From b1a3ccb36c87598b63a2045b8c2fff05a8c61069 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 23 Nov 2021 12:34:03 -0600 Subject: [PATCH 1/7] clear out interrupt when freeing the timer Closes #5418 --- ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c index f150422e3c..8ab4edb598 100644 --- a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c +++ b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c @@ -33,6 +33,7 @@ #include "shared-module/rgbmatrix/RGBMatrix.h" #include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" void *common_hal_rgbmatrix_timer_allocate(rgbmatrix_rgbmatrix_obj_t *self) { // Choose a PWM channel based on the first RGB pin @@ -65,6 +66,8 @@ void common_hal_rgbmatrix_timer_free(void *ptr) { uint8_t slice = value & 0xff; uint8_t channel = value >> 8; pwm_set_enabled(slice, false); + irq_set_enabled(PWM_IRQ_WRAP, false); + pwm_clear_irq(slice); pwmout_free(slice, channel); return; } From 5594024bb61c6922750335177c3ef4158c11f037 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 24 Dec 2021 08:21:24 -0500 Subject: [PATCH 2/7] update frozen libraries for 7.1.x --- frozen/Adafruit_CircuitPython_BLE | 2 +- frozen/Adafruit_CircuitPython_Display_Shapes | 2 +- frozen/Adafruit_CircuitPython_Display_Text | 2 +- frozen/Adafruit_CircuitPython_LSM6DS | 2 +- frozen/Adafruit_CircuitPython_Motor | 2 +- frozen/Adafruit_CircuitPython_seesaw | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BLE b/frozen/Adafruit_CircuitPython_BLE index 434e367cc7..a695cde1b1 160000 --- a/frozen/Adafruit_CircuitPython_BLE +++ b/frozen/Adafruit_CircuitPython_BLE @@ -1 +1 @@ -Subproject commit 434e367cc7da4c2836affdbf92b8932ca59a25b0 +Subproject commit a695cde1b1cc957bcd10875b12ae82d1deeb0157 diff --git a/frozen/Adafruit_CircuitPython_Display_Shapes b/frozen/Adafruit_CircuitPython_Display_Shapes index bafa35c18a..993bd12e17 160000 --- a/frozen/Adafruit_CircuitPython_Display_Shapes +++ b/frozen/Adafruit_CircuitPython_Display_Shapes @@ -1 +1 @@ -Subproject commit bafa35c18a610660bdce68784195c4a7fbdf1189 +Subproject commit 993bd12e1747ec117e8d104a5e9f4659c8a347a3 diff --git a/frozen/Adafruit_CircuitPython_Display_Text b/frozen/Adafruit_CircuitPython_Display_Text index ca141954c0..0ec87891f9 160000 --- a/frozen/Adafruit_CircuitPython_Display_Text +++ b/frozen/Adafruit_CircuitPython_Display_Text @@ -1 +1 @@ -Subproject commit ca141954c0b39cc0343c63bedb64c02f307159b9 +Subproject commit 0ec87891f9a28ee3c5ae3b020b60d361684f466d diff --git a/frozen/Adafruit_CircuitPython_LSM6DS b/frozen/Adafruit_CircuitPython_LSM6DS index 9873446ebd..f94ef67425 160000 --- a/frozen/Adafruit_CircuitPython_LSM6DS +++ b/frozen/Adafruit_CircuitPython_LSM6DS @@ -1 +1 @@ -Subproject commit 9873446ebde5779c03c2bd4e3e544a801fb27bd5 +Subproject commit f94ef67425516f23c889d217ffe5a3a710c1d278 diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index 88e5ae5142..9995c45a5e 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit 88e5ae51427aa690de129c157223e93bf936ac41 +Subproject commit 9995c45a5ed1d455a4a8b7bfb9eb134de7f2b9db diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index 0450119e16..f06ac21e96 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit 0450119e163df782930a887022e197d6d25ca666 +Subproject commit f06ac21e96321724258e00f7596d874eff53f0b8 From b9f7fd663b192f144ab29d921514749c1195851b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 23 Dec 2021 12:24:16 -0500 Subject: [PATCH 3/7] shrink CPX crickit build --- .../boards/circuitplayground_express_crickit/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index fb65d7cd0a..4d749d2134 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -15,6 +15,7 @@ LONGINT_IMPL = NONE CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_KEYPAD = 0 +CIRCUITPY_ONEWIREIO = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground From cf349af35e02a85ebece48064530729821b2fb40 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 24 Dec 2021 11:45:07 -0500 Subject: [PATCH 4/7] turn on I2C power after reset --- ports/espressif/boards/adafruit_feather_esp32s2/board.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c index 5abd1ce1b3..b0a7862ceb 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/board.c @@ -27,11 +27,17 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" +#include "components/driver/include/driver/gpio.h" void board_init(void) { // USB common_hal_never_reset_pin(&pin_GPIO19); common_hal_never_reset_pin(&pin_GPIO20); + + // Turn on I2C + common_hal_never_reset_pin(&pin_GPIO7); + gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(7, false); } bool board_requests_safe_mode(void) { From 889b25d792382c53d233d1af225ff9012b61d4ce Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 24 Dec 2021 11:49:58 -0500 Subject: [PATCH 5/7] put I2C_POWER_INVERTED alias before D7, for prettypins --- ports/espressif/boards/adafruit_feather_esp32s2/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index fff95265b5..06f294ff0f 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -14,8 +14,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_I2C_POWER_INVERTED), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, From cf70a9ca6112369527526dfe06bdb6b0f8604407 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 24 Dec 2021 16:27:17 -0500 Subject: [PATCH 6/7] Turn on I2C power for each VM, instead of just after hard reset --- ports/espressif/boards/adafruit_feather_esp32s2/board.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c index b0a7862ceb..93aff5067d 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/board.c @@ -33,11 +33,6 @@ void board_init(void) { // USB common_hal_never_reset_pin(&pin_GPIO19); common_hal_never_reset_pin(&pin_GPIO20); - - // Turn on I2C - common_hal_never_reset_pin(&pin_GPIO7); - gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); - gpio_set_level(7, false); } bool board_requests_safe_mode(void) { @@ -45,7 +40,9 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - + // Turn on I2C power by default. + gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(7, false); } void board_deinit(void) { From 1986d2ee71737c36794577cb4dc3cdf7fb1422a7 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 27 Dec 2021 16:42:41 -0600 Subject: [PATCH 7/7] clear out interrupt flags when disabling timer too --- ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c index 8ab4edb598..d580b4cc6a 100644 --- a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c +++ b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c @@ -59,6 +59,8 @@ void common_hal_rgbmatrix_timer_enable(void *ptr) { void common_hal_rgbmatrix_timer_disable(void *ptr) { int8_t slice = ((intptr_t)ptr) & 0xff; pwm_set_enabled(slice, false); + irq_set_enabled(PWM_IRQ_WRAP, false); + pwm_clear_irq(slice); } void common_hal_rgbmatrix_timer_free(void *ptr) {