From db5f99c63ebee26a32e66f345ae0502f1004aa61 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 4 Jan 2022 14:15:20 -0600 Subject: [PATCH 01/13] Add a function to get low level register access The port is free to return NULL for any/all of these, and the caller has to check. This will be used in the floppy code, because aside from getting the registers, it looks like all is independent of MCU. --- .../common-hal/digitalio/DigitalInOut.c | 27 +++++++++++++++++++ .../common-hal/digitalio/DigitalInOut.c | 25 +++++++++++++++++ shared-bindings/digitalio/DigitalInOut.h | 11 ++++++++ 3 files changed, 63 insertions(+) diff --git a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c index 40637bef4b..dee927ce88 100644 --- a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +++ b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c @@ -187,3 +187,30 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( } } } + +bool common_hal_digitalio_has_reg_op(digitalinout_reg_op_t op) { + return true; +} + +volatile uint32_t *common_hal_digitalio_digitalinout_get_reg(digitalio_digitalinout_obj_t *self, digitalinout_reg_op_t op, uint32_t *mask) { + const uint8_t pin = self->pin->number; + int port = GPIO_PORT(pin); + + *mask = 1u << GPIO_PIN(pin); + + + switch (op) { + case DIGITALINOUT_REG_READ: + return (volatile uint32_t *)&PORT->Group[port].IN.reg; + case DIGITALINOUT_REG_WRITE: + return &PORT->Group[port].OUT.reg; + case DIGITALINOUT_REG_SET: + return &PORT->Group[port].OUTSET.reg; + case DIGITALINOUT_REG_RESET: + return &PORT->Group[port].OUTCLR.reg; + case DIGITALINOUT_REG_TOGGLE: + return &PORT->Group[port].OUTTGL.reg; + default: + return NULL; + } +} diff --git a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c index 22a61afa3f..a8a5a6b4d9 100644 --- a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c +++ b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c @@ -164,3 +164,28 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( } return PULL_NONE; } + +bool common_hal_digitalio_has_reg_op(digitalinout_reg_op_t op) { + return true; +} + +volatile uint32_t *common_hal_digitalio_digitalinout_get_reg(digitalio_digitalinout_obj_t *self, digitalinout_reg_op_t op, uint32_t *mask) { + const uint8_t pin = self->pin->number; + + *mask = 1u << pin; + + switch (op) { + case DIGITALINOUT_REG_READ: + return (volatile uint32_t *)&sio_hw->gpio_in; + case DIGITALINOUT_REG_WRITE: + return &sio_hw->gpio_out; + case DIGITALINOUT_REG_SET: + return &sio_hw->gpio_set; + case DIGITALINOUT_REG_RESET: + return &sio_hw->gpio_clr; + case DIGITALINOUT_REG_TOGGLE: + return &sio_hw->gpio_togl; + default: + return NULL; + } +} diff --git a/shared-bindings/digitalio/DigitalInOut.h b/shared-bindings/digitalio/DigitalInOut.h index ebc94fa1a6..b6edbc63aa 100644 --- a/shared-bindings/digitalio/DigitalInOut.h +++ b/shared-bindings/digitalio/DigitalInOut.h @@ -41,6 +41,14 @@ typedef enum { DIGITALINOUT_INPUT_ONLY } digitalinout_result_t; +typedef enum { + DIGITALINOUT_REG_READ, + DIGITALINOUT_REG_WRITE, + DIGITALINOUT_REG_SET, + DIGITALINOUT_REG_RESET, + DIGITALINOUT_REG_TOGGLE, +} digitalinout_reg_op_t; + digitalinout_result_t common_hal_digitalio_digitalinout_construct(digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin); void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self); bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self); @@ -56,4 +64,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(digitalio_digitalino void common_hal_digitalio_digitalinout_never_reset(digitalio_digitalinout_obj_t *self); digitalio_digitalinout_obj_t *assert_digitalinout(mp_obj_t obj); +volatile uint32_t *common_hal_digitalio_digitalinout_get_reg(digitalio_digitalinout_obj_t *self, digitalinout_reg_op_t op, uint32_t *mask); +bool common_hal_digitalio_has_reg_op(digitalinout_reg_op_t op); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DIGITALIO_DIGITALINOUT_H From d816a4f19de435a59070948aa2e860cbb31e0f39 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 4 Jan 2022 17:26:25 -0600 Subject: [PATCH 02/13] Add floppyio Initially enabled for samd51, this enables reading raw flux data as well as DOS/MFM formatted media. This is only the low-level code for reading & decoding flux pulses from a floppy drive. high level details will live in a Python library. adafruit-circuitpython-floppy will take care of details like stepping from track to track, etc. --- .gitmodules | 3 + lib/adafruit_floppy | 1 + .../atmel-samd/common-hal/floppyio/__init__.h | 30 ++++ ports/atmel-samd/mpconfigport.mk | 2 + py/circuitpy_defns.mk | 4 + py/circuitpy_mpconfig.mk | 3 + shared-bindings/floppyio/__init__.c | 128 ++++++++++++++++++ shared-bindings/floppyio/__init__.h | 32 +++++ shared-module/floppyio/__init__.c | 108 +++++++++++++++ 9 files changed, 311 insertions(+) create mode 160000 lib/adafruit_floppy create mode 100644 ports/atmel-samd/common-hal/floppyio/__init__.h create mode 100644 shared-bindings/floppyio/__init__.c create mode 100644 shared-bindings/floppyio/__init__.h create mode 100644 shared-module/floppyio/__init__.c diff --git a/.gitmodules b/.gitmodules index 9376daebdc..c6c6512813 100644 --- a/.gitmodules +++ b/.gitmodules @@ -199,3 +199,6 @@ url = https://github.com/raspberrypi/rpi-firmware.git branch = master shallow = true +[submodule "lib/adafruit_floppy"] + path = lib/adafruit_floppy + url = https://github.com/adafruit/Adafruit_Floppy diff --git a/lib/adafruit_floppy b/lib/adafruit_floppy new file mode 160000 index 0000000000..d5d34127db --- /dev/null +++ b/lib/adafruit_floppy @@ -0,0 +1 @@ +Subproject commit d5d34127db8167b7a6aca8045d27f6b9e3930c6d diff --git a/ports/atmel-samd/common-hal/floppyio/__init__.h b/ports/atmel-samd/common-hal/floppyio/__init__.h new file mode 100644 index 0000000000..693babb2ef --- /dev/null +++ b/ports/atmel-samd/common-hal/floppyio/__init__.h @@ -0,0 +1,30 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +// empirical-ish from Arduino @ 120MHz +#define FLOPPYIO_SAMPLERATE (14666667) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 9d238834fe..51024b7b67 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -87,6 +87,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_ALARM ?= 1 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_SAMD ?= 1 +CIRCUITPY_FLOPPYIO ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) CIRCUITPY_WATCHDOG ?= 1 @@ -107,6 +108,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_ALARM ?= 1 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_SAMD ?= 1 +CIRCUITPY_FLOPPYIO ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 48a37be499..06399673a2 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -164,6 +164,9 @@ endif ifeq ($(CIRCUITPY_VECTORIO),1) SRC_PATTERNS += vectorio/% endif +ifeq ($(CIRCUITPY_FLOPPYIO),1) +SRC_PATTERNS += floppyio/% +endif ifeq ($(CIRCUITPY_FRAMEBUFFERIO),1) SRC_PATTERNS += framebufferio/% endif @@ -526,6 +529,7 @@ SRC_SHARED_MODULE_ALL = \ displayio/TileGrid.c \ displayio/area.c \ displayio/__init__.c \ + floppyio/__init__.c \ fontio/BuiltinFont.c \ fontio/__init__.c \ framebufferio/FramebufferDisplay.c \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 14852580e5..d0d33949ab 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -219,6 +219,9 @@ CFLAGS += -DCIRCUITPY_ESPIDF=$(CIRCUITPY_ESPIDF) CIRCUITPY__EVE ?= 0 CFLAGS += -DCIRCUITPY__EVE=$(CIRCUITPY__EVE) +CIRCUITPY_FLOPPYIO ?= 0 +CFLAGS += -DCIRCUITPY_FLOPPYIO=$(CIRCUITPY_FLOPPYIO) + CIRCUITPY_FREQUENCYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_FREQUENCYIO=$(CIRCUITPY_FREQUENCYIO) diff --git a/shared-bindings/floppyio/__init__.c b/shared-bindings/floppyio/__init__.c new file mode 100644 index 0000000000..c2d1fbb21f --- /dev/null +++ b/shared-bindings/floppyio/__init__.c @@ -0,0 +1,128 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/floppyio/__init__.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "common-hal/floppyio/__init__.h" + +#include + +#include "py/binary.h" +#include "py/enum.h" +#include "py/obj.h" +#include "py/runtime.h" + +//| def flux_readinto(buffer: WriteableBuffer, data: DigitalInOut, index: DigitalInOut) -> int: +//| """Read flux transition information into the buffer. +//| +//| The function returns when the buffer has filled, or when the index input +//| indicates that one full revolution of data has been recorded. Due to +//| technical limitations, this process may not be interruptible by +//| KeyboardInterrupt. +//| +//| :param buffer: Read data into this buffer. Each element represents the time between successive zero-to-one transitions. +//| :param data: Pin on which the flux data appears +//| :param index: Pin on which the index pulse appears +//| :return: The actual number of bytes of read +//| """ +//| ... +//| +STATIC mp_obj_t floppyio_flux_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_buffer, ARG_data, ARG_index }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_index, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE); + digitalio_digitalinout_obj_t *data = assert_digitalinout(args[ARG_data].u_obj); + digitalio_digitalinout_obj_t *index = assert_digitalinout(args[ARG_index].u_obj); + + return MP_OBJ_NEW_SMALL_INT(common_hal_floppyio_flux_readinto(bufinfo.buf, bufinfo.len, data, index)); +} +MP_DEFINE_CONST_FUN_OBJ_KW(floppyio_flux_readinto_obj, 0, floppyio_flux_readinto); + +//| def mfm_readinto(buffer: WriteableBuffer, data: DigitalInOut, index: DigitalInOut) -> int: +//| """Read mfm blocks into the buffer. +//| +//| The track is assumed to consist of 512-byte sectors. +//| +//| The function returns when all sectors have been successfully read, or +//| a number of index pulses have occurred. Due to technical limitations, this +//| process may not be interruptible by KeyboardInterrupt. +//| +//| :param buffer: Read data into this buffer. Must be a multiple of 512. +//| :param data: Pin on which the mfm data appears +//| :param index: Pin on which the index pulse appears +//| :return: The actual number of sectors read +//| """ +//| ... +//| +STATIC mp_obj_t floppyio_mfm_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_buffer, ARG_data, ARG_index }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_index, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE); + digitalio_digitalinout_obj_t *data = assert_digitalinout(args[ARG_data].u_obj); + digitalio_digitalinout_obj_t *index = assert_digitalinout(args[ARG_index].u_obj); + + if (bufinfo.len % 512 != 0) { + mp_raise_ValueError(translate("Buffer must be a multiple of 512 bytes")); + } + size_t n_sectors = bufinfo.len / 512; + return MP_OBJ_NEW_SMALL_INT(common_hal_floppyio_mfm_readinto(bufinfo.buf, n_sectors, data, index)); +} +MP_DEFINE_CONST_FUN_OBJ_KW(floppyio_mfm_readinto_obj, 0, floppyio_mfm_readinto); + +//| samplerate: int +//| """The approximate sample rate in Hz used by flux_readinto.""" +//| + +STATIC const mp_rom_map_elem_t floppyio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_floppyio) }, + { MP_ROM_QSTR(MP_QSTR_flux_readinto), MP_ROM_PTR(&floppyio_flux_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_mfm_readinto), MP_ROM_PTR(&floppyio_mfm_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_samplerate), MP_ROM_INT(FLOPPYIO_SAMPLERATE) }, +}; +STATIC MP_DEFINE_CONST_DICT(floppyio_module_globals, floppyio_module_globals_table); + +const mp_obj_module_t floppyio_module = { + .base = {&mp_type_module }, + .globals = (mp_obj_dict_t *)&floppyio_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_floppyio, floppyio_module, CIRCUITPY_FLOPPYIO); diff --git a/shared-bindings/floppyio/__init__.h b/shared-bindings/floppyio/__init__.h new file mode 100644 index 0000000000..322bbe7d43 --- /dev/null +++ b/shared-bindings/floppyio/__init__.h @@ -0,0 +1,32 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "common-hal/digitalio/DigitalInOut.h" + +int common_hal_floppyio_flux_readinto(void *buf, size_t len, digitalio_digitalinout_obj_t *data, digitalio_digitalinout_obj_t *index); +int common_hal_floppyio_mfm_readinto(void *buf, size_t n_sector, digitalio_digitalinout_obj_t *data, digitalio_digitalinout_obj_t *index); diff --git a/shared-module/floppyio/__init__.c b/shared-module/floppyio/__init__.c new file mode 100644 index 0000000000..c68b4d9ad2 --- /dev/null +++ b/shared-module/floppyio/__init__.c @@ -0,0 +1,108 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "hal_gpio.h" + +#include "py/runtime.h" + +#include "shared-bindings/time/__init__.h" +#include "shared-bindings/floppyio/__init__.h" +#include "common-hal/floppyio/__init__.h" +#include "shared-bindings/digitalio/DigitalInOut.h" + +#define T2_5 (FLOPPYIO_SAMPLERATE * 5 / 2 / 1000000) +#define T3_5 (FLOPPYIO_SAMPLERATE * 7 / 2 / 1000000) + +#define MFM_IO_MMIO (1) +#include "lib/adafruit_floppy/mfm_impl.h" + +__attribute__((optimize("O3"))) +int common_hal_floppyio_flux_readinto(void *buf, size_t len, digitalio_digitalinout_obj_t *data, digitalio_digitalinout_obj_t *index) { + uint32_t index_mask; + volatile uint32_t *index_port = common_hal_digitalio_digitalinout_get_reg(index, DIGITALINOUT_REG_READ, &index_mask); + + uint32_t data_mask; + volatile uint32_t *data_port = common_hal_digitalio_digitalinout_get_reg(data, DIGITALINOUT_REG_READ, &data_mask); + +#undef READ_INDEX +#undef READ_DATA +#define READ_INDEX() (!!(*index_port & index_mask)) +#define READ_DATA() (!!(*data_port & data_mask)) + + memset(buf, 0, len); + + uint8_t *pulses = buf, *pulses_ptr = pulses, *pulses_end = pulses + len; + + common_hal_mcu_disable_interrupts(); + + // wait for index pulse low + while (READ_INDEX()) { /* NOTHING */ + } + + + // if data line is low, wait till it rises + while (!READ_DATA()) { /* NOTHING */ + } + + // and then till it drops down + while (READ_DATA()) { /* NOTHING */ + } + + uint32_t index_state = 0; + while (pulses_ptr < pulses_end) { + index_state = (index_state << 1) | READ_INDEX(); + if ((index_state & 3) == 2) { // a zero-to-one transition + break; + } + + unsigned pulse_count = 3; + while (!READ_DATA()) { + pulse_count++; + } + + while (READ_DATA()) { + pulse_count++; + } + + *pulses_ptr++ = MIN(255, pulse_count); + } + common_hal_mcu_enable_interrupts(); + + return pulses_ptr - pulses; +} + +int common_hal_floppyio_mfm_readinto(void *buf, size_t n_sectors, digitalio_digitalinout_obj_t *data, digitalio_digitalinout_obj_t *index) { + mfm_io_t io; + io.index_port = common_hal_digitalio_digitalinout_get_reg(index, DIGITALINOUT_REG_READ, &io.index_mask); + io.data_port = common_hal_digitalio_digitalinout_get_reg(data, DIGITALINOUT_REG_READ, &io.data_mask); + + common_hal_mcu_disable_interrupts(); + uint8_t validity[n_sectors]; + int result = read_track(io, n_sectors, buf, validity); + common_hal_mcu_enable_interrupts(); + + return result; +} From a08c5c09509765b31f23382a754229b0e7c46d1a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 13 Jan 2022 19:33:10 -0600 Subject: [PATCH 03/13] fix types --- shared-bindings/floppyio/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/floppyio/__init__.c b/shared-bindings/floppyio/__init__.c index c2d1fbb21f..3ef58b2f66 100644 --- a/shared-bindings/floppyio/__init__.c +++ b/shared-bindings/floppyio/__init__.c @@ -35,7 +35,7 @@ #include "py/obj.h" #include "py/runtime.h" -//| def flux_readinto(buffer: WriteableBuffer, data: DigitalInOut, index: DigitalInOut) -> int: +//| def flux_readinto(buffer: WriteableBuffer, data: digitalio.DigitalInOut, index: digitalio.DigitalInOut) -> int: //| """Read flux transition information into the buffer. //| //| The function returns when the buffer has filled, or when the index input @@ -69,7 +69,7 @@ STATIC mp_obj_t floppyio_flux_readinto(size_t n_args, const mp_obj_t *pos_args, } MP_DEFINE_CONST_FUN_OBJ_KW(floppyio_flux_readinto_obj, 0, floppyio_flux_readinto); -//| def mfm_readinto(buffer: WriteableBuffer, data: DigitalInOut, index: DigitalInOut) -> int: +//| def mfm_readinto(buffer: WriteableBuffer, data: digitalio.DigitalInOut, index: digitalio.DigitalInOut) -> int: //| """Read mfm blocks into the buffer. //| //| The track is assumed to consist of 512-byte sectors. From 88abbb0029ef7c77d0bc85364c54ea57170ffc67 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 13 Jan 2022 20:40:30 -0600 Subject: [PATCH 04/13] submodules required must be listed explicitly --- tools/ci_fetch_deps.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index 60557c3952..cecf37e08b 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -18,6 +18,7 @@ port_deps = { "extmod/ulab/", "lib/mp3/", "lib/protomatter/", + "lib/adafruit_floppy/", "lib/quirc/", "lib/tinyusb/", "data/nvm.toml/", From 6c53b06a3c45d79ed1ad487fcf3342b20e1328d8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 14 Jan 2022 14:11:12 -0600 Subject: [PATCH 05/13] Update adafruit floppy submodule --- lib/adafruit_floppy | 2 +- shared-module/floppyio/__init__.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/adafruit_floppy b/lib/adafruit_floppy index d5d34127db..a00e78b871 160000 --- a/lib/adafruit_floppy +++ b/lib/adafruit_floppy @@ -1 +1 @@ -Subproject commit d5d34127db8167b7a6aca8045d27f6b9e3930c6d +Subproject commit a00e78b871abd40563c6de1b35a4d61a575fd1df diff --git a/shared-module/floppyio/__init__.c b/shared-module/floppyio/__init__.c index c68b4d9ad2..a9cae48c19 100644 --- a/shared-module/floppyio/__init__.c +++ b/shared-module/floppyio/__init__.c @@ -37,7 +37,7 @@ #define T3_5 (FLOPPYIO_SAMPLERATE * 7 / 2 / 1000000) #define MFM_IO_MMIO (1) -#include "lib/adafruit_floppy/mfm_impl.h" +#include "lib/adafruit_floppy/src/mfm_impl.h" __attribute__((optimize("O3"))) int common_hal_floppyio_flux_readinto(void *buf, size_t len, digitalio_digitalinout_obj_t *data, digitalio_digitalinout_obj_t *index) { From e32f0c1513d6586608df8312e5e79c8b348ad5bd Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 17 Jan 2022 11:13:45 -0600 Subject: [PATCH 06/13] update submodule --- lib/adafruit_floppy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/adafruit_floppy b/lib/adafruit_floppy index a00e78b871..94e3802157 160000 --- a/lib/adafruit_floppy +++ b/lib/adafruit_floppy @@ -1 +1 @@ -Subproject commit a00e78b871abd40563c6de1b35a4d61a575fd1df +Subproject commit 94e38021574e3e2c25bd1b8af01ad404e31f5409 From 8e895e1986dc13753a6ac3229e3b4ca727634aca Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 17 Jan 2022 16:30:28 -0600 Subject: [PATCH 07/13] Add floppyio for rp2040 Tested on RP2040 Feather with a 3.5" Prodigy diskette, the whole surface reads 100% across 3+ trials. --- lib/adafruit_floppy | 2 +- .../common-hal/floppyio/__init__.h | 37 +++++++++++++++++++ ports/raspberrypi/mpconfigport.mk | 1 + shared-module/floppyio/__init__.c | 6 ++- 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 ports/raspberrypi/common-hal/floppyio/__init__.h diff --git a/lib/adafruit_floppy b/lib/adafruit_floppy index 94e3802157..e36a6127b9 160000 --- a/lib/adafruit_floppy +++ b/lib/adafruit_floppy @@ -1 +1 @@ -Subproject commit 94e38021574e3e2c25bd1b8af01ad404e31f5409 +Subproject commit e36a6127b957ab2f602e031ba3583de9c571582e diff --git a/ports/raspberrypi/common-hal/floppyio/__init__.h b/ports/raspberrypi/common-hal/floppyio/__init__.h new file mode 100644 index 0000000000..7dbf8a7af7 --- /dev/null +++ b/ports/raspberrypi/common-hal/floppyio/__init__.h @@ -0,0 +1,37 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +// empirical-ish from RP2040 @ 125MHz for floppy_flux_readinto +#define FLOPPYIO_SAMPLERATE (24000000) +// empirical-ish from RP2040 @ 125MHz for floppy_mfm_readinto +// my guess is these are slower because the more complex routine falls out of cache, but it's just +// speculation because the loops are very similar. When looking at raw bins with a modified +// version of adafruit_floppy, it can be seen that there are _two_ peaks for T2 and T3, rather +// than a single one, around 36 (mostly) and 43 (rarer), compared to a single peak around 48. +#define T2_5 (54) +#define T3_5 (75) diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 1dfb345f5d..80938c47b0 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -5,6 +5,7 @@ CIRCUITPY_ALARM ?= 1 CIRCUITPY_RP2PIO ?= 1 CIRCUITPY_NEOPIXEL_WRITE ?= $(CIRCUITPY_RP2PIO) +CIRCUITPY_FLOPPYIO ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_DISPLAYIO) CIRCUITPY_FULL_BUILD ?= 1 CIRCUITPY_AUDIOMP3 ?= 1 diff --git a/shared-module/floppyio/__init__.c b/shared-module/floppyio/__init__.c index a9cae48c19..6700c48078 100644 --- a/shared-module/floppyio/__init__.c +++ b/shared-module/floppyio/__init__.c @@ -24,8 +24,6 @@ * THE SOFTWARE. */ -#include "hal_gpio.h" - #include "py/runtime.h" #include "shared-bindings/time/__init__.h" @@ -33,8 +31,12 @@ #include "common-hal/floppyio/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#ifndef T2_5 #define T2_5 (FLOPPYIO_SAMPLERATE * 5 / 2 / 1000000) +#endif +#ifndef T3_5 #define T3_5 (FLOPPYIO_SAMPLERATE * 7 / 2 / 1000000) +#endif #define MFM_IO_MMIO (1) #include "lib/adafruit_floppy/src/mfm_impl.h" From bf57f3606a437a3a41aa0943ecf7b7b427010092 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 1 Feb 2022 10:19:17 -0600 Subject: [PATCH 08/13] rp2pio: Add pull up/down support for the "jmp pin" This is needed so that the floppy flux reader can enable the pull up on the index pin while using it as a pio jmp pin. Also fixes a doc bug where the `jmp_pin` was omitted in one spot in the docs. --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 9 +++++++-- ports/raspberrypi/bindings/rp2pio/StateMachine.h | 3 ++- ports/raspberrypi/common-hal/audiobusio/I2SOut.c | 2 +- ports/raspberrypi/common-hal/audiobusio/PDMIn.c | 2 +- .../common-hal/imagecapture/ParallelImageCapture.c | 2 +- .../common-hal/paralleldisplay/ParallelBus.c | 2 +- .../common-hal/rotaryio/IncrementalEncoder.c | 2 +- ports/raspberrypi/common-hal/rp2pio/StateMachine.c | 13 ++++++++++++- 8 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 3dcc6e927b..90af6ebce0 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -79,6 +79,8 @@ //| initial_sideset_pin_state: int = 0, //| initial_sideset_pin_direction: int = 0x1f, //| sideset_enable: bool = False, +//| jmp_pin: Optional[microcontroller.Pin] = None, +//| jmp_pin_pull: Optional[digitalio.Pull] = None, //| exclusive_pin_use: bool = True, //| auto_pull: bool = False, //| pull_threshold: int = 32, @@ -113,6 +115,7 @@ //| :param int initial_sideset_pin_direction: the initial output direction for sideset pins starting at first_sideset_pin //| :param bool sideset_enable: True when the top sideset bit is to enable. This should be used with the ".side_set # opt" directive //| :param ~microcontroller.Pin jmp_pin: the pin which determines the branch taken by JMP PIN instructions +//| :param ~digitalio.Pull jmp_pin_pull: The pull value for the jmp pin, default is no pull. //| :param bool exclusive_pin_use: When True, do not share any pins with other state machines. Pins are never shared with other peripherals //| :param bool auto_pull: When True, automatically load data from the tx FIFO into the //| output shift register (OSR) when an OUT instruction shifts more than pull_threshold bits @@ -150,7 +153,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n ARG_first_set_pin, ARG_set_pin_count, ARG_initial_set_pin_state, ARG_initial_set_pin_direction, ARG_first_sideset_pin, ARG_sideset_pin_count, ARG_initial_sideset_pin_state, ARG_initial_sideset_pin_direction, ARG_sideset_enable, - ARG_jmp_pin, + ARG_jmp_pin, ARG_jmp_pin_pull, ARG_exclusive_pin_use, ARG_auto_pull, ARG_pull_threshold, ARG_out_shift_right, ARG_wait_for_txstall, @@ -184,6 +187,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_sideset_enable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_jmp_pin, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_jmp_pin_pull, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_exclusive_pin_use, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} }, { MP_QSTR_auto_pull, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, @@ -230,6 +234,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n } const mcu_pin_obj_t *jmp_pin = validate_obj_is_pin_or_none(args[ARG_jmp_pin].u_obj); + digitalio_pull_t jmp_pin_pull = validate_pull(args[ARG_jmp_pin_pull].u_rom_obj, MP_QSTR_jmp_pull); mp_int_t pull_threshold = args[ARG_pull_threshold].u_int; mp_int_t push_threshold = args[ARG_push_threshold].u_int; @@ -263,7 +268,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n first_set_pin, args[ARG_set_pin_count].u_int, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int, first_sideset_pin, args[ARG_sideset_pin_count].u_int, args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int, args[ARG_sideset_enable].u_bool, - jmp_pin, + jmp_pin, jmp_pin_pull, 0, args[ARG_exclusive_pin_use].u_bool, args[ARG_auto_pull].u_bool, pull_threshold, args[ARG_out_shift_right].u_bool, diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.h b/ports/raspberrypi/bindings/rp2pio/StateMachine.h index 3f3b8cf7d8..e2770cd46d 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.h +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.h @@ -29,6 +29,7 @@ #include "py/obj.h" +#include "shared-bindings/digitalio/Pull.h" #include "common-hal/microcontroller/Pin.h" #include "common-hal/rp2pio/StateMachine.h" @@ -45,7 +46,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count, uint32_t initial_set_pin_state, uint32_t initial_set_pin_direction, const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction, bool sideset_enable, - const mcu_pin_obj_t *jmp_pin, + const mcu_pin_obj_t *jmp_pin, digitalio_pull_t jmp_pin_pull, uint32_t wait_gpio_mask, bool exclusive_pin_use, bool auto_pull, uint8_t pull_threshold, bool out_shift_right, diff --git a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c index 4296014e50..d5699742e4 100644 --- a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c +++ b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c @@ -127,7 +127,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self, 0, 0, // in pulls NULL, 0, 0, 0x1f, // set pins bit_clock, 2, 0, 0x1f, // sideset pins - NULL, // jump pin + NULL, PULL_NONE, // jump pin 0, // wait gpio pins true, // exclusive pin use false, 32, false, // shift out left to start with MSB diff --git a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c index 859e82eb11..4579dedcf5 100644 --- a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c +++ b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -71,7 +71,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, 0, 0, // in pulls NULL, 0, 0, 0x1f, // set pins clock_pin, 1, 0, 0x1f, // sideset pins - NULL, // jump pin + NULL, PULL_NONE, // jump pin 0, // wait gpio pins true, // exclusive pin use false, 32, false, // out settings diff --git a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c index 45a3766897..8890e3f526 100644 --- a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c @@ -112,7 +112,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle NULL, 0, 0, 0, // sideset pins #endif false, // No sideset enable - NULL, // jump pin + NULL, PULL_NONE, // jump pin (1 << vertical_sync->number) | (1 << horizontal_reference->number) | (1 << data_clock->number), // wait gpio pins true, // exclusive pin use false, 32, false, // out settings diff --git a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c index 2e0ae4def2..12f8d79a74 100644 --- a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c @@ -100,7 +100,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu NULL, 0, 0, 0, // first set pin write, 1, 0, 1, // first sideset pin false, // No sideset enable - NULL, // jump pin + NULL, PULL_NONE, // jump pin 0, // wait gpio pins true, // exclusive pin usage true, 8, true, // TX, auto pull every 8 bits. shift left to output msb first diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c index 1f15b010f7..faf63c2812 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -86,7 +86,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode NULL, 0, 0, 0x1f, // set pins NULL, 0, 0, 0x1f, // sideset pins false, // No sideset enable - NULL, // jump pin + NULL, PULL_NONE, // jump pin 0, // wait gpio pins true, // exclusive pin use false, 32, false, // out settings diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index ac5a41652a..5de35e51c0 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -27,6 +27,7 @@ #include "bindings/rp2pio/StateMachine.h" #include "common-hal/microcontroller/__init__.h" +#include "shared-bindings/digitalio/Pull.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" @@ -342,7 +343,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count, uint32_t initial_set_pin_state, uint32_t initial_set_pin_direction, const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction, bool sideset_enable, - const mcu_pin_obj_t *jmp_pin, + const mcu_pin_obj_t *jmp_pin, digitalio_pull_t jmp_pull, uint32_t wait_gpio_mask, bool exclusive_pin_use, bool auto_pull, uint8_t pull_threshold, bool out_shift_right, @@ -489,6 +490,16 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, // Deal with pull up/downs uint32_t pull_up = mask_and_rotate(first_in_pin, in_pin_count, pull_pin_up); uint32_t pull_down = mask_and_rotate(first_in_pin, in_pin_count, pull_pin_down); + + if (jmp_pin) { + uint32_t jmp_mask = mask_and_rotate(jmp_pin, 1, 0x1f); + if (jmp_pull == PULL_UP) { + pull_up |= jmp_mask; + } + if (jmp_pull == PULL_DOWN) { + pull_up |= jmp_mask; + } + } if (initial_pin_direction & (pull_up | pull_down)) { mp_raise_ValueError(translate("pull masks conflict with direction masks")); } From f2c31c8d82598a193e5527dd215fc826b346ab41 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 2 Feb 2022 10:14:19 -0600 Subject: [PATCH 09/13] add adafruit_floppy, put in correct position --- tools/ci_fetch_deps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index cecf37e08b..70c7e22650 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -16,9 +16,9 @@ print(target, ref) port_deps = { "atmel-samd": [ "extmod/ulab/", + "lib/adafruit_floppy/", "lib/mp3/", "lib/protomatter/", - "lib/adafruit_floppy/", "lib/quirc/", "lib/tinyusb/", "data/nvm.toml/", @@ -31,6 +31,7 @@ port_deps = { "nrf": ["extmod/ulab/", "lib/mp3/", "lib/protomatter/", "lib/tinyusb/", "data/nvm.toml/"], "raspberrypi": [ "extmod/ulab/", + "lib/adafruit_floppy/", "lib/mp3/", "lib/protomatter/", "lib/quirc/", From 1be8ae75d4f8e422da80088388332b2be7af5aa2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 2 Feb 2022 17:07:02 -0600 Subject: [PATCH 10/13] skip floppyio if not full build --- ports/atmel-samd/mpconfigport.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 51024b7b67..a82dc8554b 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -87,7 +87,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_ALARM ?= 1 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_SAMD ?= 1 -CIRCUITPY_FLOPPYIO ?= 1 +CIRCUITPY_FLOPPYIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) CIRCUITPY_WATCHDOG ?= 1 From 224069551a0d63987b3374d5e87fdae4ac9f8fac Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 2 Feb 2022 21:36:58 -0600 Subject: [PATCH 11/13] disable onewireio on seeduino xiao (samd21) I don't understand how this stopped fitting, as none of the added code is used in this build. --- ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk index 1334c8312c..d11bd0cc28 100644 --- a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk +++ b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk @@ -9,3 +9,4 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 +CIRCUITPY_ONEWIRE = 0 From 31febc336bdfd8cd31cddd4f1a1efa99848090ee Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 2 Feb 2022 21:37:47 -0600 Subject: [PATCH 12/13] fix sam e51 comment & floppy building --- ports/atmel-samd/mpconfigport.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index a82dc8554b..c4d2133c9a 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -100,7 +100,7 @@ endif # samd51 ifeq ($(CHIP_FAMILY),same51) -# No native touchio on SAMD51. +# No native touchio on SAME51. CIRCUITPY_TOUCHIO_USE_NATIVE = 0 # The ?='s allow overriding in mpconfigboard.mk. @@ -108,7 +108,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_ALARM ?= 1 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_SAMD ?= 1 -CIRCUITPY_FLOPPYIO ?= 1 +CIRCUITPY_FLOPPYIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) From 766bf8f671911c74712407e50c5a2351e229781d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 7 Apr 2022 10:57:37 -0500 Subject: [PATCH 13/13] disable floppyio on kicksat-sprite --- ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index dd6b811f5b..11abb8a727 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -18,6 +18,7 @@ CIRCUITPY_AUDIOMIXER = 0 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_FLOPPYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_GETPASS = 0 CIRCUITPY_KEYPAD = 0