From 2b64b1d3359fb545d7d085abc2592686e1813c83 Mon Sep 17 00:00:00 2001 From: EmergReanimator Date: Mon, 17 May 2021 21:22:24 +0200 Subject: [PATCH 01/55] [resolves #4771] DEBUG UART supported on ATMSAME5x --- ports/atmel-samd/common-hal/busio/UART.c | 46 ++++++++++++++++++------ supervisor/shared/serial.c | 2 +- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index cd8263bc56..b58bcddd2f 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -45,6 +45,8 @@ #include "samd/sercom.h" +#include "common-hal/busio/SPI.h" // for never_reset_sercom + #define UART_DEBUG(...) (void)0 // #define UART_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) @@ -152,16 +154,22 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if (rx && receiver_buffer_size > 0) { self->buffer_length = receiver_buffer_size; - // Initially allocate the UART's buffer in the long-lived part of the - // heap. UARTs are generally long-lived objects, but the "make long- - // lived" machinery is incapable of moving internal pointers like - // self->buffer, so do it manually. (However, as long as internal - // pointers like this are NOT moved, allocating the buffer - // in the long-lived pool is not strictly necessary) - self->buffer = (uint8_t *)gc_alloc(self->buffer_length * sizeof(uint8_t), false, true); - if (self->buffer == NULL) { - common_hal_busio_uart_deinit(self); - mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), self->buffer_length * sizeof(uint8_t)); + if (NULL != receiver_buffer) { + self->buffer = receiver_buffer; + } + else { + // Initially allocate the UART's buffer in the long-lived part of the + // heap. UARTs are generally long-lived objects, but the "make long- + // lived" machinery is incapable of moving internal pointers like + // self->buffer, so do it manually. (However, as long as internal + // pointers like this are NOT moved, allocating the buffer + // in the long-lived pool is not strictly necessary) + + self->buffer = (uint8_t *)gc_alloc(self->buffer_length * sizeof(uint8_t), false, true); + if (self->buffer == NULL) { + common_hal_busio_uart_deinit(self); + mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), self->buffer_length * sizeof(uint8_t)); + } } } else { self->buffer_length = 0; @@ -246,6 +254,24 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, usart_async_enable(usart_desc_p); } +void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { +#if (1) + never_reset_sercom(self->usart_desc.device.hw); + never_reset_pin_number(self->rx_pin); + never_reset_pin_number(self->tx_pin); + return; +#else + for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) { + if (mcu_uart_banks[i] == self->handle.Instance) { + never_reset_uart[i] = true; + never_reset_pin_number(self->tx->pin->port, self->tx->pin->number); + never_reset_pin_number(self->rx->pin->port, self->rx->pin->number); + break; + } + } +#endif +} + bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { return self->rx_pin == NO_PIN && self->tx_pin == NO_PIN; } diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index f7e0aafaaf..f3a0d5a976 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -67,7 +67,7 @@ void serial_early_init(void) { const mcu_pin_obj_t *tx = MP_OBJ_TO_PTR(DEBUG_UART_TX); common_hal_busio_uart_construct(&debug_uart, tx, rx, NULL, NULL, NULL, - false, 115200, 8, UART_PARITY_NONE, 1, 1.0f, 64, + false, 115200, 8, BUSIO_UART_PARITY_NONE, 1, 1.0f, 64, buf_array, true); common_hal_busio_uart_never_reset(&debug_uart); #endif From 7805392b9e1e1b85b4ab5df579111aaa3e3aa234 Mon Sep 17 00:00:00 2001 From: EmergReanimator Date: Wed, 19 May 2021 20:19:16 +0200 Subject: [PATCH 02/55] Update UART.c Incorporating feedback: https://github.com/adafruit/circuitpython/pull/4772#discussion_r634112839 --- ports/atmel-samd/common-hal/busio/UART.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index b58bcddd2f..164d0a18f1 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -255,21 +255,18 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { -#if (1) - never_reset_sercom(self->usart_desc.device.hw); - never_reset_pin_number(self->rx_pin); - never_reset_pin_number(self->tx_pin); - return; -#else - for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) { - if (mcu_uart_banks[i] == self->handle.Instance) { - never_reset_uart[i] = true; - never_reset_pin_number(self->tx->pin->port, self->tx->pin->number); - never_reset_pin_number(self->rx->pin->port, self->rx->pin->number); - break; + for (size_t i = 0; i < MP_ARRAY_SIZE(sercom_insts); i++) { + const Sercom *sercom = sercom_insts[i]; + Sercom *hw = (Sercom *)(self->usart_desc.device.hw); + + // Reserve pins for active UART only + if (sercom == hw) { + never_reset_sercom(hw); + never_reset_pin_number(self->rx_pin); + never_reset_pin_number(self->tx_pin); } } -#endif + return; } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { From 24e641a834becd3ef99682c915a6b6936d4584f0 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 25 May 2021 16:06:00 -0500 Subject: [PATCH 03/55] Fix for Issue #4266 --- ports/raspberrypi/audio_dma.c | 1 - ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ports/raspberrypi/audio_dma.c b/ports/raspberrypi/audio_dma.c index 28a80a770c..61c022f446 100644 --- a/ports/raspberrypi/audio_dma.c +++ b/ports/raspberrypi/audio_dma.c @@ -368,7 +368,6 @@ bool audio_dma_get_playing(audio_dma_t *dma) { } if (!dma_channel_is_busy(dma->channel[0]) && !dma_channel_is_busy(dma->channel[1])) { - audio_dma_stop(dma); return false; } diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index 4fef53ff0a..ddf9cc0bd4 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -126,17 +126,14 @@ void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self } void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, mp_obj_t sample, bool loop) { - if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) { - common_hal_audiopwmio_pwmaudioout_stop(self); - } // TODO: Share pacing timers based on frequency. size_t pacing_timer = NUM_DMA_TIMERS; for (size_t i = 0; i < NUM_DMA_TIMERS; i++) { if (dma_hw->timer[i] == 0) { pacing_timer = i; + break; } - break; } if (pacing_timer == NUM_DMA_TIMERS) { mp_raise_RuntimeError(translate("No DMA pacing timer found")); From 6750d3feab5befcbc07f0f665c65b1da535c9f43 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 13 May 2021 11:12:23 -0500 Subject: [PATCH 04/55] esp32s2: Introduce, use NO_PIN GPIO_NUM_NC is -1 so it's equivalent to the existing code. --- ports/esp32s2/common-hal/microcontroller/Pin.c | 4 ++-- ports/esp32s2/peripherals/pins.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.c b/ports/esp32s2/common-hal/microcontroller/Pin.c index 402de227d2..44b2c94b05 100644 --- a/ports/esp32s2/common-hal/microcontroller/Pin.c +++ b/ports/esp32s2/common-hal/microcontroller/Pin.c @@ -51,7 +51,7 @@ STATIC void floating_gpio_reset(gpio_num_t pin_number) { } void never_reset_pin_number(gpio_num_t pin_number) { - if (pin_number == -1) { + if (pin_number == NO_PIN) { return; } never_reset_pins[pin_number / 32] |= 1 << pin_number % 32; @@ -63,7 +63,7 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t *pin) { // Mark pin as free and return it to a quiescent state. void reset_pin_number(gpio_num_t pin_number) { - if (pin_number == -1) { + if (pin_number == NO_PIN) { return; } never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32); diff --git a/ports/esp32s2/peripherals/pins.h b/ports/esp32s2/peripherals/pins.h index c92f4b4cce..0ffa482166 100644 --- a/ports/esp32s2/peripherals/pins.h +++ b/ports/esp32s2/peripherals/pins.h @@ -91,4 +91,6 @@ extern const mcu_pin_obj_t pin_GPIO44; extern const mcu_pin_obj_t pin_GPIO45; extern const mcu_pin_obj_t pin_GPIO46; +#define NO_PIN (GPIO_NUM_NC) + #endif // MICROPY_INCLUDED_ESP32S2_PERIPHERALS_PINS_H From 60c9a57815b01d94c57a511e14ef0f9c0f88eca0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 13 May 2021 11:12:49 -0500 Subject: [PATCH 05/55] esp32s2: Add pin_number, reset_pin_number needed by rgbmatrix --- ports/esp32s2/common-hal/microcontroller/Pin.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.c b/ports/esp32s2/common-hal/microcontroller/Pin.c index 44b2c94b05..d912402fb9 100644 --- a/ports/esp32s2/common-hal/microcontroller/Pin.c +++ b/ports/esp32s2/common-hal/microcontroller/Pin.c @@ -72,6 +72,10 @@ void reset_pin_number(gpio_num_t pin_number) { floating_gpio_reset(pin_number); } +void common_hal_mcu_pin_reset_number(uint8_t i) { + reset_pin_number((gpio_num_t)i); +} + void common_hal_reset_pin(const mcu_pin_obj_t *pin) { if (pin == NULL) { return; @@ -109,3 +113,7 @@ bool pin_number_is_free(gpio_num_t pin_number) { bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) { return pin_number_is_free(pin->number); } + +uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t *pin) { + return pin ? pin->number : NO_PIN; +} From 4de8fa09abfa338114d41ffc5411477aa4ae2a2f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 13 May 2021 11:13:52 -0500 Subject: [PATCH 06/55] esp32s2: peripherals: store address of timer peripheral in its struct .. this is helpful if we need to go down to the esp-idf low level I/O routines --- ports/esp32s2/peripherals/timer.c | 2 ++ ports/esp32s2/peripherals/timer.h | 1 + 2 files changed, 3 insertions(+) diff --git a/ports/esp32s2/peripherals/timer.c b/ports/esp32s2/peripherals/timer.c index 674d7fc5b2..c280cba3ef 100644 --- a/ports/esp32s2/peripherals/timer.c +++ b/ports/esp32s2/peripherals/timer.c @@ -68,6 +68,8 @@ void peripherals_timer_init(const timer_config_t *config, timer_index_t *timer) } } + timer->hw = (timer->group == 0) ? &TIMERG0 : &TIMERG1; + // initialize timer module timer_init(timer->group, timer->idx, config); timer_set_counter_value(timer->group, timer->idx, 0); diff --git a/ports/esp32s2/peripherals/timer.h b/ports/esp32s2/peripherals/timer.h index 54150069c4..ad88976ec3 100644 --- a/ports/esp32s2/peripherals/timer.h +++ b/ports/esp32s2/peripherals/timer.h @@ -30,6 +30,7 @@ #include "driver/timer.h" typedef struct { + timg_dev_t *hw; timer_idx_t idx; timer_group_t group; } timer_index_t; From 0d7f257eae42f70033ed86a2da4323c1b3e72a4e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 26 May 2021 11:01:04 -0500 Subject: [PATCH 07/55] displayio: Pause rgbmatrix during soft-reset We can't handle rgbmatrix's interrupts from here until the display is reinitialized, so set the display as paused. With this change, I can survive multiple cycles with wifi+rgbmatrix on an esp32s2. Before, it usually failed. --- shared-module/displayio/__init__.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 7d9dc26dd3..23338275e8 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -185,6 +185,8 @@ void reset_displays(void) { rgbmatrix_rgbmatrix_obj_t *pm = &displays[i].rgbmatrix; if (!any_display_uses_this_framebuffer(&pm->base)) { common_hal_rgbmatrix_rgbmatrix_deinit(pm); + } else { + common_hal_rgbmatrix_rgbmatrix_set_paused(pm, true); } #endif #if CIRCUITPY_SHARPDISPLAY From 11288c1c28f2101d979fa7b214e7cc18f3e0bb08 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 13 May 2021 11:19:55 -0500 Subject: [PATCH 08/55] esp32s2: Add rgbmatrix support --- lib/protomatter | 2 +- ports/esp32s2/Makefile | 2 + .../esp32s2/common-hal/rgbmatrix/RGBMatrix.c | 75 +++++++++++++++++++ .../esp32s2/common-hal/rgbmatrix/RGBMatrix.h | 37 +++++++++ ports/esp32s2/common-hal/rgbmatrix/__init__.c | 0 ports/esp32s2/common-hal/rgbmatrix/__init__.h | 0 ports/esp32s2/mpconfigport.mk | 2 + ports/esp32s2/peripherals/timer.c | 22 +++++- ports/esp32s2/peripherals/timer.h | 3 +- shared-module/rgbmatrix/RGBMatrix.c | 8 +- 10 files changed, 143 insertions(+), 8 deletions(-) create mode 100644 ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.c create mode 100644 ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.h create mode 100644 ports/esp32s2/common-hal/rgbmatrix/__init__.c create mode 100644 ports/esp32s2/common-hal/rgbmatrix/__init__.h diff --git a/lib/protomatter b/lib/protomatter index 98017c5734..7fe6406aff 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit 98017c57349e259fab70c6a7830436b19a55f6f4 +Subproject commit 7fe6406affb1376193102cf76ded06e61316d7e6 diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile index 85d8e04332..201989e0c9 100644 --- a/ports/esp32s2/Makefile +++ b/ports/esp32s2/Makefile @@ -222,6 +222,8 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o)) $(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os $(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os +$(BUILD)/lib/protomatter/src/core.o: CFLAGS += -DESP32 + # List of sources for qstr extraction SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) # Sources that only hold QSTRs after pre-processing. diff --git a/ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.c b/ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.c new file mode 100644 index 0000000000..d42829985f --- /dev/null +++ b/ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.c @@ -0,0 +1,75 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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 + +#include "common-hal/rgbmatrix/RGBMatrix.h" + +#include "peripherals/timer.h" + +void *common_hal_rgbmatrix_timer_allocate(rgbmatrix_rgbmatrix_obj_t *self) { + const timer_config_t config = { + .alarm_en = false, + .counter_en = false, + .intr_type = TIMER_INTR_LEVEL, + .counter_dir = TIMER_COUNT_UP, + .auto_reload = true, + .divider = 2 // 40MHz + }; + + timer_index_t *timer = malloc(sizeof(timer_index_t)); + bool res = peripherals_timer_init(&config, timer); + if (!res) { + return NULL; + } + peripherals_timer_never_reset(timer); + return timer; +} + +extern bool _PM_esp32timerCallback(void *arg); + +void common_hal_rgbmatrix_timer_enable(void *ptr) { +} + +void common_hal_rgbmatrix_timer_disable(void *ptr) { + timer_index_t *timer = (timer_index_t *)ptr; + if (timer->idx == TIMER_MAX) { + return; + } + timer_pause(timer->group, timer->idx); + timer_disable_intr(timer->group, timer->idx); + timer_isr_callback_remove(timer->group, timer->idx); +} + +void common_hal_rgbmatrix_timer_free(void *ptr) { + timer_index_t *timer = (timer_index_t *)ptr; + if (timer->idx == TIMER_MAX) { + return; + } + common_hal_rgbmatrix_timer_disable(ptr); + peripherals_timer_deinit(timer); + timer->idx = TIMER_MAX; +} diff --git a/ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.h b/ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.h new file mode 100644 index 0000000000..d14cd9b083 --- /dev/null +++ b/ports/esp32s2/common-hal/rgbmatrix/RGBMatrix.h @@ -0,0 +1,37 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H + +#include "shared-module/rgbmatrix/RGBMatrix.h" + +void *common_hal_rgbmatrix_timer_allocate(rgbmatrix_rgbmatrix_obj_t *self); +void common_hal_rgbmatrix_timer_enable(void *); +void common_hal_rgbmatrix_timer_disable(void *); +void common_hal_rgbmatrix_timer_free(void *); + +#endif diff --git a/ports/esp32s2/common-hal/rgbmatrix/__init__.c b/ports/esp32s2/common-hal/rgbmatrix/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/esp32s2/common-hal/rgbmatrix/__init__.h b/ports/esp32s2/common-hal/rgbmatrix/__init__.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index a8dded05de..1f5021bc15 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -21,8 +21,10 @@ CIRCUITPY_AUDIOIO = 0 CIRCUITPY_CANIO = 1 CIRCUITPY_COUNTIO = 1 CIRCUITPY_DUALBANK = 1 +CIRCUITPY_FRAMEBUFFERIO = 1 CIRCUITPY_FREQUENCYIO = 1 CIRCUITPY_I2CPERIPHERAL = 0 +CIRCUITPY_RGBMATRIX = 1 CIRCUITPY_ROTARYIO = 1 CIRCUITPY_NVM = 1 CIRCUITPY_PS2IO ?= 1 diff --git a/ports/esp32s2/peripherals/timer.c b/ports/esp32s2/peripherals/timer.c index c280cba3ef..8e516756b6 100644 --- a/ports/esp32s2/peripherals/timer.c +++ b/ports/esp32s2/peripherals/timer.c @@ -26,6 +26,7 @@ #include "peripherals/timer.h" +#define TIMER_NEVER_RESET 2 #define TIMER_FREE 1 #define TIMER_BUSY 0 @@ -45,7 +46,7 @@ void peripherals_timer_reset(void) { } } -void peripherals_timer_init(const timer_config_t *config, timer_index_t *timer) { +bool peripherals_timer_init(const timer_config_t *config, timer_index_t *timer) { bool break_loop = false; // get free timer @@ -60,7 +61,7 @@ void peripherals_timer_init(const timer_config_t *config, timer_index_t *timer) } else if (i == 1 && j == 1) { timer->idx = TIMER_MAX; timer->group = TIMER_GROUP_MAX; - return; + return false; } } if (break_loop) { @@ -73,8 +74,25 @@ void peripherals_timer_init(const timer_config_t *config, timer_index_t *timer) // initialize timer module timer_init(timer->group, timer->idx, config); timer_set_counter_value(timer->group, timer->idx, 0); + + return true; } void peripherals_timer_deinit(timer_index_t *timer) { + if (timer->group == TIMER_GROUP_MAX || timer->idx == TIMER_MAX) { + return; + } timer_deinit(timer->group, timer->idx); + int i = timer->group; + int j = timer->idx; + timer->group = TIMER_GROUP_MAX; + timer->idx = TIMER_MAX; + timer_state[i][j] = TIMER_FREE; +} + +void peripherals_timer_never_reset(timer_index_t *timer) { + timer_deinit(timer->group, timer->idx); + int i = timer->group; + int j = timer->idx; + timer_state[i][j] = TIMER_NEVER_RESET; } diff --git a/ports/esp32s2/peripherals/timer.h b/ports/esp32s2/peripherals/timer.h index ad88976ec3..6869bd4352 100644 --- a/ports/esp32s2/peripherals/timer.h +++ b/ports/esp32s2/peripherals/timer.h @@ -35,8 +35,9 @@ typedef struct { timer_group_t group; } timer_index_t; -extern void peripherals_timer_init(const timer_config_t *config, timer_index_t *timer); +extern bool peripherals_timer_init(const timer_config_t *config, timer_index_t *timer); extern void peripherals_timer_deinit(timer_index_t *timer); extern void peripherals_timer_reset(void); +extern void peripherals_timer_never_reset(timer_index_t *timer); #endif // MICROPY_INCLUDED_ESP32S2_PERIPHERALS_TIMER_HANDLER_H diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index a0dc783b55..8346bbbeff 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -104,17 +104,17 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self, if (stat == PROTOMATTER_OK) { _PM_protoPtr = &self->protomatter; - common_hal_mcu_disable_interrupts(); + // common_hal_mcu_disable_interrupts(); common_hal_rgbmatrix_timer_enable(self->timer); stat = _PM_begin(&self->protomatter); if (stat == PROTOMATTER_OK) { _PM_convert_565(&self->protomatter, self->bufinfo.buf, self->width); - } - common_hal_mcu_enable_interrupts(); - if (stat == PROTOMATTER_OK) { _PM_swapbuffer_maybe(&self->protomatter); } + // common_hal_mcu_enable_interrupts(); + // if (stat == PROTOMATTER_OK) { + // } } if (stat != PROTOMATTER_OK) { From da7c74f6148080fbafa90ee3d289700dfac218c5 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Thu, 27 May 2021 18:02:52 +0800 Subject: [PATCH 09/55] Initial commit. --- .../boards/cytron-maker-pi-rp2040/board.c | 37 +++++++++++++ .../cytron-maker-pi-rp2040/mpconfigboard.h | 2 + .../cytron-maker-pi-rp2040/mpconfigboard.mk | 11 ++++ .../boards/cytron-maker-pi-rp2040/pins.c | 52 +++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 ports/raspberrypi/boards/cytron-maker-pi-rp2040/board.c create mode 100644 ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/cytron-maker-pi-rp2040/pins.c diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/board.c b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/board.c new file mode 100644 index 0000000000..67486d4c23 --- /dev/null +++ b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/board.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft 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 "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.h b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.h new file mode 100644 index 0000000000..efb2fc3402 --- /dev/null +++ b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.h @@ -0,0 +1,2 @@ +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico" +#define MICROPY_HW_MCU_NAME "rp2040" diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.mk new file mode 100644 index 0000000000..608ca280df --- /dev/null +++ b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x239A +USB_PID = 0x80F4 +USB_PRODUCT = "Pico" +USB_MANUFACTURER = "Raspberry Pi" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/pins.c b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/pins.c new file mode 100644 index 0000000000..057eaec2af --- /dev/null +++ b/ports/raspberrypi/boards/cytron-maker-pi-rp2040/pins.c @@ -0,0 +1,52 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, + + { MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 9ff6ccba48f8ecb93f1d55c0c3565f7392525c6e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 27 May 2021 11:33:17 -0500 Subject: [PATCH 10/55] remove commented-out code --- shared-module/rgbmatrix/RGBMatrix.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 8346bbbeff..0bfed0aa6c 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -104,7 +104,6 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self, if (stat == PROTOMATTER_OK) { _PM_protoPtr = &self->protomatter; - // common_hal_mcu_disable_interrupts(); common_hal_rgbmatrix_timer_enable(self->timer); stat = _PM_begin(&self->protomatter); @@ -112,9 +111,6 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self, _PM_convert_565(&self->protomatter, self->bufinfo.buf, self->width); _PM_swapbuffer_maybe(&self->protomatter); } - // common_hal_mcu_enable_interrupts(); - // if (stat == PROTOMATTER_OK) { - // } } if (stat != PROTOMATTER_OK) { From e7f82f864ac223a84b4533cf7a4868710119d953 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 27 May 2021 21:29:38 -0400 Subject: [PATCH 11/55] fix check of usb_hid.Device out_report_length --- locale/circuitpython.pot | 6 +++++- shared-bindings/usb_hid/Device.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index eb75d2da6f..fbb6402051 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -87,6 +87,10 @@ msgstr "" msgid "%q list must be a list" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -104,7 +108,7 @@ msgid "%q must be >= 1" msgstr "" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index 38556e5c13..64803f8e13 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -69,16 +69,16 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args { MP_QSTR_usage_page, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_usage, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_in_report_length, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, - { MP_QSTR_out_report_length, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_int = 0 } }, + { MP_QSTR_out_report_length, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0 } }, { MP_QSTR_report_id_index, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none } }, }; 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_report_descriptor].u_obj, &bufinfo, MP_BUFFER_READ); - mp_obj_t descriptor = mp_obj_new_bytearray(bufinfo.len, bufinfo.buf); + mp_buffer_info_t descriptor_bufinfo; + mp_get_buffer_raise(args[ARG_report_descriptor].u_obj, &descriptor_bufinfo, MP_BUFFER_READ); + mp_obj_t descriptor = mp_obj_new_bytearray(descriptor_bufinfo.len, descriptor_bufinfo.buf); const mp_int_t usage_page_arg = args[ARG_usage_page].u_int; if (usage_page_arg <= 0 || usage_page_arg > 255) { @@ -99,8 +99,8 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args const uint8_t in_report_length = in_report_length_arg; const mp_int_t out_report_length_arg = args[ARG_out_report_length].u_int; - if (out_report_length_arg <= 0 || out_report_length_arg > 255) { - mp_raise_ValueError_varg(translate("%q must be 1-255"), MP_QSTR_out_report_length); + if (out_report_length_arg < 0 || out_report_length_arg > 255) { + mp_raise_ValueError_varg(translate("%q must be 0-255"), MP_QSTR_out_report_length); } const uint8_t out_report_length = out_report_length_arg; @@ -108,8 +108,9 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args uint8_t report_id_index = 0; if (report_id_index_arg != mp_const_none) { const mp_int_t report_id_index_int = mp_obj_int_get_checked(report_id_index_arg); - if (report_id_index_int <= 0 || report_id_index_int > 255) { - mp_raise_ValueError_varg(translate("%q must be None or 1-255"), MP_QSTR_report_id_index); + if (report_id_index_int <= 0 || (uint32_t)report_id_index_int >= descriptor_bufinfo.len) { + mp_raise_ValueError_varg(translate("%q must be None or between 1 and len(report_descriptor)-1"), + MP_QSTR_report_id_index); } report_id_index = report_id_index_int; } From 688d6a9ee1ce6dc8e24fda15408ef078da61399e Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Fri, 28 May 2021 04:44:49 +0200 Subject: [PATCH 12/55] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 6 +++++- locale/cs.po | 6 +++++- locale/de_DE.po | 6 +++++- locale/el.po | 6 +++++- locale/en_GB.po | 6 +++++- locale/es.po | 11 +++++++++-- locale/fil.po | 6 +++++- locale/fr.po | 11 +++++++++-- locale/hi.po | 6 +++++- locale/it_IT.po | 6 +++++- locale/ja.po | 6 +++++- locale/ko.po | 6 +++++- locale/nl.po | 6 +++++- locale/pl.po | 6 +++++- locale/pt_BR.po | 11 +++++++++-- locale/sv.po | 11 +++++++++-- locale/zh_Latn_pinyin.po | 11 +++++++++-- 17 files changed, 105 insertions(+), 22 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index f0e702b7f0..f8ea996124 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -94,6 +94,10 @@ msgstr "indeks %q harus bilangan bulat, bukan %s" msgid "%q list must be a list" msgstr "daftar %q harus berupa daftar" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -111,7 +115,7 @@ msgid "%q must be >= 1" msgstr "%q harus >= 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/cs.po b/locale/cs.po index aebc210b81..902d0e9254 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -90,6 +90,10 @@ msgstr "Indexy %q musí být celá čísla, nikoli %s" msgid "%q list must be a list" msgstr "Seznam %q musí být seznam" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -107,7 +111,7 @@ msgid "%q must be >= 1" msgstr "%q musí být > = 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/de_DE.po b/locale/de_DE.po index 12a9112722..ea3fed6ea8 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -95,6 +95,10 @@ msgstr "%q Indizes müssen Integer sein, nicht %s" msgid "%q list must be a list" msgstr "%q Liste muss eine Liste sein" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -112,7 +116,7 @@ msgid "%q must be >= 1" msgstr "%q muss >= 1 sein" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/el.po b/locale/el.po index 3430bb0078..5203a4d6a9 100644 --- a/locale/el.po +++ b/locale/el.po @@ -87,6 +87,10 @@ msgstr "" msgid "%q list must be a list" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -104,7 +108,7 @@ msgid "%q must be >= 1" msgstr "" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/en_GB.po b/locale/en_GB.po index 0b9eb660c3..8eff40108e 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -96,6 +96,10 @@ msgstr "" msgid "%q list must be a list" msgstr "%q list must be a list" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -113,7 +117,7 @@ msgid "%q must be >= 1" msgstr "%q must be >= 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/es.po b/locale/es.po index fb4c3f5e96..51e908b1e8 100644 --- a/locale/es.po +++ b/locale/es.po @@ -98,6 +98,10 @@ msgstr "%q indices deben ser enteros, no %s" msgid "%q list must be a list" msgstr "%q lista debe ser una lista" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "%q debe estar entre 1-255" @@ -115,8 +119,8 @@ msgid "%q must be >= 1" msgstr "%q debe ser >= 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" -msgstr "%q debe ser None o 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" +msgstr "" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -4448,6 +4452,9 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "%q must be None or 1-255" +#~ msgstr "%q debe ser None o 1-255" + #~ msgid "Only raw int or string supported for ip" #~ msgstr "Para ip solo puede con un entero o una cadena" diff --git a/locale/fil.po b/locale/fil.po index ca689b783e..748886d42b 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -86,6 +86,10 @@ msgstr "%q indeks ay dapat integers, hindi %s" msgid "%q list must be a list" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -104,7 +108,7 @@ msgid "%q must be >= 1" msgstr "aarehas na haba dapat ang buffer slices" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/fr.po b/locale/fr.po index a55d920693..902821ca1d 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -98,6 +98,10 @@ msgstr "les indices %q doivent être des entiers, pas %s" msgid "%q list must be a list" msgstr "La liste %q doit être une liste" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "%q doit être compris entre 1 et 255" @@ -115,8 +119,8 @@ msgid "%q must be >= 1" msgstr "%q doit être >= 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" -msgstr "%q doit être None ou compris entre 1 et 255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" +msgstr "" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -4459,6 +4463,9 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "%q must be None or 1-255" +#~ msgstr "%q doit être None ou compris entre 1 et 255" + #~ msgid "Only raw int supported for ip" #~ msgstr "IP n'accepte que les chiffres entiers bruts" diff --git a/locale/hi.po b/locale/hi.po index ecb7d2d8cc..604cb4ca56 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -87,6 +87,10 @@ msgstr "" msgid "%q list must be a list" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -104,7 +108,7 @@ msgid "%q must be >= 1" msgstr "" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/it_IT.po b/locale/it_IT.po index 4b58d8d02e..416ad5e94a 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -96,6 +96,10 @@ msgstr "gli indici %q devono essere interi, non %s" msgid "%q list must be a list" msgstr "lista %q deve essere una lista" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -114,7 +118,7 @@ msgid "%q must be >= 1" msgstr "slice del buffer devono essere della stessa lunghezza" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/ja.po b/locale/ja.po index aa9b79ea5b..fd825e7bd1 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -92,6 +92,10 @@ msgstr "" msgid "%q list must be a list" msgstr "%q リストはリストでなければなりません" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -109,7 +113,7 @@ msgid "%q must be >= 1" msgstr "%qは1以上でなければなりません" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/ko.po b/locale/ko.po index 82d4928e9f..064e69704f 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -88,6 +88,10 @@ msgstr "%q 인덱스는 %s 가 아닌 정수 여야합니다" msgid "%q list must be a list" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -105,7 +109,7 @@ msgid "%q must be >= 1" msgstr "%q 는 >=1이어야합니다" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/nl.po b/locale/nl.po index 8ba8094d45..0a9f7f331a 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -90,6 +90,10 @@ msgstr "%q indexen moeten integers zijn, niet %s" msgid "%q list must be a list" msgstr "%q lijst moet een lijst zijn" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -107,7 +111,7 @@ msgid "%q must be >= 1" msgstr "%q moet >= 1 zijn" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/pl.po b/locale/pl.po index 5497efcba3..7e89641e28 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -92,6 +92,10 @@ msgstr "%q indeks musi być liczbą całkowitą, a nie %s" msgid "%q list must be a list" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "" @@ -109,7 +113,7 @@ msgid "%q must be >= 1" msgstr "%q musi być >= 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" msgstr "" #: shared-module/vectorio/Polygon.c diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 14baa40edf..7dd88d348c 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -96,6 +96,10 @@ msgstr "Os índices %q devem ser inteiros, e não %s" msgid "%q list must be a list" msgstr "A lista %q deve ser uma lista" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "%q deve ser 1-255" @@ -113,8 +117,8 @@ msgid "%q must be >= 1" msgstr "%q deve ser >= 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" -msgstr "%q deve ser Nenhum ou 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" +msgstr "" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -4458,6 +4462,9 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "%q must be None or 1-255" +#~ msgstr "%q deve ser Nenhum ou 1-255" + #~ msgid "Only raw int or string supported for ip" #~ msgstr "Apenas int ou string bruto é compatível para o ip" diff --git a/locale/sv.po b/locale/sv.po index f38f7240af..1429ad4948 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -95,6 +95,10 @@ msgstr "Indexet %q måste vara ett heltal, inte %s" msgid "%q list must be a list" msgstr "%q-listan måste vara en lista" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "%q måste vara 1-255" @@ -112,8 +116,8 @@ msgid "%q must be >= 1" msgstr "%q måste vara >= 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" -msgstr "%q måste vara None eller 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" +msgstr "" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -4417,6 +4421,9 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "%q must be None or 1-255" +#~ msgstr "%q måste vara None eller 1-255" + #~ msgid "Only raw int or string supported for ip" #~ msgstr "Enbart int eller string stöds för ip" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 0f54ddec98..1a82e35d25 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -97,6 +97,10 @@ msgstr "%q suǒyǐn bìxū shì zhěngshù, ér bùshì %s" msgid "%q list must be a list" msgstr "%q lièbiǎo bìxū shì lièbiǎo" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 0-255" +msgstr "" + #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" msgstr "%q bì xū wéi 1-255" @@ -114,8 +118,8 @@ msgid "%q must be >= 1" msgstr "%q bìxū dàyú huò děngyú 1" #: shared-bindings/usb_hid/Device.c -msgid "%q must be None or 1-255" -msgstr "%q bì xū wéi wú huò 1-255" +msgid "%q must be None or between 1 and len(report_descriptor)-1" +msgstr "" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -4414,6 +4418,9 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "%q must be None or 1-255" +#~ msgstr "%q bì xū wéi wú huò 1-255" + #~ msgid "Only raw int supported for ip" #~ msgstr "Ip jǐn zhīchí raw int" From 321e5dd16f4c72bc597baf40ff5f878d8f41ab6f Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Fri, 28 May 2021 18:01:02 +0800 Subject: [PATCH 13/55] Use underscore instead of dash for board name. --- .../{cytron-maker-pi-rp2040 => cytron_maker_pi_rp2040}/board.c | 0 .../mpconfigboard.h | 0 .../mpconfigboard.mk | 0 .../{cytron-maker-pi-rp2040 => cytron_maker_pi_rp2040}/pins.c | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename ports/raspberrypi/boards/{cytron-maker-pi-rp2040 => cytron_maker_pi_rp2040}/board.c (100%) rename ports/raspberrypi/boards/{cytron-maker-pi-rp2040 => cytron_maker_pi_rp2040}/mpconfigboard.h (100%) rename ports/raspberrypi/boards/{cytron-maker-pi-rp2040 => cytron_maker_pi_rp2040}/mpconfigboard.mk (100%) rename ports/raspberrypi/boards/{cytron-maker-pi-rp2040 => cytron_maker_pi_rp2040}/pins.c (100%) diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/board.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/board.c similarity index 100% rename from ports/raspberrypi/boards/cytron-maker-pi-rp2040/board.c rename to ports/raspberrypi/boards/cytron_maker_pi_rp2040/board.c diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.h b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h similarity index 100% rename from ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.h rename to ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk similarity index 100% rename from ports/raspberrypi/boards/cytron-maker-pi-rp2040/mpconfigboard.mk rename to ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk diff --git a/ports/raspberrypi/boards/cytron-maker-pi-rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c similarity index 100% rename from ports/raspberrypi/boards/cytron-maker-pi-rp2040/pins.c rename to ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c From 5920ac647a66ff93fe0ec5167f71f5706c1af8f5 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Fri, 28 May 2021 22:42:54 +0800 Subject: [PATCH 14/55] Modified the essential files for Maker Pi RP2040. --- .github/workflows/build.yml | 1 + .../cytron_maker_pi_rp2040/mpconfigboard.h | 13 +++++++- .../cytron_maker_pi_rp2040/mpconfigboard.mk | 8 ++--- .../boards/cytron_maker_pi_rp2040/pins.c | 31 ++++++++++++------- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b23f4538e..67c93fc02b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -212,6 +212,7 @@ jobs: - "cp_sapling_m0" - "cp_sapling_m0_revb" - "cp_sapling_m0_spiflash" + - "cytron_maker_pi_rp2040" - "datalore_ip_m4" - "datum_distance" - "datum_imu" diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h index efb2fc3402..341b0f619b 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h @@ -1,2 +1,13 @@ -#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico" +#define MICROPY_HW_BOARD_NAME "Cytron Maker Pi RP2040" #define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) + +#define MICROPY_HW_BAT_SENSE (&pin_GPIO29) + +#define MICROPY_HW_BUZZER (&pin_GPIO22) + +#define MICROPY_HW_MOTOR_M1A (&pin_GPIO8) +#define MICROPY_HW_MOTOR_M1B (&pin_GPIO9) +#define MICROPY_HW_MOTOR_M2A (&pin_GPIO10) +#define MICROPY_HW_MOTOR_M2B (&pin_GPIO11) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk index 608ca280df..6d6dc1af1b 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk @@ -1,7 +1,7 @@ -USB_VID = 0x239A -USB_PID = 0x80F4 -USB_PRODUCT = "Pico" -USB_MANUFACTURER = "Raspberry Pi" +USB_VID = 0x2E8A +USB_PID = 0x1000 +USB_PRODUCT = "Maker Pi RP2040" +USB_MANUFACTURER = "Cytron" CHIP_VARIANT = RP2040 CHIP_FAMILY = rp2 diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c index 057eaec2af..20cefa591b 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c @@ -9,31 +9,37 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, - { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, - { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_M1A), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_M1B), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_M2A), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_M2B), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_BUZZER), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, - { MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_GPIO23) }, - { MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) }, - - { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO24) }, - { MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) }, - - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, - { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, - { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, @@ -47,6 +53,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_VBATT), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 9df8f235b1e4585ef8f58bc927c282e8ac1a23fd Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 28 May 2021 10:53:21 -0500 Subject: [PATCH 15/55] OnDiskBitmap: INCOMPATIBLE CHANGE: Allow them to use palettes Before, when an OnDiskBitmap was a paletted bitmap type, the palette was internal to the OnDiskBitmap, and it internally performed the palette conversion itself. When using with a tilegrid, a ColorConverter() object always had to be passed. Now, an OnDiskBitmap has a "pixel_shader" property. If the bitmap is a paletted bitmap type, it is a (modifiable) Palette object. Otherwise, it is a ColorConverter() object as before. This allows palette effects to be applied to paletted OnDiskBitmaps. Code that used to say: ```python face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter()) ``` must be updated to say: ```python face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader) ``` Compatible code for 6.x and 7.x can say ```python face = displayio.TileGrid(odb, pixel_shader=getattr(odb, 'pixel_shader', ColorConverter()) ``` --- shared-bindings/displayio/OnDiskBitmap.c | 23 ++++++++- shared-bindings/displayio/OnDiskBitmap.h | 2 +- shared-module/displayio/ColorConverter.h | 2 +- shared-module/displayio/OnDiskBitmap.c | 63 ++++++++++++++++-------- shared-module/displayio/OnDiskBitmap.h | 8 ++- shared-module/displayio/Palette.h | 2 +- 6 files changed, 73 insertions(+), 27 deletions(-) diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index 580665eab9..5dcec9bb47 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -55,7 +55,7 @@ //| //| with open("/sample.bmp", "rb") as f: //| odb = displayio.OnDiskBitmap(f) -//| face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter()) +//| face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader) //| splash.append(face) //| # Wait for the image to load. //| board.DISPLAY.refresh(target_frames_per_second=60) @@ -127,8 +127,29 @@ const mp_obj_property_t displayio_ondiskbitmap_height_obj = { }; +//| pixel_shader: Union[ColorConverter, Palette] +//| """The image's pixel_shader. The type depends on the underlying +//| bitmap's structure. The pixel shadder can be modified (e.g., to set the +//| transparent pixel or, for paletted images, to update the palette""" +//| +STATIC mp_obj_t displayio_ondiskbitmap_obj_get_pixel_shader(mp_obj_t self_in) { + displayio_ondiskbitmap_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_displayio_ondiskbitmap_get_pixel_shader(self); +} + +MP_DEFINE_CONST_FUN_OBJ_1(displayio_ondiskbitmap_get_pixel_shader_obj, displayio_ondiskbitmap_obj_get_pixel_shader); + +const mp_obj_property_t displayio_ondiskbitmap_pixel_shader_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_ondiskbitmap_get_pixel_shader_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + STATIC const mp_rom_map_elem_t displayio_ondiskbitmap_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_ondiskbitmap_height_obj) }, + { MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&displayio_ondiskbitmap_pixel_shader_obj) }, { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_ondiskbitmap_width_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_ondiskbitmap_locals_dict, displayio_ondiskbitmap_locals_dict_table); diff --git a/shared-bindings/displayio/OnDiskBitmap.h b/shared-bindings/displayio/OnDiskBitmap.h index aff3a19db2..6d534ec50e 100644 --- a/shared-bindings/displayio/OnDiskBitmap.h +++ b/shared-bindings/displayio/OnDiskBitmap.h @@ -38,6 +38,6 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *b int16_t x, int16_t y); uint16_t common_hal_displayio_ondiskbitmap_get_height(displayio_ondiskbitmap_t *self); - +mp_obj_t common_hal_displayio_ondiskbitmap_get_pixel_shader(displayio_ondiskbitmap_t *self); uint16_t common_hal_displayio_ondiskbitmap_get_width(displayio_ondiskbitmap_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_ONDISKBITMAP_H diff --git a/shared-module/displayio/ColorConverter.h b/shared-module/displayio/ColorConverter.h index 55f86982dc..d8805ed720 100644 --- a/shared-module/displayio/ColorConverter.h +++ b/shared-module/displayio/ColorConverter.h @@ -33,7 +33,7 @@ #include "py/obj.h" #include "shared-module/displayio/Palette.h" -typedef struct { +typedef struct displayio_colorconverter { mp_obj_base_t base; bool dither; uint8_t input_colorspace; diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c index 5c7e00a583..1bc5f93eb6 100644 --- a/shared-module/displayio/OnDiskBitmap.c +++ b/shared-module/displayio/OnDiskBitmap.c @@ -25,6 +25,10 @@ */ #include "shared-bindings/displayio/OnDiskBitmap.h" +#include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/displayio/Palette.h" +#include "shared-module/displayio/ColorConverter.h" +#include "shared-module/displayio/Palette.h" #include @@ -63,6 +67,11 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, self->width = read_word(bmp_header, 9); self->height = read_word(bmp_header, 11); + displayio_colorconverter_t *colorconverter = m_new_obj(displayio_colorconverter_t); + colorconverter->base.type = &displayio_colorconverter_type; + common_hal_displayio_colorconverter_construct(colorconverter, false, DISPLAYIO_COLORSPACE_RGB888); + self->colorconverter = colorconverter; + if (bits_per_pixel == 16) { if (((header_size >= 56)) || (self->bitfield_compressed)) { self->r_bitmask = read_word(bmp_header, 27); @@ -74,25 +83,41 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, self->g_bitmask = 0x3e0; self->b_bitmask = 0x1f; } - } else if (indexed && self->bits_per_pixel != 1) { + } else if (indexed) { if (number_of_colors == 0) { number_of_colors = 1 << bits_per_pixel; } - uint16_t palette_size = number_of_colors * sizeof(uint32_t); - uint16_t palette_offset = 0xe + header_size; - self->palette_data = m_malloc(palette_size, false); + displayio_palette_t *palette = m_new_obj(displayio_palette_t); + palette->base.type = &displayio_palette_type; + common_hal_displayio_palette_construct(palette, number_of_colors); - f_rewind(&self->file->fp); - f_lseek(&self->file->fp, palette_offset); + if (number_of_colors > 1) { + uint16_t palette_size = number_of_colors * sizeof(uint32_t); + uint16_t palette_offset = 0xe + header_size; - UINT palette_bytes_read; - if (f_read(&self->file->fp, self->palette_data, palette_size, &palette_bytes_read) != FR_OK) { - mp_raise_OSError(MP_EIO); - } - if (palette_bytes_read != palette_size) { - mp_raise_ValueError(translate("Unable to read color palette data")); + uint32_t *palette_data = m_malloc(palette_size, false); + + f_rewind(&self->file->fp); + f_lseek(&self->file->fp, palette_offset); + + UINT palette_bytes_read; + if (f_read(&self->file->fp, palette_data, palette_size, &palette_bytes_read) != FR_OK) { + mp_raise_OSError(MP_EIO); + } + if (palette_bytes_read != palette_size) { + mp_raise_ValueError(translate("Unable to read color palette data")); + } + for (uint16_t i = 0; i < palette_size; i++) { + common_hal_displayio_palette_set_color(palette, i, palette_data[i]); + } + m_free(palette_data); + } else { + common_hal_displayio_palette_set_color(palette, 0, 0x0); + common_hal_displayio_palette_set_color(palette, 1, 0xffffff); } + self->palette = palette; + } else if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124)) { mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported: given header size is %d"), header_size); } @@ -148,15 +173,7 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s uint8_t offset = (x % pixels_per_byte) * self->bits_per_pixel; uint8_t mask = (1 << self->bits_per_pixel) - 1; - uint8_t index = (pixel_data >> ((8 - self->bits_per_pixel) - offset)) & mask; - if (self->bits_per_pixel == 1) { - if (index == 1) { - return 0xFFFFFF; - } else { - return 0x000000; - } - } - return self->palette_data[index]; + return (pixel_data >> ((8 - self->bits_per_pixel) - offset)) & mask; } else if (bytes_per_pixel == 2) { if (self->g_bitmask == 0x07e0) { // 565 red = ((pixel_data & self->r_bitmask) >> 11); @@ -185,3 +202,7 @@ uint16_t common_hal_displayio_ondiskbitmap_get_height(displayio_ondiskbitmap_t * uint16_t common_hal_displayio_ondiskbitmap_get_width(displayio_ondiskbitmap_t *self) { return self->width; } + +mp_obj_t common_hal_displayio_ondiskbitmap_get_pixel_shader(displayio_ondiskbitmap_t *self) { + return MP_OBJ_FROM_PTR(self->pixel_shader_base); +} diff --git a/shared-module/displayio/OnDiskBitmap.h b/shared-module/displayio/OnDiskBitmap.h index 610b114910..806b13f7f9 100644 --- a/shared-module/displayio/OnDiskBitmap.h +++ b/shared-module/displayio/OnDiskBitmap.h @@ -43,10 +43,14 @@ typedef struct { uint32_t r_bitmask; uint32_t g_bitmask; uint32_t b_bitmask; - bool bitfield_compressed; pyb_file_obj_t *file; + union { + mp_obj_base_t *pixel_shader_base; + struct displayio_palette *palette; + struct displayio_colorconverter *colorconverter; + }; + bool bitfield_compressed; uint8_t bits_per_pixel; - uint32_t *palette_data; } displayio_ondiskbitmap_t; #endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_ONDISKBITMAP_H diff --git a/shared-module/displayio/Palette.h b/shared-module/displayio/Palette.h index 82504b7ed1..49f03b56c7 100644 --- a/shared-module/displayio/Palette.h +++ b/shared-module/displayio/Palette.h @@ -69,7 +69,7 @@ typedef struct { bool opaque; } displayio_output_pixel_t; -typedef struct { +typedef struct displayio_palette { mp_obj_base_t base; _displayio_color_t *colors; uint32_t color_count; From 193f8b7264524ea85da46d6e63acd9ff8c8d2c8e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 28 May 2021 11:13:55 -0500 Subject: [PATCH 16/55] Fixes needed after micropython merges .. this branch was old and stale, it turns out --- shared-bindings/displayio/OnDiskBitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index 5dcec9bb47..b6341b1929 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -142,8 +142,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_ondiskbitmap_get_pixel_shader_obj, displayio const mp_obj_property_t displayio_ondiskbitmap_pixel_shader_obj = { .base.type = &mp_type_property, .proxy = {(mp_obj_t)&displayio_ondiskbitmap_get_pixel_shader_obj, - (mp_obj_t)&mp_const_none_obj, - (mp_obj_t)&mp_const_none_obj}, + (mp_obj_t)MP_ROM_NONE, + (mp_obj_t)MP_ROM_NONE}, }; From bfcb8c5896583c8a0c9e9e10ef1ee1a539580d4c Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Sat, 29 May 2021 00:47:14 +0800 Subject: [PATCH 17/55] Do not use neopixel as status LED. Also removed the unused definition. --- .../boards/cytron_maker_pi_rp2040/mpconfigboard.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h index 341b0f619b..9c035c7d13 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.h @@ -1,13 +1,2 @@ #define MICROPY_HW_BOARD_NAME "Cytron Maker Pi RP2040" #define MICROPY_HW_MCU_NAME "rp2040" - -#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define MICROPY_HW_BAT_SENSE (&pin_GPIO29) - -#define MICROPY_HW_BUZZER (&pin_GPIO22) - -#define MICROPY_HW_MOTOR_M1A (&pin_GPIO8) -#define MICROPY_HW_MOTOR_M1B (&pin_GPIO9) -#define MICROPY_HW_MOTOR_M2A (&pin_GPIO10) -#define MICROPY_HW_MOTOR_M2B (&pin_GPIO11) From ebda9e07f484b969b12cd66ad0a1aeaa3298c63b Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Sat, 29 May 2021 01:04:13 +0800 Subject: [PATCH 18/55] Use 4 spaces instead of tab. --- .../boards/cytron_maker_pi_rp2040/pins.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c index 20cefa591b..5229642670 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c @@ -9,35 +9,35 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, - + { MP_ROM_QSTR(MP_QSTR_M1A), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, - + { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_M1B), MP_ROM_PTR(&pin_GPIO9) }, - { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, - + { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_M2A), MP_ROM_PTR(&pin_GPIO10) }, - { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, - - { MP_ROM_QSTR(MP_QSTR_M2B), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_M2B), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) }, - + { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, - - { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_PTR(&pin_GPIO18) }, - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, - + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, - - { MP_ROM_QSTR(MP_QSTR_BUZZER), MP_ROM_PTR(&pin_GPIO22) }, + + { MP_ROM_QSTR(MP_QSTR_BUZZER), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, @@ -53,7 +53,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, - { MP_ROM_QSTR(MP_QSTR_VBATT), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_VBATT), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 49db85cb3d97f976a39eedc85a680b2d6858cce0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 27 May 2021 15:25:29 -0500 Subject: [PATCH 19/55] Check that select firmwares build on Windows with MSYS2 This configuration is used by @ladyada and more often than it should we've discovered late that a change introduced problems building there. By adding this to regular CI, hopefully we learn about and fix these issues sooner rather than later. --- .github/workflows/ports_windows.yml | 106 ++++++++++++++++++++++++++++ ports/atmel-samd/Makefile | 3 +- ports/nrf/Makefile | 3 +- ports/stm/Makefile | 3 +- 4 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ports_windows.yml diff --git a/.github/workflows/ports_windows.yml b/.github/workflows/ports_windows.yml new file mode 100644 index 0000000000..2347902f7b --- /dev/null +++ b/.github/workflows/ports_windows.yml @@ -0,0 +1,106 @@ +name: windows port + +on: + push: + pull_request: + paths: + - '.github/workflows/*.yml' + - 'tools/**' + - 'py/**' + - 'extmod/**' + - 'lib/**' + - 'ports/unix/**' + - 'ports/windows/**' + +jobs: + build: + runs-on: windows-2019 + defaults: + run: + # We define a custom shell script here, although `msys2.cmd` does neither exist nor is it available in the PATH yet + shell: msys2 {0} + steps: + + # We want to change the configuration of the git command that actions/checkout will be using (since it is not possible to set autocrlf through the action yet, see actions/checkout#226). + - run: git config --global core.autocrlf input + shell: bash + + - name: Check python coding (cmd) + run: | + python -c "import sys, locale; print(sys.getdefaultencoding(), locale.getpreferredencoding(False))" + shell: cmd + + # We use a JS Action, which calls the system terminal or other custom terminals directly, if required + - uses: msys2/setup-msys2@v2 + with: + update: true + install: base-devel git wget unzip gcc python-pip + + # The goal of this was to test how things worked when the default file + # encoding (locale.getpreferedencoding()) was not UTF-8. However, msys2 + # python does use utf-8 as the preferred file encoding, and using + # actions/setup-python python3.8 gave a broken build, so we're not really + # testing what we wanted to test. + # + # however, commandline length limits are being tested so that does some + # good. + - name: Check python coding (msys2) + run: | + locale -v + which python; python --version + python -c "import sys, locale; print(sys.getdefaultencoding(), locale.getpreferredencoding(False))" + which python3; python3 --version + python3 -c "import sys, locale; print(sys.getdefaultencoding(), locale.getpreferredencoding(False))" + + - name: Install dependencies + run: | + wget --no-verbose -O gcc-arm.zip https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-win32.zip + unzip -q -d /tmp gcc-arm.zip + tar -C /tmp/gcc-arm-none-* -cf - . | tar -C /usr/local -xf - + pip install wheel + # requirements_dev.txt doesn't install on windows. (with msys2 python) + # instead, pick a subset for what we want to do + pip install cascadetoml jinja2 typer + # check that installed packages work....? + which python; python --version; python -c "import cascadetoml" + which python3; python3 --version; python3 -c "import cascadetoml" + + - uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 + + - run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/* + - name: CircuitPython version + run: | + git describe --dirty --tags + echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + + - name: build mpy-cross + run: make -j2 -C mpy-cross + + - name: build rp2040 + run: make -j2 -C ports/raspberrypi BOARD=adafruit_feather_rp2040 TRANSLATION=de_DE + + - name: build samd21 + run: make -j2 -C ports/atmel-samd BOARD=feather_m0_express TRANSLATION=zh_Latn_pinyin + + - name: build samd51 + run: make -j2 -C ports/atmel-samd BOARD=feather_m4_express TRANSLATION=es + + - name: build nrf + run: make -j2 -C ports/nrf BOARD=feather_nrf52840_express TRANSLATION=fr + + - name: build stm + run: make -j2 -C ports/stm BOARD=feather_stm32f405_express TRANSLATION=pt_BR + +# I gave up trying to do esp32 builds on windows when I saw +# ERROR: Platform MINGW64_NT-10.0-17763-x86_64 appears to be unsupported +# https://github.com/espressif/esp-idf/issues/7062 +# +# - name: prepare esp +# run: ports/esp32s2/esp-idf/install.bat +# shell: cmd +# +# - name: build esp +# run: . ports/esp32s2/esp-idf/export.sh && make -j2 -C ports/esp32s2 BOARD=adafruit_metro_esp32s2 diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 574d115260..8df7de590d 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -398,7 +398,8 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE) $(STEPECHO) "LINK $@" - $(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)echo $(OBJ) > $(BUILD)/firmware.objs + $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 091bd7599b..290d99386a 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -252,7 +252,8 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE) $(STEPECHO) "LINK $@" - $(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)echo $(OBJ) > $(BUILD)/firmware.objs + $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf diff --git a/ports/stm/Makefile b/ports/stm/Makefile index 41f2e50e3d..1de7ed5c82 100755 --- a/ports/stm/Makefile +++ b/ports/stm/Makefile @@ -280,7 +280,8 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.elf: $(OBJ) $(STEPECHO) "LINK $@" - $(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)echo $^ > $(BUILD)/firmware.objs + $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf From ebe4d90ac3fa6873e7f35fd1c23fe73e43b62ec2 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Sat, 29 May 2021 10:12:22 +0800 Subject: [PATCH 20/55] Updated the copyright information. --- ports/raspberrypi/boards/cytron_maker_pi_rp2040/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/board.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/board.c index 67486d4c23..e68ca62414 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/board.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/board.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Wai Weng for Cytron Technologies * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6b476c19ba3718753fea2957e0b4101e1df08451 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 29 May 2021 08:10:10 -0500 Subject: [PATCH 21/55] fix formatting --- ports/atmel-samd/common-hal/busio/UART.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 164d0a18f1..5aa13d076d 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -156,8 +156,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->buffer_length = receiver_buffer_size; if (NULL != receiver_buffer) { self->buffer = receiver_buffer; - } - else { + } else { // Initially allocate the UART's buffer in the long-lived part of the // heap. UARTs are generally long-lived objects, but the "make long- // lived" machinery is incapable of moving internal pointers like From 760e8c77bd3e9cc12ffc2852c8a02eb01352a9ec Mon Sep 17 00:00:00 2001 From: root Date: Sat, 29 May 2021 11:55:10 -0500 Subject: [PATCH 22/55] Changes to correct repeat playing on a channel --- ports/raspberrypi/audio_dma.c | 2 ++ ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ports/raspberrypi/audio_dma.c b/ports/raspberrypi/audio_dma.c index 61c022f446..7044c44edf 100644 --- a/ports/raspberrypi/audio_dma.c +++ b/ports/raspberrypi/audio_dma.c @@ -352,6 +352,8 @@ bool audio_dma_get_paused(audio_dma_t *dma) { void audio_dma_init(audio_dma_t *dma) { dma->first_buffer = NULL; dma->second_buffer = NULL; + dma->channel[0] = NUM_DMA_CHANNELS; + dma->channel[1] = NUM_DMA_CHANNELS; } void audio_dma_deinit(audio_dma_t *dma) { diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index ddf9cc0bd4..9f2c877416 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -127,6 +127,12 @@ void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, mp_obj_t sample, bool loop) { + if (self->dma.channel[0] < NUM_DMA_CHANNELS) { + if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) { + common_hal_audiopwmio_pwmaudioout_stop(self); + } + } + // TODO: Share pacing timers based on frequency. size_t pacing_timer = NUM_DMA_TIMERS; for (size_t i = 0; i < NUM_DMA_TIMERS; i++) { From a2b220370eb6261f207532319cca768266f3730a Mon Sep 17 00:00:00 2001 From: root Date: Sat, 29 May 2021 12:26:41 -0500 Subject: [PATCH 23/55] Fix formatting issue --- ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index 9f2c877416..f5bfd2d0df 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -130,7 +130,7 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, if (self->dma.channel[0] < NUM_DMA_CHANNELS) { if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) { common_hal_audiopwmio_pwmaudioout_stop(self); - } + } } // TODO: Share pacing timers based on frequency. From b06ec0a776a7633f9b22a61c7fa76103cdf52aa5 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Sun, 30 May 2021 09:57:00 +0800 Subject: [PATCH 24/55] Added libraries dependency. --- .gitmodules | 3 +++ frozen/Adafruit_CircuitPython_SimpleIO | 1 + .../boards/cytron_maker_pi_rp2040/mpconfigboard.mk | 5 +++++ 3 files changed, 9 insertions(+) create mode 160000 frozen/Adafruit_CircuitPython_SimpleIO diff --git a/.gitmodules b/.gitmodules index 24ba2e2f6f..55fce0eebb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -184,3 +184,6 @@ [submodule "frozen/Adafruit_CircuitPython_MIDI"] path = frozen/Adafruit_CircuitPython_MIDI url = https://github.com/adafruit/Adafruit_CircuitPython_MIDI +[submodule "frozen/Adafruit_CircuitPython_SimpleIO"] + path = frozen/Adafruit_CircuitPython_SimpleIO + url = https://github.com/adafruit/adafruit_circuitpython_simpleio diff --git a/frozen/Adafruit_CircuitPython_SimpleIO b/frozen/Adafruit_CircuitPython_SimpleIO new file mode 160000 index 0000000000..dd00c66121 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_SimpleIO @@ -0,0 +1 @@ +Subproject commit dd00c661217143b610903adf52c285cc5c5396a6 diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk index 6d6dc1af1b..049c230f94 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/mpconfigboard.mk @@ -9,3 +9,8 @@ CHIP_FAMILY = rp2 EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" CIRCUITPY__EVE = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Motor +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SimpleIO From b25ad6dcdb55c0842de218f8811a8ad2bb40d260 Mon Sep 17 00:00:00 2001 From: Alvaro Figueroa Date: Sat, 29 May 2021 07:26:08 +0000 Subject: [PATCH 25/55] Translated using Weblate (Spanish) Currently translated at 100.0% (994 of 994 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/es.po b/locale/es.po index 51e908b1e8..973a94b284 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-05-24 21:25+0000\n" -"Last-Translator: Jose David M \n" +"PO-Revision-Date: 2021-05-30 13:32+0000\n" +"Last-Translator: Alvaro Figueroa \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" @@ -100,7 +100,7 @@ msgstr "%q lista debe ser una lista" #: shared-bindings/usb_hid/Device.c msgid "%q must be 0-255" -msgstr "" +msgstr "%q debe ser de 0-255" #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" @@ -120,7 +120,7 @@ msgstr "%q debe ser >= 1" #: shared-bindings/usb_hid/Device.c msgid "%q must be None or between 1 and len(report_descriptor)-1" -msgstr "" +msgstr "%q debe ser None o entre 1 y len(report_descriptor)-1" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" From e18d67cdc5198773e9a22b580e85e22ec8600734 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Fri, 28 May 2021 20:28:53 +0000 Subject: [PATCH 26/55] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (994 of 994 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 7dd88d348c..6c6c8064c6 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-05-25 17:41+0000\n" +"PO-Revision-Date: 2021-05-30 13:32+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -98,7 +98,7 @@ msgstr "A lista %q deve ser uma lista" #: shared-bindings/usb_hid/Device.c msgid "%q must be 0-255" -msgstr "" +msgstr "%q deve ser entre 0-255" #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" @@ -118,7 +118,7 @@ msgstr "%q deve ser >= 1" #: shared-bindings/usb_hid/Device.c msgid "%q must be None or between 1 and len(report_descriptor)-1" -msgstr "" +msgstr "%q deve ser None ou entre 1 e len(report_descriptor)-1" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" From 017c6d5aa8440c4f90d984496f6c7c845497d64d Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Sat, 29 May 2021 13:01:15 +0000 Subject: [PATCH 27/55] Translated using Weblate (Swedish) Currently translated at 100.0% (994 of 994 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 1429ad4948..21fb6da6c4 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-05-24 21:25+0000\n" +"PO-Revision-Date: 2021-05-30 13:32+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -97,7 +97,7 @@ msgstr "%q-listan måste vara en lista" #: shared-bindings/usb_hid/Device.c msgid "%q must be 0-255" -msgstr "" +msgstr "%q måste vara 0-255" #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" @@ -117,7 +117,7 @@ msgstr "%q måste vara >= 1" #: shared-bindings/usb_hid/Device.c msgid "%q must be None or between 1 and len(report_descriptor)-1" -msgstr "" +msgstr "%q måste vara None eller mellan 1 och len(report_descriptor)-1" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" From 625fa881c63d1e0e93040ed31f6b25d20c4bb552 Mon Sep 17 00:00:00 2001 From: reppad Date: Sun, 30 May 2021 16:14:21 +0200 Subject: [PATCH 28/55] Add Muselab Nanoesp32_s2 w/Wrover --- .github/workflows/build.yml | 3 +- .../board.c | 0 .../mpconfigboard.h | 2 +- .../mpconfigboard.mk | 2 +- .../pins.c | 0 .../sdkconfig | 0 .../muselab_nanoesp32_s2_wrover/board.c | 52 +++++++++++++++++++ .../mpconfigboard.h | 38 ++++++++++++++ .../mpconfigboard.mk | 17 ++++++ .../boards/muselab_nanoesp32_s2_wrover/pins.c | 48 +++++++++++++++++ .../muselab_nanoesp32_s2_wrover/sdkconfig | 0 11 files changed, 159 insertions(+), 3 deletions(-) rename ports/esp32s2/boards/{muselab_nanoesp32_s2 => muselab_nanoesp32_s2_wroom}/board.c (100%) rename ports/esp32s2/boards/{muselab_nanoesp32_s2 => muselab_nanoesp32_s2_wroom}/mpconfigboard.h (96%) rename ports/esp32s2/boards/{muselab_nanoesp32_s2 => muselab_nanoesp32_s2_wroom}/mpconfigboard.mk (90%) rename ports/esp32s2/boards/{muselab_nanoesp32_s2 => muselab_nanoesp32_s2_wroom}/pins.c (100%) rename ports/esp32s2/boards/{muselab_nanoesp32_s2 => muselab_nanoesp32_s2_wroom}/sdkconfig (100%) create mode 100644 ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/board.c create mode 100644 ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h create mode 100644 ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk create mode 100644 ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/pins.c create mode 100644 ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/sdkconfig diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67c93fc02b..d6e995b799 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -473,7 +473,8 @@ jobs: - "franzininho_wifi_wrover" - "lilygo_ttgo_t8_s2_st7789" - "microdev_micro_s2" - - "muselab_nanoesp32_s2" + - "muselab_nanoesp32_s2_wroom" + - "muselab_nanoesp32_s2_wrover" - "targett_module_clip_wroom" - "targett_module_clip_wrover" - "unexpectedmaker_feathers2" diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c b/ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/board.c similarity index 100% rename from ports/esp32s2/boards/muselab_nanoesp32_s2/board.c rename to ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/board.c diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.h b/ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h similarity index 96% rename from ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.h rename to ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h index 1612153976..41ce41c238 100644 --- a/ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.h +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -26,7 +26,7 @@ // Micropython setup -#define MICROPY_HW_BOARD_NAME "nanoESP32-S2" +#define MICROPY_HW_BOARD_NAME "nanoESP32-S2 w/Wroom" #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.mk b/ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.mk similarity index 90% rename from ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.mk rename to ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.mk index 449676d380..736bbb5adc 100644 --- a/ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.mk +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.mk @@ -1,6 +1,6 @@ USB_VID = 0x239A USB_PID = 0x80DE -USB_PRODUCT = "nanoESP32-S2" +USB_PRODUCT = "nanoESP32-S2 w/Wroom" USB_MANUFACTURER = "Muselab" INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2/pins.c b/ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/pins.c similarity index 100% rename from ports/esp32s2/boards/muselab_nanoesp32_s2/pins.c rename to ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/pins.c diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2/sdkconfig b/ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/sdkconfig similarity index 100% rename from ports/esp32s2/boards/muselab_nanoesp32_s2/sdkconfig rename to ports/esp32s2/boards/muselab_nanoesp32_s2_wroom/sdkconfig diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/board.c b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/board.c new file mode 100644 index 0000000000..e40b6335bc --- /dev/null +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/board.c @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft 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 "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // USB + common_hal_never_reset_pin(&pin_GPIO19); + common_hal_never_reset_pin(&pin_GPIO20); + + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h new file mode 100644 index 0000000000..c5c05676f1 --- /dev/null +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft 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. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "nanoESP32-S2 w/Wrover" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk new file mode 100644 index 0000000000..fbb03d02fc --- /dev/null +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x239A +USB_PID = 0x80DE +USB_PRODUCT = "nanoESP32-S2 w/Wrover" +USB_MANUFACTURER = "Muselab" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB + +CIRCUITPY_MODULE=wrover diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/pins.c b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/pins.c new file mode 100644 index 0000000000..0562d9331f --- /dev/null +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/pins.c @@ -0,0 +1,48 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + + + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/sdkconfig b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/sdkconfig new file mode 100644 index 0000000000..e69de29bb2 From 8761e4bfd7b7124873c561b1b86e7c597d024489 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 30 May 2021 12:12:38 -0500 Subject: [PATCH 29/55] Initialize pacing timer --- ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index f5bfd2d0df..e191606577 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -102,6 +102,7 @@ void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *s } audio_dma_init(&self->dma); + self->pacing_timer = NUM_DMA_TIMERS; self->quiescent_value = quiescent_value; } @@ -127,10 +128,8 @@ void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, mp_obj_t sample, bool loop) { - if (self->dma.channel[0] < NUM_DMA_CHANNELS) { - if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) { - common_hal_audiopwmio_pwmaudioout_stop(self); - } + if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) { + common_hal_audiopwmio_pwmaudioout_stop(self); } // TODO: Share pacing timers based on frequency. From ed977e9f25049a097a35fbf5106cf6e6f3ed772d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 30 May 2021 11:59:57 -0500 Subject: [PATCH 30/55] mpy-cross: Build an arm64 (M1) bin and a universal bin --- .github/workflows/build.yml | 16 ++++++++++++++++ mpy-cross/Makefile.m1 | 11 +++++++++++ 2 files changed, 27 insertions(+) create mode 100644 mpy-cross/Makefile.m1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b23f4538e..8bc6e22f8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,8 +154,24 @@ jobs: with: name: mpy-cross-macos-catalina path: mpy-cross/mpy-cross + - name: Select SDK for M1 build + run: sudo xcode-select -switch /Applications/Xcode_12.3.app + - name: Build mpy-cross (arm64) + run: make -C mpy-cross -j2 -f Makefile.m1 V=2 + - uses: actions/upload-artifact@v2 + with: + name: mpy-cross-macos-bigsur-arm64 + path: mpy-cross/mpy-cross-arm64 + - name: Make universal binary + run: lipo -create -output mpy-cross-macos-universal mpy-cross/mpy-cross mpy-cross/mpy-cross-arm64 + - uses: actions/upload-artifact@v2 + with: + name: mpy-cross-macos-universal + path: mpy-cross-macos-universal - name: Upload mpy-cross build to S3 run: | + [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross-macos-universal s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross-macos-universal-${{ env.CP_VERSION }} --no-progress --region us-east-1 + [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross-arm64 s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross-macos-bigsur-${{ env.CP_VERSION }}-arm64 --no-progress --region us-east-1 [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross-macos-catalina-${{ env.CP_VERSION }} --no-progress --region us-east-1 env: AWS_PAGER: '' diff --git a/mpy-cross/Makefile.m1 b/mpy-cross/Makefile.m1 new file mode 100644 index 0000000000..063036f597 --- /dev/null +++ b/mpy-cross/Makefile.m1 @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors) +# +# SPDX-License-Identifier: MIT + +PROG=mpy-cross-arm64 +BUILD=build-arm64 + +include mpy-cross.mk +# Because mpy-cross.mk unconditionally overwrites CC for Darwin, we must set it BELOW the inclusion +CC := $(shell xcrun --sdk macosx11.1 --find clang) -isysroot $(shell xcrun --sdk macosx11.1 --show-sdk-path) -target arm64-apple-macos11 -DMICROPY_NLR_SETJMP=1 +$(info pt2 CC=$(CC)) From 61d25f197ab17d05e1aede3f90de8f5ef9e0d055 Mon Sep 17 00:00:00 2001 From: reppad Date: Sun, 30 May 2021 20:18:49 +0200 Subject: [PATCH 31/55] Add requested Espressif PID --- .../boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk index fbb03d02fc..9904a06e4b 100644 --- a/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.mk @@ -1,5 +1,5 @@ -USB_VID = 0x239A -USB_PID = 0x80DE +USB_VID = 0x303A +USB_PID = 0x80B2 USB_PRODUCT = "nanoESP32-S2 w/Wrover" USB_MANUFACTURER = "Muselab" From 064e6881ed2fbef4ede82c5dae4e5d8ba0cc1958 Mon Sep 17 00:00:00 2001 From: Jonathan Giles Date: Mon, 31 May 2021 14:14:20 -0400 Subject: [PATCH 32/55] Fix mpy-cross build on Apple M1 machines --- py/nlraarch64.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/py/nlraarch64.c b/py/nlraarch64.c index 66faf93fa5..37a860540e 100644 --- a/py/nlraarch64.c +++ b/py/nlraarch64.c @@ -34,8 +34,13 @@ // Implemented purely as inline assembly; inside a function, we have to deal with undoing the prologue, restoring // SP and LR. This way, we don't. __asm( + #if defined(__APPLE__) && defined(__MACH__) + "_nlr_push: \n" + ".global _nlr_push \n" + #else "nlr_push: \n" ".global nlr_push \n" + #endif "mov x9, sp \n" "stp lr, x9, [x0, #16]\n" // 16 == offsetof(nlr_buf_t, regs) "stp x19, x20, [x0, #32]\n" @@ -44,7 +49,11 @@ __asm( "stp x25, x26, [x0, #80]\n" "stp x27, x28, [x0, #96]\n" "str x29, [x0, #112]\n" + #if defined(__APPLE__) && defined(__MACH__) + "b _nlr_push_tail \n" // do the rest in C + #else "b nlr_push_tail \n" // do the rest in C + #endif ); NORETURN void nlr_jump(void *val) { From 9eed85dd12e685ebe30833f4accd4a9fbc95041b Mon Sep 17 00:00:00 2001 From: hexthat Date: Tue, 1 Jun 2021 01:26:20 +0000 Subject: [PATCH 33/55] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (994 of 994 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 1a82e35d25..9a59f6236f 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-05-25 17:41+0000\n" +"PO-Revision-Date: 2021-06-01 13:10+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -99,7 +99,7 @@ msgstr "%q lièbiǎo bìxū shì lièbiǎo" #: shared-bindings/usb_hid/Device.c msgid "%q must be 0-255" -msgstr "" +msgstr "%q bì xū wéi 0-255" #: shared-bindings/usb_hid/Device.c msgid "%q must be 1-255" @@ -119,7 +119,7 @@ msgstr "%q bìxū dàyú huò děngyú 1" #: shared-bindings/usb_hid/Device.c msgid "%q must be None or between 1 and len(report_descriptor)-1" -msgstr "" +msgstr "%q bì xū wéi wú huò zài 1 hé len(report_descriptor)-1 zhī jiān" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" From dbf9918f78323dc135019eb3b9148887948a3132 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 1 Jun 2021 12:46:31 -0500 Subject: [PATCH 34/55] mpy-cross: Remove bug workaround, debug print --- mpy-cross/Makefile.m1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mpy-cross/Makefile.m1 b/mpy-cross/Makefile.m1 index 063036f597..34e9841540 100644 --- a/mpy-cross/Makefile.m1 +++ b/mpy-cross/Makefile.m1 @@ -7,5 +7,4 @@ BUILD=build-arm64 include mpy-cross.mk # Because mpy-cross.mk unconditionally overwrites CC for Darwin, we must set it BELOW the inclusion -CC := $(shell xcrun --sdk macosx11.1 --find clang) -isysroot $(shell xcrun --sdk macosx11.1 --show-sdk-path) -target arm64-apple-macos11 -DMICROPY_NLR_SETJMP=1 -$(info pt2 CC=$(CC)) +CC := $(shell xcrun --sdk macosx11.1 --find clang) -isysroot $(shell xcrun --sdk macosx11.1 --show-sdk-path) -target arm64-apple-macos11 From d888238dfef0ddc116178094a1ccf08d70e08dda Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 1 Jun 2021 19:15:51 -0500 Subject: [PATCH 35/55] Update __init__.c some small typos --- shared-bindings/usb_cdc/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/usb_cdc/__init__.c b/shared-bindings/usb_cdc/__init__.c index f16373fa73..18e8356e34 100644 --- a/shared-bindings/usb_cdc/__init__.c +++ b/shared-bindings/usb_cdc/__init__.c @@ -52,9 +52,9 @@ //| """The `console` `Serial` object is used for the REPL, and for `sys.stdin` and `sys.stdout`. //| `console` is ``None`` if disabled. //| -//| However, note that`sys.stdin` and `sys.stdout` are text-based streams, +//| However, note that `sys.stdin` and `sys.stdout` are text-based streams, //| and the `console` object is a binary stream. -//| You do not normally need to write to `console` unless you wnat to write binary data. +//| You do not normally need to write to `console` unless you want to write binary data. //| """ //| //| data: Optional[Serial] From d6f47d2182be8b7fd8342f43f6b4068ed0957ce6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 1 Jun 2021 21:09:59 -0400 Subject: [PATCH 36/55] update frozen libraries for 7.0.0-alpha.3 --- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_ESP32SPI | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- frozen/Adafruit_CircuitPython_ProgressBar | 2 +- frozen/Adafruit_CircuitPython_SimpleIO | 2 +- frozen/Adafruit_CircuitPython_seesaw | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 8ece81d95a..f376fcca8c 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 8ece81d95a62c2aa84a7f4d5ebaef362bbbabc45 +Subproject commit f376fcca8c829b1e68236edbef6b71cb57f7e42f diff --git a/frozen/Adafruit_CircuitPython_ESP32SPI b/frozen/Adafruit_CircuitPython_ESP32SPI index d3e7a587a2..61e38631b5 160000 --- a/frozen/Adafruit_CircuitPython_ESP32SPI +++ b/frozen/Adafruit_CircuitPython_ESP32SPI @@ -1 +1 @@ -Subproject commit d3e7a587a2f974251f44254fae88c14a52229979 +Subproject commit 61e38631b557a51376edbd02501ca51311631597 diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index de68b7d457..78b0fbbb00 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit de68b7d4575151c1648c734559e59c2932965939 +Subproject commit 78b0fbbb00c0431042b460fe20a76bbc440c4793 diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index bdef506ca4..a8e9975b3f 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit bdef506ca48a50607ad6a3e5a9c7cc2c9ace0e42 +Subproject commit a8e9975b3f06d454f8951254d96f99755b11d962 diff --git a/frozen/Adafruit_CircuitPython_ProgressBar b/frozen/Adafruit_CircuitPython_ProgressBar index 7b617d33ee..7193260344 160000 --- a/frozen/Adafruit_CircuitPython_ProgressBar +++ b/frozen/Adafruit_CircuitPython_ProgressBar @@ -1 +1 @@ -Subproject commit 7b617d33ee5746140aa38edec001f4f5c31167ce +Subproject commit 7193260344306337050a165bdee4f9d0de7bb8e9 diff --git a/frozen/Adafruit_CircuitPython_SimpleIO b/frozen/Adafruit_CircuitPython_SimpleIO index dd00c66121..9b53bebc52 160000 --- a/frozen/Adafruit_CircuitPython_SimpleIO +++ b/frozen/Adafruit_CircuitPython_SimpleIO @@ -1 +1 @@ -Subproject commit dd00c661217143b610903adf52c285cc5c5396a6 +Subproject commit 9b53bebc520d70f89d44fc989fc493d5036df925 diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index 6467edbed5..3c47a7323f 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit 6467edbed535484ebdd7492d885adf3433fb8280 +Subproject commit 3c47a7323f81e961b06853814964d04db5b3817b From 6737bbdcf3a9dd3b1fe60dd9bef4cbdd3fae1f89 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 1 Jun 2021 20:38:56 -0500 Subject: [PATCH 37/55] stubs package with data_files --- setup.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index d2989d068d..8c1f27e405 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,11 @@ # SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors) # # SPDX-License-Identifier: MIT - +import os +import site from datetime import datetime +from typing import List + from setuptools import setup from pathlib import Path import subprocess @@ -25,6 +28,13 @@ if len(pieces) > 2: pieces.pop() version = "-".join(pieces) +def build_data_files_list() -> List[tuple]: + result = [] + for package in os.listdir("circuitpython-stubs"): + result.append((site.getsitepackages()[0] + "/" + package + "/", + ["circuitpython-stubs/{}/__init__.pyi".format(package)])) + return result + setup( name="circuitpython-stubs", description="PEP 561 type stubs for CircuitPython", @@ -34,7 +44,6 @@ setup( author_email="circuitpython@adafruit.com", version=version, license="MIT", - package_data={"circuitpython-stubs": stubs}, - packages=["circuitpython-stubs"], + data_files=build_data_files_list(), setup_requires=["setuptools>=38.6.0"], ) From 6278c2bb9f4c7b86fb81f0bbecb26deecc314b0a Mon Sep 17 00:00:00 2001 From: Tsutomu IKEGAMI Date: Wed, 2 Jun 2021 11:57:55 +0900 Subject: [PATCH 38/55] Fix bit_length() method to work with zero-valued mpz integer. --- py/mpz.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/mpz.h b/py/mpz.h index b273cdcc62..275e0b9a62 100644 --- a/py/mpz.h +++ b/py/mpz.h @@ -142,6 +142,9 @@ static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * MPZ_DIG_SIZE; } static inline size_t mpz_num_bits(const mpz_t *z) { + if (mpz_is_zero(z)) { + return 0; + } size_t last_bits = (8 * (sizeof(long) - sizeof(mpz_dig_t))) - __builtin_clzl(z->dig[z->len - 1]); return z->len * MPZ_DIG_SIZE + last_bits; } From 9490010d7d00fe3d28d30bcc028c1e0a07ce342f Mon Sep 17 00:00:00 2001 From: Tsutomu IKEGAMI Date: Wed, 2 Jun 2021 12:10:41 +0900 Subject: [PATCH 39/55] Fix format (expand tab) --- py/mpz.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/mpz.h b/py/mpz.h index 275e0b9a62..ba2db4c308 100644 --- a/py/mpz.h +++ b/py/mpz.h @@ -143,7 +143,7 @@ static inline size_t mpz_max_num_bits(const mpz_t *z) { } static inline size_t mpz_num_bits(const mpz_t *z) { if (mpz_is_zero(z)) { - return 0; + return 0; } size_t last_bits = (8 * (sizeof(long) - sizeof(mpz_dig_t))) - __builtin_clzl(z->dig[z->len - 1]); return z->len * MPZ_DIG_SIZE + last_bits; From 6af36757a7aaf56d3d2c949cdbdd0a315973648a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 2 Jun 2021 08:50:20 -0400 Subject: [PATCH 40/55] lengthen RP2040 xosc startup time --- ports/raspberrypi/sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/sdk b/ports/raspberrypi/sdk index 7a6660134a..49c0c1613d 160000 --- a/ports/raspberrypi/sdk +++ b/ports/raspberrypi/sdk @@ -1 +1 @@ -Subproject commit 7a6660134ac6242e3223fe1c78b248caf6b2cbf4 +Subproject commit 49c0c1613dca37eea85f168290e858cca4411d81 From 3930440bc5112641856d557a919d3e6312cac34a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 2 Jun 2021 11:29:56 -0400 Subject: [PATCH 41/55] Fix usb_cdc.enable(console=False, data=True) --- .../atmel-samd/boards/metro_m4_express/pins.c | 2 ++ shared-module/usb_cdc/__init__.c | 18 ++++++++++++---- supervisor/shared/usb/usb.c | 21 ++++++++++++------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/ports/atmel-samd/boards/metro_m4_express/pins.c b/ports/atmel-samd/boards/metro_m4_express/pins.c index 4eb26dd21b..8b04072917 100644 --- a/ports/atmel-samd/boards/metro_m4_express/pins.c +++ b/ports/atmel-samd/boards/metro_m4_express/pins.c @@ -26,6 +26,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA19) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA17) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_LED),MP_ROM_PTR(&pin_PA16) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D13),MP_ROM_PTR(&pin_PA16) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_PB02) }, diff --git a/shared-module/usb_cdc/__init__.c b/shared-module/usb_cdc/__init__.c index 769a2ce87f..5881ec4c32 100644 --- a/shared-module/usb_cdc/__init__.c +++ b/shared-module/usb_cdc/__init__.c @@ -147,26 +147,26 @@ static const char data_cdc_comm_interface_name[] = USB_INTERFACE_NAME " CDC2 con static const char console_cdc_data_interface_name[] = USB_INTERFACE_NAME " CDC data"; static const char data_cdc_data_interface_name[] = USB_INTERFACE_NAME " CDC2 data"; +// .idx is set later. + static usb_cdc_serial_obj_t usb_cdc_console_obj = { .base.type = &usb_cdc_serial_type, .timeout = -1.0f, .write_timeout = -1.0f, - .idx = 0, }; static usb_cdc_serial_obj_t usb_cdc_data_obj = { .base.type = &usb_cdc_serial_type, .timeout = -1.0f, .write_timeout = -1.0f, - .idx = 1, }; static bool usb_cdc_console_is_enabled; static bool usb_cdc_data_is_enabled; void usb_cdc_set_defaults(void) { - usb_cdc_console_is_enabled = CIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT; - usb_cdc_data_is_enabled = CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT; + common_hal_usb_cdc_enable(CIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT, + CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT); } bool usb_cdc_console_enabled(void) { @@ -241,11 +241,21 @@ bool common_hal_usb_cdc_enable(bool console, bool data) { // Right now these objects contain no heap objects, but if that changes, // they will need to be protected against gc. + // Assign only as many idx values as necessary. They must start at 0. + uint8_t idx = 0; usb_cdc_console_is_enabled = console; usb_cdc_set_console(console ? MP_OBJ_FROM_PTR(&usb_cdc_console_obj) : mp_const_none); + if (console) { + usb_cdc_console_obj.idx = idx; + idx++; + } usb_cdc_data_is_enabled = data; usb_cdc_set_data(data ? MP_OBJ_FROM_PTR(&usb_cdc_data_obj) : mp_const_none); + if (data) { + usb_cdc_data_obj.idx = idx; + } + return true; } diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 061e74e73d..9c4cffb80e 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -77,10 +77,14 @@ void usb_init(void) { post_usb_init(); - #if MICROPY_KBD_EXCEPTION + #if MICROPY_KBD_EXCEPTION && CIRCUITPY_USB_CDC // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() usb_callback will be invoked when Ctrl+C is received // This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here - tud_cdc_set_wanted_char(CHAR_CTRL_C); + + // Don't watch for ctrl-C if there is no REPL. + if (usb_cdc_console_enabled()) { + tud_cdc_set_wanted_char(CHAR_CTRL_C); + } #endif } @@ -103,7 +107,7 @@ void usb_set_defaults(void) { #endif }; -// Some dynamic USB data must be saved after boot.py. How much is needed +// Some dynamic USB data must be saved after boot.py. How much is needed? size_t usb_boot_py_data_size(void) { size_t size = 0; @@ -151,7 +155,10 @@ void usb_background(void) { #if CFG_TUSB_OS == OPT_OS_NONE tud_task(); #endif - tud_cdc_write_flush(); + // No need to flush if there's no REPL. + if (usb_cdc_console_enabled()) { + tud_cdc_write_flush(); + } } } @@ -274,13 +281,13 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ * @param itf Interface index (for multiple cdc interfaces) * @param wanted_char The wanted char (set previously) */ -void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) { - (void)itf; // not used +// Only called when console is enabled. +void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) { // Workaround for using lib/utils/interrupt_char.c // Compare mp_interrupt_char with wanted_char and ignore if not matched if (mp_interrupt_char == wanted_char) { - tud_cdc_read_flush(); // flush read fifo + tud_cdc_n_read_flush(itf); // flush read fifo mp_keyboard_interrupt(); } } From 95cbf3faa58bc2e0b400cc360dbaed9ccc668329 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 2 Jun 2021 15:27:20 -0400 Subject: [PATCH 42/55] handle CIRCUITPY_USB_CDC = 0 properly (fix simmel build) --- supervisor/shared/usb/usb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 9c4cffb80e..0e1c3472eb 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -83,6 +83,7 @@ void usb_init(void) { // Don't watch for ctrl-C if there is no REPL. if (usb_cdc_console_enabled()) { + // Console will always be itf 0. tud_cdc_set_wanted_char(CHAR_CTRL_C); } #endif @@ -156,9 +157,12 @@ void usb_background(void) { tud_task(); #endif // No need to flush if there's no REPL. + #if CIRCUITPY_USB_CDC if (usb_cdc_console_enabled()) { + // Console will always be itf 0. tud_cdc_write_flush(); } + #endif } } @@ -212,6 +216,7 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { // DTR = false is counted as disconnected if (!dtr) { cdc_line_coding_t coding; + // Use whichever CDC is itf 0. tud_cdc_get_line_coding(&coding); if (coding.bit_rate == 1200) { From db1830d62b07d17c7fcb74dcfafaf60113f61e72 Mon Sep 17 00:00:00 2001 From: George White Date: Wed, 2 Jun 2021 21:14:02 -0400 Subject: [PATCH 43/55] Add Sparkfun MicroMod SAMD51 --- .github/workflows/build.yml | 1 + .../boards/sparkfun_samd51_micromod/board.c | 38 +++++++ .../sparkfun_samd51_micromod/mpconfigboard.h | 33 +++++++ .../sparkfun_samd51_micromod/mpconfigboard.mk | 14 +++ .../boards/sparkfun_samd51_micromod/pins.c | 99 +++++++++++++++++++ 5 files changed, 185 insertions(+) create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e78c4067ed..4c6a7167da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -347,6 +347,7 @@ jobs: - "sparkfun_redboard_turbo" - "sparkfun_samd21_dev" - "sparkfun_samd21_mini" + - "sparkfun_samd51_micromod" - "sparkfun_samd51_thing_plus" - "sparkfun_thing_plus_rp2040" - "spresense" diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c b/ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c new file mode 100644 index 0000000000..5fca974e9e --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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 "supervisor/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h new file mode 100644 index 0000000000..9099970c19 --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h @@ -0,0 +1,33 @@ +#define MICROPY_HW_BOARD_NAME "SparkFun Thing Plus - SAMD51" +#define MICROPY_HW_MCU_NAME "samd51j20" + +#define CIRCUITPY_MCU_FAMILY samd51 + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PA09 +#define SPI_FLASH_MISO_PIN &pin_PA10 +#define SPI_FLASH_SCK_PIN &pin_PA08 +#define SPI_FLASH_CS_PIN &pin_PA11 + +// These are pins not to reset. +// SPI Data pins +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PA16) +#define DEFAULT_I2C_BUS_SDA (&pin_PA17) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA05) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA04) +#define DEFAULT_SPI_BUS_MISO (&pin_PB06) + +#define DEFAULT_UART_BUS_RX (&pin_PB30) +#define DEFAULT_UART_BUS_TX (&pin_PB31) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk new file mode 100644 index 0000000000..63d52382a2 --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk @@ -0,0 +1,14 @@ +LD_FILE = boards/samd51x20-bootloader-external-flash.ld +USB_VID = 0x1b4f +USB_PID = 0x0020 # Used by uf2 bootloader +USB_PRODUCT = "SparkFun MicroMod SAMD51" +USB_MANUFACTURER = "SparkFun Electronics" + +CHIP_VARIANT = SAMD51J20A +CHIP_FAMILY = samd51 + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = W25Q128JVxM +LONGINT_IMPL = MPZ + +CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c new file mode 100644 index 0000000000..ade56ef1ee --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c @@ -0,0 +1,99 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // D (digital only) pins (D0,D1) + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB04) } + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB05) }, + + // A (ADC) pins (A0-A4) + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA03) }, + + // DAC + { MP_ROM_QSTR(MP_QSTR_DAC), MP_ROM_PTR(&pin_PA02) }, + + // G (General/BUS) pins (G0-G9) + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_D32), MP_ROM_PTR(&pin_PB31) }, + { MP_ROM_QSTR(MP_QSTR_D33), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR(&pin_PB15) }, + + // PWM pins (PWM0, PWM1) + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_PA02) }, + + // AUD (audio) + { MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR(&pin_PB17) }, + { MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_PA21) }, + { MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_GPA16) }, + + // I2C + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PA16) }, + + { MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_PB18) }, + + // I2C2 + { MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PA12) }, + + // SPI + { MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA07) }, + + // Status LED + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA23) }, + + // UART + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB31) }, + { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PB31) }, + + // UART2 + { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA12) }, + + + // Board objects + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); + + From 4c493c86c8555a7d2a3c207a39a1ec4722a6cf0a Mon Sep 17 00:00:00 2001 From: George White Date: Wed, 2 Jun 2021 21:14:02 -0400 Subject: [PATCH 44/55] Add Sparkfun MicroMod SAMD51 --- .github/workflows/build.yml | 1 + .../boards/sparkfun_samd51_micromod/board.c | 38 ++++++++ .../sparkfun_samd51_micromod/mpconfigboard.h | 33 +++++++ .../sparkfun_samd51_micromod/mpconfigboard.mk | 14 +++ .../boards/sparkfun_samd51_micromod/pins.c | 97 +++++++++++++++++++ 5 files changed, 183 insertions(+) create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e78c4067ed..4c6a7167da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -347,6 +347,7 @@ jobs: - "sparkfun_redboard_turbo" - "sparkfun_samd21_dev" - "sparkfun_samd21_mini" + - "sparkfun_samd51_micromod" - "sparkfun_samd51_thing_plus" - "sparkfun_thing_plus_rp2040" - "spresense" diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c b/ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c new file mode 100644 index 0000000000..5fca974e9e --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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 "supervisor/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h new file mode 100644 index 0000000000..9099970c19 --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h @@ -0,0 +1,33 @@ +#define MICROPY_HW_BOARD_NAME "SparkFun Thing Plus - SAMD51" +#define MICROPY_HW_MCU_NAME "samd51j20" + +#define CIRCUITPY_MCU_FAMILY samd51 + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PA09 +#define SPI_FLASH_MISO_PIN &pin_PA10 +#define SPI_FLASH_SCK_PIN &pin_PA08 +#define SPI_FLASH_CS_PIN &pin_PA11 + +// These are pins not to reset. +// SPI Data pins +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PA16) +#define DEFAULT_I2C_BUS_SDA (&pin_PA17) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA05) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA04) +#define DEFAULT_SPI_BUS_MISO (&pin_PB06) + +#define DEFAULT_UART_BUS_RX (&pin_PB30) +#define DEFAULT_UART_BUS_TX (&pin_PB31) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk new file mode 100644 index 0000000000..63d52382a2 --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk @@ -0,0 +1,14 @@ +LD_FILE = boards/samd51x20-bootloader-external-flash.ld +USB_VID = 0x1b4f +USB_PID = 0x0020 # Used by uf2 bootloader +USB_PRODUCT = "SparkFun MicroMod SAMD51" +USB_MANUFACTURER = "SparkFun Electronics" + +CHIP_VARIANT = SAMD51J20A +CHIP_FAMILY = samd51 + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = W25Q128JVxM +LONGINT_IMPL = MPZ + +CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c new file mode 100644 index 0000000000..3870f6f510 --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c @@ -0,0 +1,97 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // D (digital only) pins (D0,D1) + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB04) } + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB05) }, + + // A (ADC) pins (A0-A4) + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA03) }, + + // DAC + { MP_ROM_QSTR(MP_QSTR_DAC), MP_ROM_PTR(&pin_PA02) }, + + // G (General/BUS) pins (G0-G9) + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_D32), MP_ROM_PTR(&pin_PB31) }, + { MP_ROM_QSTR(MP_QSTR_D33), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR(&pin_PB15) }, + + // PWM pins (PWM0, PWM1) + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_PA02) }, + + // AUD (audio) + { MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR(&pin_PB17) }, + { MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_PA21) }, + { MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_GPA16) }, + + // I2C + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PA16) }, + + { MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_PB18) }, + + // I2C2 + { MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PA12) }, + + // SPI + { MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA07) }, + + // Status LED + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA23) }, + + // UART + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB31) }, + { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PB31) }, + + // UART2 + { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA12) }, + + + // Board objects + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 2b068414e1bcab7ae72a55d8d0436b9377eafca4 Mon Sep 17 00:00:00 2001 From: George White Date: Wed, 2 Jun 2021 23:13:08 -0400 Subject: [PATCH 45/55] Fix missing comma Doh --- ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c index 59747cdc90..81fd594ab0 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c @@ -2,7 +2,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // D (digital only) pins (D0,D1) - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB04) } + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB04) }, { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB05) }, // A (ADC) pins (A0-A4) From 6e36f30d9f6cc6f1394405a8fe7545cd522f5efb Mon Sep 17 00:00:00 2001 From: George White Date: Thu, 3 Jun 2021 05:36:05 -0400 Subject: [PATCH 46/55] MicroMod SAMDt1 - correct board nane --- .../atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h index 9099970c19..dc9809d564 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h @@ -1,4 +1,4 @@ -#define MICROPY_HW_BOARD_NAME "SparkFun Thing Plus - SAMD51" +#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod SAMD51" #define MICROPY_HW_MCU_NAME "samd51j20" #define CIRCUITPY_MCU_FAMILY samd51 From 26c6bd2346870d5848cbe2e7ba0edccf314944e6 Mon Sep 17 00:00:00 2001 From: George White Date: Thu, 3 Jun 2021 05:39:09 -0400 Subject: [PATCH 47/55] MicroMod SAMD51 - correct SCL2 --- ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c index 81fd594ab0..63c3aca894 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c @@ -64,7 +64,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // I2C2 { MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PA13) }, - { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_SCL2), MP_ROM_PTR(&pin_PA12) }, // SPI { MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PA06) }, From 9cde8a22655866af25becdff72b38589d47f8d52 Mon Sep 17 00:00:00 2001 From: George White Date: Thu, 3 Jun 2021 06:05:13 -0400 Subject: [PATCH 48/55] MicroMod SAMD51 - correct I2C_INT pin --- ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c index 63c3aca894..49411217d7 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/pins.c @@ -60,7 +60,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PA16) }, - { MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_PB18) }, + { MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_PA18) }, // I2C2 { MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PA13) }, From a4be61912c768d506390384935334276fc4b9e3f Mon Sep 17 00:00:00 2001 From: Tsutomu IKEGAMI Date: Thu, 3 Jun 2021 20:40:37 +0900 Subject: [PATCH 49/55] Fix move cursor esc sequence of terminalio to meet ANSI standard --- shared-module/terminalio/Terminal.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shared-module/terminalio/Terminal.c b/shared-module/terminalio/Terminal.c index 8ef2acd1ca..8e4979ecad 100644 --- a/shared-module/terminalio/Terminal.c +++ b/shared-module/terminalio/Terminal.c @@ -106,7 +106,7 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con } } if (c == ';') { - int16_t m = 0; + uint16_t m = 0; for (++j; j < 9; j++) { if ('0' <= i[j] && i[j] <= '9') { m = m * 10 + (i[j] - '0'); @@ -116,6 +116,12 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con } } if (c == 'H') { + if (n > 0) { + n--; + } + if (m > 0) { + m--; + } if (n >= self->tilegrid->height_in_tiles) { n = self->tilegrid->height_in_tiles - 1; } From 6011db3aec0ae0b15af50ccafbedf657895c9603 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Thu, 3 Jun 2021 15:49:23 +0100 Subject: [PATCH 50/55] Added board definition --- .github/workflows/build.yml | 1 + .../boards/pimoroni_pga2040/board.c | 37 +++++++++++++++ .../boards/pimoroni_pga2040/mpconfigboard.h | 2 + .../boards/pimoroni_pga2040/mpconfigboard.mk | 11 +++++ .../boards/pimoroni_pga2040/pins.c | 47 +++++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 ports/raspberrypi/boards/pimoroni_pga2040/board.c create mode 100644 ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/pimoroni_pga2040/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e78c4067ed..fe719a845b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -308,6 +308,7 @@ jobs: - "pewpew_m4" - "picoplanet" - "pimoroni_keybow2040" + - "pimoroni_pga2040" - "pimoroni_picolipo_16mb" - "pimoroni_picolipo_4mb" - "pimoroni_picosystem" diff --git a/ports/raspberrypi/boards/pimoroni_pga2040/board.c b/ports/raspberrypi/boards/pimoroni_pga2040/board.c new file mode 100644 index 0000000000..67486d4c23 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_pga2040/board.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft 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 "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.h new file mode 100644 index 0000000000..a5a0414146 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.h @@ -0,0 +1,2 @@ +#define MICROPY_HW_BOARD_NAME "Pimoroni PGA2040" +#define MICROPY_HW_MCU_NAME "rp2040" diff --git a/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk new file mode 100644 index 0000000000..b5b750bd39 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x1006 +USB_PRODUCT = "PGA2040" +USB_MANUFACTURER = "Pimoroni" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/pimoroni_pga2040/pins.c b/ports/raspberrypi/boards/pimoroni_pga2040/pins.c new file mode 100644 index 0000000000..1ddc885082 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_pga2040/pins.c @@ -0,0 +1,47 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + + { MP_ROM_QSTR(MP_QSTR_GP29_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From e6fe55349d92eda60db3060bfc739a6f037535d9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 13 May 2021 10:33:24 -0500 Subject: [PATCH 51/55] run_tests: Parallelism improvements, partial sync with micropython Take changes from https://github.com/micropython/micropython/pull/3694 (expected to be merged soon) as well as other accumulated stuff from upstream that we want. Leave our desired differences, including: * silencing warnings in python3 * renaming the file descriptors returned by openpty() * adding ulab tests * Adding "." to the import path for skip_if This speeds up `make test_full` and should also reduce the time in CI a little bit. --- ports/unix/Makefile | 2 +- tests/run-tests.py | 96 ++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 55 deletions(-) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 0e52063ac7..a4374500ef 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -228,7 +228,7 @@ include $(TOP)/py/mkrules.mk test: $(PROG) $(TOP)/tests/run-tests.py $(eval DIRNAME=ports/$(notdir $(CURDIR))) - cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py --auto-jobs + cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py test_full: $(PROG) $(TOP)/tests/run-tests.py $(eval DIRNAME=ports/$(notdir $(CURDIR))) diff --git a/tests/run-tests.py b/tests/run-tests.py index 77994f4cd8..f33822cb9b 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -7,10 +7,11 @@ import platform import argparse import inspect import re -import threading +from glob import glob import multiprocessing from multiprocessing.pool import ThreadPool -from glob import glob +import threading +import tempfile # See stackoverflow.com/questions/2632199: __file__ nor sys.argv[0] # are guaranteed to always work, this one should though. @@ -169,26 +170,27 @@ def run_micropython(pyb, args, test_file, is_special=False): # if running via .mpy, first compile the .py file if args.via_mpy: + mpy_modname = tempfile.mktemp(dir="") + mpy_filename = mpy_modname + ".mpy" subprocess.check_output( [MPYCROSS] + args.mpy_cross_flags.split() - + ["-o", "mpytest.mpy", "-X", "emit=" + args.emit, test_file] + + ["-o", mpy_filename, "-X", "emit=" + args.emit, test_file] ) - cmdlist.extend(["-m", "mpytest"]) + cmdlist.extend(["-m", mpy_modname]) else: cmdlist.append(test_file) # run the actual test - e = {"LANG": "en_US.UTF-8", "MICROPYPATH": os.environ["MICROPYPATH"]} try: - output_mupy = subprocess.check_output(cmdlist, env=e, stderr=subprocess.STDOUT) - except subprocess.CalledProcessError as error: + output_mupy = subprocess.check_output(cmdlist, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as er: had_crash = True - output_mupy = error.output + b"CRASH" + output_mupy = er.output + b"CRASH" # clean up if we had an intermediate .mpy file if args.via_mpy: - rm_f("mpytest.mpy") + rm_f(mpy_filename) else: # run on pyboard @@ -200,7 +202,7 @@ def run_micropython(pyb, args, test_file, is_special=False): if not is_special and e.args[0] == "exception": output_mupy = e.args[1] + e.args[2] + b"CRASH" else: - output_mupy = b"CRASH" + output_mupy = bytes(e.args[0], "ascii") + b"\nCRASH" # canonical form for all ports/platforms is to use \n for end-of-line output_mupy = output_mupy.replace(b"\r\n", b"\n") @@ -241,10 +243,9 @@ def run_micropython(pyb, args, test_file, is_special=False): else: # a regex if lines_exp[i][1].match(lines_mupy[i_mupy]): - # print("match", lines_exp[i][0], lines_mupy[i_mupy]) lines_mupy[i_mupy] = lines_exp[i][0] else: - # print("don't match: %r %s" % (lines_exp[i][0], lines_mupy[i_mupy])) # DEBUG + # print("don't match: %r %s" % (lines_exp[i][1], lines_mupy[i_mupy])) # DEBUG pass i_mupy += 1 if i_mupy >= len(lines_mupy): @@ -266,6 +267,9 @@ class ThreadSafeCounter: self._value = start self._lock = threading.Lock() + def increment(self): + self.add(1) + def add(self, to_add): with self._lock: self._value += to_add @@ -306,11 +310,11 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): if not (args.list_tests or args.write_exp): # Even if we run completely different tests in a different directory, # we need to access feature_checks from the same directory as the - # run-tests script itself so use base_path. + # run-tests.py script itself so use base_path. # Check if micropython.native is supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "native_check.py") - if output.endswith(b"CRASH"): + if output != b"native\n": skip_native = True # Check if arbitrary-precision integers are supported, and skip such tests if it's not @@ -325,7 +329,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): # Check if set type (and set literals) is supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "set_check.py") - if output.endswith(b"CRASH"): + if output != b"{1}\n": skip_set_type = True # Check if slice is supported, and skip such tests if it's not @@ -335,12 +339,12 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): # Check if async/await keywords are supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "async_check.py") - if output.endswith(b"CRASH"): + if output != b"async\n": skip_async = True # Check if const keyword (MicroPython extension) is supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "const.py") - if output.endswith(b"CRASH"): + if output != b"1\n": skip_const = True # Check if __rOP__ special methods are supported, and skip such tests if it's not @@ -365,10 +369,10 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): upy_byteorder = run_feature_check(pyb, args, base_path, "byteorder.py") upy_float_precision = run_feature_check(pyb, args, base_path, "float.py") - if upy_float_precision.endswith(b"CRASH"): - upy_float_precision = 0 - else: + try: upy_float_precision = int(upy_float_precision) + except ValueError: + upy_float_precision = 0 has_complex = run_feature_check(pyb, args, base_path, "complex.py") == b"complex\n" has_coverage = run_feature_check(pyb, args, base_path, "coverage.py") == b"coverage\n" cpy_byteorder = subprocess.check_output( @@ -545,7 +549,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): is_bytearray = test_name.startswith("bytearray") or test_name.endswith("_bytearray") is_set_type = test_name.startswith("set_") or test_name.startswith("frozenset") is_slice = test_name.find("slice") != -1 or test_name in misc_slice_tests - is_async = test_name.startswith("async_") + is_async = test_name.startswith(("async_", "uasyncio_")) is_const = test_name.startswith("const") is_io_module = test_name.startswith("io_") @@ -610,8 +614,8 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): filename_mupy = os.path.join(result_dir, test_basename + ".out") if output_expected == output_mupy: - # print("pass ", test_file) - passed_count.add(1) + print("pass ", test_file) + passed_count.increment() rm_f(filename_expected) rm_f(filename_mupy) else: @@ -619,17 +623,13 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): f.write(output_expected) with open(filename_mupy, "wb") as f: f.write(output_mupy) - print("### Expected") - print(output_expected) - print("### Actual") - print(output_mupy) print("FAIL ", test_file) - failed_tests.append(test_file) + failed_tests.append(test_name) - test_count.add(1) + test_count.increment() - if args.list_tests: - return True + if pyb or args.list_tests: + num_threads = 1 if num_threads > 1: pool = ThreadPool(num_threads) @@ -638,6 +638,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): for test in tests: run_one_test(test) + if args.list_tests: + return True + print( "{} tests performed ({} individual testcases)".format( test_count.value, testcase_count.value @@ -645,18 +648,12 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): ) print("{} tests passed".format(passed_count.value)) - if len(skipped_tests.value) > 0: - print( - "{} tests skipped: {}".format( - len(skipped_tests.value), " ".join(sorted(skipped_tests.value)) - ) - ) - if len(failed_tests.value) > 0: - print( - "{} tests failed: {}".format( - len(failed_tests.value), " ".join(sorted(failed_tests.value)) - ) - ) + skipped_tests = sorted(skipped_tests.value) + if len(skipped_tests) > 0: + print("{} tests skipped: {}".format(len(skipped_tests), " ".join(skipped_tests))) + failed_tests = sorted(failed_tests.value) + if len(failed_tests) > 0: + print("{} tests failed: {}".format(len(failed_tests), " ".join(failed_tests))) return False # all tests succeeded @@ -758,18 +755,11 @@ the last matching regex is used: cmd_parser.add_argument( "-j", "--jobs", - default=1, + default=multiprocessing.cpu_count(), metavar="N", type=int, help="Number of tests to run simultaneously", ) - cmd_parser.add_argument( - "--auto-jobs", - action="store_const", - dest="jobs", - const=multiprocessing.cpu_count(), - help="Set the -j values to the CPU (thread) count", - ) cmd_parser.add_argument("files", nargs="*", help="input test files") cmd_parser.add_argument( "--print-failures", @@ -869,9 +859,7 @@ the last matching regex is used: if not args.keep_path: # clear search path to make sure tests use only builtin modules and those in extmod - os.environ["MICROPYPATH"] = ( - os.pathsep + base_path("../extmod") + os.pathsep + base_path(".") - ) + os.environ["MICROPYPATH"] = os.pathsep + base_path("../extmod") try: os.makedirs(args.result_dir, exist_ok=True) From c5066efacbc3fed78dfeb3098c36436ddfef7e0c Mon Sep 17 00:00:00 2001 From: George Waters Date: Thu, 3 Jun 2021 22:55:32 -0400 Subject: [PATCH 52/55] Enable slice indices --- py/circuitpy_mpconfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index c71cad6aeb..009b428645 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -96,6 +96,7 @@ #define MICROPY_PY_BUILTINS_SET (1) #define MICROPY_PY_BUILTINS_SLICE (1) #define MICROPY_PY_BUILTINS_SLICE_ATTRS (1) +#define MICROPY_PY_BUILTINS_SLICE_INDICES (1) #define MICROPY_PY_BUILTINS_STR_UNICODE (1) #define MICROPY_PY_CMATH (0) From f2e3231c46714ccc46e3436c61d9cb6e9ef2aaff Mon Sep 17 00:00:00 2001 From: EmergReanimator Date: Thu, 3 Jun 2021 21:17:44 +0200 Subject: [PATCH 53/55] resolves #4153: Fixed build issue when CIRCUITPY_USB is off --- shared-bindings/supervisor/Runtime.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index b7ebdd850a..262346bad2 100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -33,7 +33,9 @@ #include "shared-bindings/supervisor/RunReason.h" #include "shared-bindings/supervisor/Runtime.h" +#if (CIRCUITPY_USB) #include "tusb.h" +#endif STATIC supervisor_run_reason_t _run_reason; From af7557b53b5ebfd8189905e97538d187bdb384dd Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Fri, 4 Jun 2021 16:02:32 +0100 Subject: [PATCH 54/55] Updated with final USB PID --- ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk index b5b750bd39..1b870037d4 100644 --- a/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk +++ b/ports/raspberrypi/boards/pimoroni_pga2040/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x2E8A -USB_PID = 0x1006 +USB_PID = 0x1008 USB_PRODUCT = "PGA2040" USB_MANUFACTURER = "Pimoroni" From 57334c812e19802ef75b3f01d0feb0713e855255 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 4 Jun 2021 12:10:41 -0500 Subject: [PATCH 55/55] Fix pulsein pause and resume functions to handle HCSR04 --- .../raspberrypi/common-hal/pulseio/PulseIn.c | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.c b/ports/raspberrypi/common-hal/pulseio/PulseIn.c index 78f05d5d63..520526c661 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.c @@ -117,9 +117,13 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self) { } void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) { + pio_sm_restart(self->state_machine.pio, self->state_machine.state_machine); pio_sm_set_enabled(self->state_machine.pio, self->state_machine.state_machine, false); + last_level = self->idle_state; + level_count = 0; + result = 0; + buf_index = 0; } - void common_hal_pulseio_pulsein_interrupt() { pulseio_pulsein_obj_t *self = save_self; @@ -134,13 +138,13 @@ void common_hal_pulseio_pulsein_interrupt() { } else { result = level_count; last_level = level; - level_count = 1; - // Pulses that are londger than MAX_PULSE will return MAX_PULSE + level_count = 0; + // Pulses that are longer than MAX_PULSE will return MAX_PULSE if (result > MAX_PULSE) { result = MAX_PULSE; } - // ignore pulses that are too short - if (result <= MAX_PULSE && result > MIN_PULSE) { + // return pulses that are not too short + if (result > MIN_PULSE) { self->buffer[buf_index] = (uint16_t)result; if (self->len < self->maxlen) { self->len++; @@ -165,12 +169,6 @@ void common_hal_pulseio_pulsein_interrupt() { } void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self, uint16_t trigger_duration) { - // exec a wait for the selected pin to change state - if (self->idle_state == true) { - pio_sm_exec(self->state_machine.pio,self->state_machine.state_machine,0x2020); - } else { - pio_sm_exec(self->state_machine.pio,self->state_machine.state_machine,0x20a0); - } // Send the trigger pulse. if (trigger_duration > 0) { gpio_set_function(self->pin,GPIO_FUNC_SIO); @@ -178,11 +176,17 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self, gpio_put(self->pin, !self->idle_state); common_hal_mcu_delay_us((uint32_t)trigger_duration); gpio_set_function(self->pin,GPIO_FUNC_PIO0); - common_hal_mcu_delay_us(225); + common_hal_mcu_delay_us(125); } // Reconfigure the pin for PIO gpio_set_function(self->pin, GPIO_FUNC_PIO0); + // exec a wait for the selected pin to change state + if (self->idle_state == true) { + pio_sm_exec(self->state_machine.pio,self->state_machine.state_machine,0x2020); + } else { + pio_sm_exec(self->state_machine.pio,self->state_machine.state_machine,0x20a0); + } pio_sm_set_enabled(self->state_machine.pio, self->state_machine.state_machine, true); }