From 083f91363aee04f06cab1f4cc895a4aca185d04c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 23 May 2018 18:21:07 -0400 Subject: [PATCH 1/4] pirkey APA102 defs were commented out in mpconfigboard.h --- ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h index a26fd7fdd0..fd4f92289c 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h @@ -1,8 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Adafruit pIRKey M0" #define MICROPY_HW_MCU_NAME "samd21e18" -// #define MICROPY_HW_APA102_MOSI (&pin_PA00) -// #define MICROPY_HW_APA102_SCK (&pin_PA01) +#define MICROPY_HW_APA102_MOSI (&pin_PA00) +#define MICROPY_HW_APA102_SCK (&pin_PA01) // #define CIRCUITPY_BITBANG_APA102 From b9f36184f57264926230e31096ea0321c6de9382 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 24 May 2018 13:28:03 -0400 Subject: [PATCH 2/4] refine pirkey build --- .gitmodules | 6 +++ .../Adafruit_CircuitPython_CircuitPlayground | 2 +- frozen/Adafruit_CircuitPython_DotStar | 1 + frozen/Adafruit_CircuitPython_IRRemote | 1 + frozen/Adafruit_CircuitPython_seesaw | 2 +- .../boards/pirkey_m0/mpconfigboard.h | 52 +++++++++++++++++++ .../boards/pirkey_m0/mpconfigboard.mk | 5 ++ ports/atmel-samd/mpconfigport.h | 18 +++++++ shared-bindings/busio/__init__.c | 5 +- 9 files changed, 89 insertions(+), 3 deletions(-) create mode 160000 frozen/Adafruit_CircuitPython_DotStar create mode 160000 frozen/Adafruit_CircuitPython_IRRemote diff --git a/.gitmodules b/.gitmodules index 9025eb7d66..d0f3fd5656 100644 --- a/.gitmodules +++ b/.gitmodules @@ -61,3 +61,9 @@ [submodule "ports/atmel-samd/Adafruit_CircuitPython_seesaw"] path = frozen/Adafruit_CircuitPython_seesaw url = https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git +[submodule "frozen/Adafruit_CircuitPython_IRRemote"] + path = frozen/Adafruit_CircuitPython_IRRemote + url = https://github.com/adafruit/Adafruit_CircuitPython_IRRemote.git +[submodule "frozen/Adafruit_CircuitPython_DotStar"] + path = frozen/Adafruit_CircuitPython_DotStar + url = https://github.com/adafruit/Adafruit_CircuitPython_DotStar.git diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index a669915237..d82fb2399b 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit a669915237545638c64f89400f368a91c408cd5d +Subproject commit d82fb2399b304e4cac10f0001ac63b76dd6b2ba0 diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar new file mode 160000 index 0000000000..af25424ee7 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -0,0 +1 @@ +Subproject commit af25424ee7dbebea3e5d77390c017018ffa52d36 diff --git a/frozen/Adafruit_CircuitPython_IRRemote b/frozen/Adafruit_CircuitPython_IRRemote new file mode 160000 index 0000000000..c29e10b590 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_IRRemote @@ -0,0 +1 @@ +Subproject commit c29e10b590efbdf06163897b49cd0c2bea82ad6e diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index 71f3947ff9..498f59bf92 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit 71f3947ff94ca070eb01c5f872b0400031be8086 +Subproject commit 498f59bf926477b3a8fb8eb157ca05eb12c3e298 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h index fd4f92289c..15979ae778 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h @@ -12,6 +12,58 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE 0 +// A number of modules are removed for pIRKey to make room for frozen libraries. +#define PIRKEY_M0 (1) + #include "internal_flash.h" #define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) + +#define IGNORE_PIN_PA02 1 +#define IGNORE_PIN_PA03 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA06 1 +#define IGNORE_PIN_PA07 1 +#define IGNORE_PIN_PA08 1 +#define IGNORE_PIN_PA09 1 +#define IGNORE_PIN_PA10 1 +#define IGNORE_PIN_PA11 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA15 1 +#define IGNORE_PIN_PA16 1 +#define IGNORE_PIN_PA17 1 +#define IGNORE_PIN_PA18 1 +#define IGNORE_PIN_PA19 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 1 +#define IGNORE_PIN_PA22 1 +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 +#define IGNORE_PIN_PA27 1 +#define IGNORE_PIN_PA30 1 +#define IGNORE_PIN_PA31 1 +#define IGNORE_PIN_PB00 1 +#define IGNORE_PIN_PB01 1 +#define IGNORE_PIN_PB02 1 +#define IGNORE_PIN_PB03 1 +#define IGNORE_PIN_PB04 1 +#define IGNORE_PIN_PB05 1 +#define IGNORE_PIN_PB06 1 +#define IGNORE_PIN_PB07 1 +#define IGNORE_PIN_PB08 1 +#define IGNORE_PIN_PB09 1 +#define IGNORE_PIN_PB10 1 +#define IGNORE_PIN_PB11 1 +#define IGNORE_PIN_PB12 1 +#define IGNORE_PIN_PB13 1 +#define IGNORE_PIN_PB14 1 +#define IGNORE_PIN_PB15 1 +#define IGNORE_PIN_PB16 1 +#define IGNORE_PIN_PB17 1 +#define IGNORE_PIN_PB22 1 +#define IGNORE_PIN_PB23 1 +#define IGNORE_PIN_PB30 1 +#define IGNORE_PIN_PB31 1 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index 87b46c642f..0f8d0f9ca4 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -9,3 +9,8 @@ LONGINT_IMPL = NONE CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 0d07e0009e..15cb514049 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -247,6 +247,23 @@ extern const struct _mp_obj_module_t usb_hid_module; #define TOUCHIO_MODULE #endif +// A pIRKey has minimal I/O needs. Remove unneeded modules to make room +// for frozen modules. math is very large and is also removed. +#ifdef PIRKEY_M0 +#define MICROPY_PORT_BUILTIN_MODULES \ + { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, +#else #define MICROPY_PORT_BUILTIN_MODULES \ { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \ @@ -267,6 +284,7 @@ extern const struct _mp_obj_module_t usb_hid_module; { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, \ TOUCHIO_MODULE \ EXTRA_BUILTIN_MODULES +#endif #define MICROPY_PORT_BUILTIN_DEBUG_MODULES \ { MP_OBJ_NEW_QSTR(MP_QSTR_uheap),(mp_obj_t)&uheap_module }, \ diff --git a/shared-bindings/busio/__init__.c b/shared-bindings/busio/__init__.c index 958ee062af..0ed0bf22db 100644 --- a/shared-bindings/busio/__init__.c +++ b/shared-bindings/busio/__init__.c @@ -87,10 +87,13 @@ STATIC const mp_rom_map_elem_t busio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busio) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&busio_i2c_type) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&busio_spi_type) }, +// a pIRKey does not need these. Remove them to make room for frozen modules. +#ifndef PIRKEY_M0 + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&busio_i2c_type) }, { MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&busio_onewire_type) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&busio_uart_type) }, +#endif }; STATIC MP_DEFINE_CONST_DICT(busio_module_globals, busio_module_globals_table); From ee896cdd41f9c3f3ca4fdc7c08b8e24caabe950b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 24 May 2018 20:20:18 -0400 Subject: [PATCH 3/4] restore I2C and UART. Don't do port.c resets and inits for modules that are not available. --- ports/atmel-samd/supervisor/port.c | 12 ++++++++---- shared-bindings/busio/__init__.c | 5 +---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index cd122843de..8571348fbb 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -190,7 +190,10 @@ safe_mode_t port_init(void) { // Configure millisecond timer initialization. tick_init(); + +#ifndef PIRKEY_M0 rtc_init(); +#endif // Init the nvm controller. // struct nvm_config config_nvm; @@ -249,18 +252,19 @@ void reset_port(void) { pulsein_reset(); pulseout_reset(); pwmout_reset(); + +#ifndef PIRKEY_M0 + analogin_reset(); + analogout_reset(); rtc_reset(); +#endif reset_gclks(); - analogin_reset(); - #ifdef CIRCUITPY_GAMEPAD_TICKS gamepad_reset(); #endif - analogout_reset(); - reset_event_system(); reset_all_pins(); diff --git a/shared-bindings/busio/__init__.c b/shared-bindings/busio/__init__.c index 0ed0bf22db..958ee062af 100644 --- a/shared-bindings/busio/__init__.c +++ b/shared-bindings/busio/__init__.c @@ -87,13 +87,10 @@ STATIC const mp_rom_map_elem_t busio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busio) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&busio_spi_type) }, -// a pIRKey does not need these. Remove them to make room for frozen modules. -#ifndef PIRKEY_M0 { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&busio_i2c_type) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&busio_spi_type) }, { MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&busio_onewire_type) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&busio_uart_type) }, -#endif }; STATIC MP_DEFINE_CONST_DICT(busio_module_globals, busio_module_globals_table); From 052a9ff3782ecad55ddece286af00cbd0a7fe57b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 24 May 2018 21:40:49 -0400 Subject: [PATCH 4/4] update cpx lib --- frozen/Adafruit_CircuitPython_CircuitPlayground | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index d82fb2399b..d0022de9d5 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit d82fb2399b304e4cac10f0001ac63b76dd6b2ba0 +Subproject commit d0022de9d5e9b4c3d4998a5d708e59ee147f0a21