From 547ca5a452f64fec654005ec669bb5c5184bd8a2 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 4 Feb 2023 12:02:06 -0600 Subject: [PATCH 001/225] bitmap constructor positive validation --- shared-bindings/displayio/Bitmap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 65551f4e0d..f507a64880 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -62,14 +62,11 @@ //| ... STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 3, 3, false); - uint32_t width = mp_obj_get_int(all_args[0]); - uint32_t height = mp_obj_get_int(all_args[1]); - uint32_t value_count = mp_obj_get_int(all_args[2]); + uint32_t width = mp_arg_validate_int_min(mp_obj_get_int(all_args[0]), 1, MP_QSTR_width); + uint32_t height = mp_arg_validate_int_min(mp_obj_get_int(all_args[1]), 1, MP_QSTR_height); + uint32_t value_count = mp_arg_validate_int_min(mp_obj_get_int(all_args[2]), 1, MP_QSTR_value_count); uint32_t bits = 1; - if (value_count == 0) { - mp_raise_ValueError(translate("value_count must be > 0")); - } while ((value_count - 1) >> bits) { if (bits < 8) { bits <<= 1; From beb4a797ff136d695d611c8b1665b433cd438331 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 4 Feb 2023 12:37:43 -0600 Subject: [PATCH 002/225] bitmap fill, __get_item__, and __set_item__ positive validation --- shared-bindings/displayio/Bitmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index f507a64880..a6bccc6298 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -141,15 +141,15 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val uint16_t x = 0; uint16_t y = 0; if (mp_obj_is_small_int(index_obj)) { - mp_int_t i = MP_OBJ_SMALL_INT_VALUE(index_obj); + mp_int_t i = mp_arg_validate_int_min(MP_OBJ_SMALL_INT_VALUE(index_obj), 0, MP_QSTR_index); uint16_t width = common_hal_displayio_bitmap_get_width(self); x = i % width; y = i / width; } else { mp_obj_t *items; mp_obj_get_array_fixed_n(index_obj, 2, &items); - x = mp_obj_get_int(items[0]); - y = mp_obj_get_int(items[1]); + x = mp_arg_validate_int_min(mp_obj_get_int(items[0]), 0, MP_QSTR_x); + y = mp_arg_validate_int_min(mp_obj_get_int(items[1]), 0, MP_QSTR_y); if (x >= common_hal_displayio_bitmap_get_width(self) || y >= common_hal_displayio_bitmap_get_height(self)) { mp_raise_IndexError(translate("pixel coordinates out of bounds")); } @@ -286,7 +286,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 1, displayio_bitmap_obj_bl STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); - mp_uint_t value = (mp_uint_t)mp_obj_get_int(value_obj); + mp_uint_t value = (mp_uint_t)mp_arg_validate_int_min(mp_obj_get_int(value_obj), 0, MP_QSTR_value); if ((value >> common_hal_displayio_bitmap_get_bits_per_value(self)) != 0) { mp_raise_ValueError(translate("pixel value requires too many bits")); } From efe48e61ed8c3cef958dc9b5ad367cd454c9da19 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 6 Feb 2023 17:03:49 -0600 Subject: [PATCH 003/225] argument bounds validation for bitmap.blit() --- shared-bindings/displayio/Bitmap.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index a6bccc6298..458a73c3b1 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -212,8 +212,9 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg displayio_bitmap_t *self = MP_OBJ_TO_PTR(pos_args[0]); - int16_t x = args[ARG_x].u_int; - int16_t y = args[ARG_y].u_int; + // Check x,y are within self (target) bitmap boundary + int16_t x = mp_arg_validate_int_range(args[ARG_x].u_int, 0, self->width - 1, MP_QSTR_x); + int16_t y = mp_arg_validate_int_range(args[ARG_y].u_int, 0, self->height - 1, MP_QSTR_y); displayio_bitmap_t *source = mp_arg_validate_type(args[ARG_source].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap); @@ -223,32 +224,21 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg mp_raise_ValueError(translate("source palette too large")); } - int16_t x1 = args[ARG_x1].u_int; - int16_t y1 = args[ARG_y1].u_int; + // Check x1,y1,x2,y2 are within source bitmap boundary + int16_t x1 = mp_arg_validate_int_range(args[ARG_x1].u_int, 0, source->width - 1, MP_QSTR_x1); + int16_t y1 = mp_arg_validate_int_range(args[ARG_y1].u_int, 0, source->height - 1, MP_QSTR_y1); int16_t x2, y2; // if x2 or y2 is None, then set as the maximum size of the source bitmap if (args[ARG_x2].u_obj == mp_const_none) { x2 = source->width; } else { - x2 = mp_obj_get_int(args[ARG_x2].u_obj); + x2 = mp_arg_validate_int_range(mp_obj_get_int(args[ARG_x2].u_obj), 0, source->width, MP_QSTR_x2); } // int16_t y2; if (args[ARG_y2].u_obj == mp_const_none) { y2 = source->height; } else { - y2 = mp_obj_get_int(args[ARG_y2].u_obj); - } - - // Check x,y are within self (target) bitmap boundary - if ((x < 0) || (y < 0) || (x > self->width) || (y > self->height)) { - mp_raise_ValueError(translate("out of range of target")); - } - // Check x1,y1,x2,y2 are within source bitmap boundary - if ((x1 < 0) || (x1 > source->width) || - (y1 < 0) || (y1 > source->height) || - (x2 < 0) || (x2 > source->width) || - (y2 < 0) || (y2 > source->height)) { - mp_raise_ValueError(translate("out of range of source")); + y2 = mp_arg_validate_int_range(mp_obj_get_int(args[ARG_y2].u_obj), 0, source->height, MP_QSTR_y2); } // Ensure x1 < x2 and y1 < y2 From bb4cccc1cda1573889097ee0c596e27686a794bf Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 10 Feb 2023 17:26:01 -0600 Subject: [PATCH 004/225] use range instead of min where applicable to consolodate bounds checks --- shared-bindings/displayio/Bitmap.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 458a73c3b1..0efa801a7d 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -148,21 +148,15 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val } else { mp_obj_t *items; mp_obj_get_array_fixed_n(index_obj, 2, &items); - x = mp_arg_validate_int_min(mp_obj_get_int(items[0]), 0, MP_QSTR_x); - y = mp_arg_validate_int_min(mp_obj_get_int(items[1]), 0, MP_QSTR_y); - if (x >= common_hal_displayio_bitmap_get_width(self) || y >= common_hal_displayio_bitmap_get_height(self)) { - mp_raise_IndexError(translate("pixel coordinates out of bounds")); - } + x = mp_arg_validate_int_range(mp_obj_get_int(items[0]), 0, self->width - 1, MP_QSTR_x); + y = mp_arg_validate_int_range(mp_obj_get_int(items[1]), 0, self->height - 1, MP_QSTR_y); } if (value_obj == MP_OBJ_SENTINEL) { // load return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_bitmap_get_pixel(self, x, y)); } else { - mp_uint_t value = (mp_uint_t)mp_obj_get_int(value_obj); - if ((value >> common_hal_displayio_bitmap_get_bits_per_value(self)) != 0) { - mp_raise_ValueError(translate("pixel value requires too many bits")); - } + mp_uint_t value = (mp_uint_t)mp_arg_validate_int_range(mp_obj_get_int(value_obj), 0,(1u << common_hal_displayio_bitmap_get_bits_per_value(self)) - 1, MP_QSTR_value); common_hal_displayio_bitmap_set_pixel(self, x, y, value); } return mp_const_none; @@ -276,10 +270,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 1, displayio_bitmap_obj_bl STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); - mp_uint_t value = (mp_uint_t)mp_arg_validate_int_min(mp_obj_get_int(value_obj), 0, MP_QSTR_value); - if ((value >> common_hal_displayio_bitmap_get_bits_per_value(self)) != 0) { - mp_raise_ValueError(translate("pixel value requires too many bits")); - } + mp_uint_t value = (mp_uint_t)mp_arg_validate_int_range(mp_obj_get_int(value_obj), 0,(1u << common_hal_displayio_bitmap_get_bits_per_value(self)) - 1,MP_QSTR_value); common_hal_displayio_bitmap_fill(self, value); return mp_const_none; From 67fd815e27581a1a758de68943cd64717e856021 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 10 Feb 2023 17:39:38 -0600 Subject: [PATCH 005/225] maximum value validation for bitmap constructor --- shared-bindings/displayio/Bitmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 0efa801a7d..566bee954c 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -62,9 +62,9 @@ //| ... STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 3, 3, false); - uint32_t width = mp_arg_validate_int_min(mp_obj_get_int(all_args[0]), 1, MP_QSTR_width); - uint32_t height = mp_arg_validate_int_min(mp_obj_get_int(all_args[1]), 1, MP_QSTR_height); - uint32_t value_count = mp_arg_validate_int_min(mp_obj_get_int(all_args[2]), 1, MP_QSTR_value_count); + uint32_t width = mp_arg_validate_int_range(mp_obj_get_int(all_args[0]), 1, 32767, MP_QSTR_width); + uint32_t height = mp_arg_validate_int_range(mp_obj_get_int(all_args[1]), 1, 32767, MP_QSTR_height); + uint32_t value_count = mp_arg_validate_int_range(mp_obj_get_int(all_args[2]), 1, 32767, MP_QSTR_value_count); uint32_t bits = 1; while ((value_count - 1) >> bits) { From 5f3f87e371c7cc0d83817308375ab58e3d329210 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 10 Feb 2023 18:05:07 -0600 Subject: [PATCH 006/225] validate palette color count and group scale --- shared-bindings/displayio/Group.c | 2 +- shared-bindings/displayio/Palette.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 3e4569b271..24064a74c1 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -56,7 +56,7 @@ STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_arg mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - mp_int_t scale = mp_arg_validate_int_min(args[ARG_scale].u_int, 1, MP_QSTR_scale); + mp_int_t scale = mp_arg_validate_int_range(args[ARG_scale].u_int, 1, 32767,MP_QSTR_scale); displayio_group_t *self = m_new_obj(displayio_group_t); self->base.type = &displayio_group_type; diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index aa24dc262f..804b9ff034 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -58,7 +58,7 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a displayio_palette_t *self = m_new_obj(displayio_palette_t); self->base.type = &displayio_palette_type; - common_hal_displayio_palette_construct(self, args[ARG_color_count].u_int); + common_hal_displayio_palette_construct(self, mp_arg_validate_int_range(args[ARG_color_count].u_int, 1, 32767, MP_QSTR_color_count)); return MP_OBJ_FROM_PTR(self); } From 694537acb323314a25a802e53c4c34be5c6ced73 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 18 Feb 2023 10:35:39 -0600 Subject: [PATCH 007/225] change validation maximum computation --- shared-bindings/displayio/Bitmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 566bee954c..e14ac638e2 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -156,7 +156,9 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val // load return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_bitmap_get_pixel(self, x, y)); } else { - mp_uint_t value = (mp_uint_t)mp_arg_validate_int_range(mp_obj_get_int(value_obj), 0,(1u << common_hal_displayio_bitmap_get_bits_per_value(self)) - 1, MP_QSTR_value); + mp_uint_t value = (mp_uint_t)mp_arg_validate_int_range( + mp_obj_get_int(value_obj), 0, + (UINT32_MAX >> (32 - common_hal_displayio_bitmap_get_bits_per_value(self))), MP_QSTR_value); common_hal_displayio_bitmap_set_pixel(self, x, y, value); } return mp_const_none; From 3601bb3062735e12e9666e0bd1c0f730ab831f33 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 20 Feb 2023 20:37:42 -0600 Subject: [PATCH 008/225] change value_count max --- shared-bindings/displayio/Bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index e14ac638e2..c2431699b2 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -64,7 +64,7 @@ STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_ar mp_arg_check_num(n_args, n_kw, 3, 3, false); uint32_t width = mp_arg_validate_int_range(mp_obj_get_int(all_args[0]), 1, 32767, MP_QSTR_width); uint32_t height = mp_arg_validate_int_range(mp_obj_get_int(all_args[1]), 1, 32767, MP_QSTR_height); - uint32_t value_count = mp_arg_validate_int_range(mp_obj_get_int(all_args[2]), 1, 32767, MP_QSTR_value_count); + uint32_t value_count = mp_arg_validate_int_range(mp_obj_get_int(all_args[2]), 1, 65535, MP_QSTR_value_count); uint32_t bits = 1; while ((value_count - 1) >> bits) { From 7740cbac97a312f5932ad0731b46ad5ad8398a23 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 4 Mar 2023 13:13:59 -0600 Subject: [PATCH 009/225] do background tasks and handle interrupt during boundary fill --- shared-module/bitmaptools/__init__.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index dbf5a9ef96..6354dd508a 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "shared/runtime/interrupt_char.h" #include "shared-bindings/bitmaptools/__init__.h" #include "shared-bindings/displayio/Bitmap.h" #include "shared-bindings/displayio/Palette.h" @@ -376,6 +377,10 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination, } mp_obj_list_get(fill_area, &list_length, &fill_points); + RUN_BACKGROUND_TASKS; + if (mp_hal_is_interrupted()) { + return; + } } // set dirty the area so displayio will draw From 08c9eb9f00a4c88d0a81f9b6d5e4298d021ca74c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 4 Mar 2023 14:40:06 -0500 Subject: [PATCH 010/225] be more careful when setting socket to non-blocking --- ports/espressif/common-hal/socketpool/Socket.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ports/espressif/common-hal/socketpool/Socket.c b/ports/espressif/common-hal/socketpool/Socket.c index 8b6cff30ef..19e83e717f 100644 --- a/ports/espressif/common-hal/socketpool/Socket.c +++ b/ports/espressif/common-hal/socketpool/Socket.c @@ -253,9 +253,7 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_ uint64_t start_ticks = supervisor_ticks_ms64(); // Allow timeouts and interrupts - while (newsoc == -1 && - !timed_out && - !mp_hal_is_interrupted()) { + while (newsoc == -1 && !timed_out) { if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) { timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; } @@ -267,9 +265,6 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_ } } - // New client socket will not be non-blocking by default, so make it non-blocking. - lwip_fcntl(newsoc, F_SETFL, O_NONBLOCK); - if (!timed_out) { // harmless on failure but avoiding memcpy is faster memcpy((void *)ip, (void *)&accept_addr.sin_addr.s_addr, sizeof(accept_addr.sin_addr.s_addr)); @@ -280,6 +275,10 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_ if (newsoc < 0) { return -MP_EBADF; } + + // We got a socket. New client socket will not be non-blocking by default, so make it non-blocking. + lwip_fcntl(newsoc, F_SETFL, O_NONBLOCK); + if (!register_open_socket(newsoc)) { lwip_close(newsoc); return -MP_EBADF; From a2514ca3049cb90a38fcacd8a7d089923b969e64 Mon Sep 17 00:00:00 2001 From: Phillip Burgess Date: Wed, 8 Mar 2023 11:37:51 -0800 Subject: [PATCH 011/225] Add board adafruit_feather_rp2040_dvi Based on Feather RP2040 SCORPIO, but new USB PID (from MBAdafruitBoards/Production) and pin name changes for GP16-23 (CKN/CKP etc., from board schematic). --- .../adafruit_feather_rp2040_dvi/board.c | 29 +++++++++++ .../mpconfigboard.h | 14 ++++++ .../mpconfigboard.mk | 9 ++++ .../pico-sdk-configboard.h | 4 ++ .../boards/adafruit_feather_rp2040_dvi/pins.c | 48 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/board.c create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/board.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/board.c new file mode 100644 index 0000000000..331653173e --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/board.c @@ -0,0 +1,29 @@ +/* + * 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" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h new file mode 100644 index 0000000000..06cfaf37f6 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h @@ -0,0 +1,14 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040 DVI" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO16) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO8) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.mk new file mode 100644 index 0000000000..a60ff7b9a7 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x8128 +USB_PRODUCT = "Feather RP2040 DVI" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pico-sdk-configboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c new file mode 100644 index 0000000000..b352cd96e2 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c @@ -0,0 +1,48 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { 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_D24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_CKN), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_CKP), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D0N), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D0P), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_D1N), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_D1P), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D2N), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_D2P), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); From de3c5ad2f4c71170bb7f5e1e94c4159ef9f07cf2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Mar 2023 11:00:55 -0500 Subject: [PATCH 012/225] add blank lines around aliased pins --- ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c index b352cd96e2..f8618cd6d1 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c @@ -12,10 +12,13 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, @@ -27,6 +30,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, From a2cb953eac8f77223595f420432da79328af5b95 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Mar 2023 13:09:45 -0600 Subject: [PATCH 013/225] Fix for issue #7054 by avoiding recursive calls to websocket_background. --- supervisor/shared/web_workflow/websocket.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/supervisor/shared/web_workflow/websocket.c b/supervisor/shared/web_workflow/websocket.c index 7612066fa6..e55e09b3e7 100644 --- a/supervisor/shared/web_workflow/websocket.c +++ b/supervisor/shared/web_workflow/websocket.c @@ -52,6 +52,8 @@ typedef struct { // interrupt character. STATIC ringbuf_t _incoming_ringbuf; STATIC uint8_t _buf[16]; +// make sure background is not called recursively +STATIC bool in_web_background = false; static _websocket cp_serial; @@ -244,6 +246,10 @@ void websocket_background(void) { if (!websocket_connected()) { return; } + if (in_web_background) { + return; + } + in_web_background = true; uint8_t c; while (ringbuf_num_empty(&_incoming_ringbuf) > 0 && _read_next_payload_byte(&c)) { @@ -253,4 +259,5 @@ void websocket_background(void) { } ringbuf_put(&_incoming_ringbuf, c); } + in_web_background = false; } From 2ebc0ea51ca22a0e32d1d2d2ead7000bca971bfa Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Mar 2023 11:30:38 -0500 Subject: [PATCH 014/225] GitHub online editor introduced spaces on blank lines :( --- ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c index f8618cd6d1..e014ace05a 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c @@ -15,10 +15,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, - + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, - + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, From ec2101f4aa5a94d3592a9fedd1672ec896d28463 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Mar 2023 13:18:54 -0500 Subject: [PATCH 015/225] update tinyusb to latest --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 73896a3b71..990fb6ae5c 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 73896a3b71c525a3ee4cefa7e35ce3b3a93786ef +Subproject commit 990fb6ae5c4d9d4b77c5a9ecb3a2abe899dd2712 From 0f31ba676b187d2d641eabb8cce4a298cea3ae8e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Mar 2023 17:40:53 -0500 Subject: [PATCH 016/225] update errata fixes for RP2040 --- ports/raspberrypi/sdk_config/pico/config_autogen.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/raspberrypi/sdk_config/pico/config_autogen.h b/ports/raspberrypi/sdk_config/pico/config_autogen.h index a29ccb458a..ee99b1c609 100644 --- a/ports/raspberrypi/sdk_config/pico/config_autogen.h +++ b/ports/raspberrypi/sdk_config/pico/config_autogen.h @@ -18,6 +18,8 @@ #define PICO_NO_HARDWARE (0) #define PICO_ON_DEVICE (1) #define PICO_PRINTF_ALWAYS_INCLUDED (1) +#define PICO_RP2040_USB_DEVICE_ENUMERATION_FIX (1) +#define PICO_RP2040_USB_DEVICE_UFRAME_FIX (1) #define PICO_STDIO_IGNORE_NESTED_STDOUT (0) #define PICO_USE_CRT_PRINTF (0) #define PICO_USE_OPTIMISTIC_SBRK (0) From 7f10f36dfbe4b5f48371e40e66157236b696f102 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Mar 2023 23:18:58 -0500 Subject: [PATCH 017/225] usbh_control.c no longer exists --- supervisor/supervisor.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 801025f41a..c461c5353f 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -163,7 +163,6 @@ ifeq ($(CIRCUITPY_USB),1) SRC_SUPERVISOR += \ lib/tinyusb/src/host/hub.c \ lib/tinyusb/src/host/usbh.c \ - lib/tinyusb/src/host/usbh_control.c \ endif endif From 5cb21539f295d3537a80bbf4c33266a9feab6642 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 10 Mar 2023 13:12:37 -0500 Subject: [PATCH 018/225] use revised USB host API on mimxrt10xx --- shared-module/usb/core/Device.c | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/shared-module/usb/core/Device.c b/shared-module/usb/core/Device.c index 81431d5d7a..706c94eec3 100644 --- a/shared-module/usb/core/Device.c +++ b/shared-module/usb/core/Device.c @@ -61,12 +61,9 @@ uint16_t common_hal_usb_core_device_get_idProduct(usb_core_device_obj_t *self) { } STATIC xfer_result_t _get_string_result; -STATIC bool _transfer_done_cb(uint8_t daddr, tusb_control_request_t const *request, xfer_result_t result) { - // Store the result so we stop waiting for the transfer. We don't need the other data for now. - (void)daddr; - (void)request; - _get_string_result = result; - return true; +STATIC void _transfer_done_cb(tuh_xfer_t *xfer) { + // Store the result so we stop waiting for the transfer. + _get_string_result = xfer->result; } STATIC void _wait_for_callback(void) { @@ -89,7 +86,7 @@ STATIC mp_obj_t _get_string(const uint16_t *temp_buf) { mp_obj_t common_hal_usb_core_device_get_serial_number(usb_core_device_obj_t *self) { _get_string_result = 0xff; uint16_t temp_buf[127]; - if (!tuh_descriptor_string_serial_get(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb)) { + if (!tuh_descriptor_get_serial_string(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb, 0)) { return mp_const_none; } _wait_for_callback(); @@ -99,7 +96,7 @@ mp_obj_t common_hal_usb_core_device_get_serial_number(usb_core_device_obj_t *sel mp_obj_t common_hal_usb_core_device_get_product(usb_core_device_obj_t *self) { _get_string_result = 0xff; uint16_t temp_buf[127]; - if (!tuh_descriptor_string_product_get(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb)) { + if (!tuh_descriptor_get_product_string(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb, 0)) { return mp_const_none; } _wait_for_callback(); @@ -109,7 +106,7 @@ mp_obj_t common_hal_usb_core_device_get_product(usb_core_device_obj_t *self) { mp_obj_t common_hal_usb_core_device_get_manufacturer(usb_core_device_obj_t *self) { _get_string_result = 0xff; uint16_t temp_buf[127]; - if (!tuh_descriptor_string_manufacturer_get(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb)) { + if (!tuh_descriptor_get_manufacturer_string(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb, 0)) { return mp_const_none; } _wait_for_callback(); @@ -125,11 +122,8 @@ mp_obj_t common_hal_usb_core_device_read(usb_core_device_obj_t *self, mp_int_t e } xfer_result_t control_result; -STATIC bool _control_complete_cb(uint8_t dev_addr, tusb_control_request_t const *request, xfer_result_t result) { - (void)dev_addr; - (void)request; - control_result = result; - return true; +STATIC void _control_complete_cb(tuh_xfer_t *xfer) { + control_result = xfer->result; } mp_int_t common_hal_usb_core_device_ctrl_transfer(usb_core_device_obj_t *self, @@ -145,11 +139,17 @@ mp_int_t common_hal_usb_core_device_ctrl_transfer(usb_core_device_obj_t *self, .wIndex = wIndex, .wLength = len }; + tuh_xfer_t xfer = { + .daddr = self->device_number, + .ep_addr = 0, + .setup = &request, + .buffer = buffer, + .complete_cb = _control_complete_cb, + }; + control_result = XFER_RESULT_STALLED; - bool result = tuh_control_xfer(self->device_number, - &request, - buffer, - _control_complete_cb); + + bool result = tuh_control_xfer(&xfer); if (!result) { mp_raise_usb_core_USBError(NULL); } From a6400fb08ae896f5c71989ac47bf5ea803faeb70 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Sat, 11 Mar 2023 00:14:36 +0530 Subject: [PATCH 019/225] use intersection of changes per commit and merge ref --- .github/workflows/build.yml | 5 ---- tools/ci_set_matrix.py | 46 ++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4383153fd1..150c2364ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,16 +80,11 @@ jobs: run: git cat-file -e $SHA && echo "BASE_SHA=$SHA" >> $GITHUB_ENV || true env: SHA: ${{ github.event.before }} - - name: Get changes - id: get-changes - if: env.BASE_SHA && env.HEAD_SHA - run: echo $(git diff $BASE_SHA...$HEAD_SHA --name-only) | echo "changed_files=[\"$(sed "s/ /\", \"/g")\"]" >> $GITHUB_OUTPUT - name: Set matrix id: set-matrix run: python3 -u ci_set_matrix.py working-directory: tools env: - CHANGED_FILES: ${{ steps.get-changes.outputs.changed_files }} LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }} tests: diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index b5618aec2f..3cd0dbf56f 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -68,25 +68,43 @@ PATTERN_WINDOWS = [ "tools/", ] + +def git_diff(pattern: str): + return ( + subprocess.run( + f"git diff {pattern} --name-only", + capture_output=True, + shell=True, + ) + .stdout.decode("utf-8") + .split("\n")[:-1] + ) + + if len(sys.argv) > 1: print("Using files list on commandline") changed_files = sys.argv[1:] - last_failed_jobs = {} +elif os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA"): + print("Using files list by computing diff") + changed_files = git_diff("$BASE_SHA...$HEAD_SHA") + if os.environ.get("GITHUB_EVENT_NAME") == "pull_request": + changed_files = list(set(changed_files).intersection(git_diff("$HEAD_SHA~...$HEAD_SHA"))) else: - c = os.environ["CHANGED_FILES"] - if c == "": - print("CHANGED_FILES is in environment, but value is empty") - changed_files = [] - else: - print("Using files list in CHANGED_FILES") - changed_files = json.loads(c.replace("\\", "")) + print("Using files list in CHANGED_FILES") + changed_files = json.loads(os.environ.get("CHANGED_FILES") or "[]") - j = os.environ["LAST_FAILED_JOBS"] - if j == "": - print("LAST_FAILED_JOBS is in environment, but value is empty") - last_failed_jobs = {} - else: - last_failed_jobs = json.loads(j) +print("Using jobs list in LAST_FAILED_JOBS") +last_failed_jobs = json.loads(os.environ.get("LAST_FAILED_JOBS") or "{}") + + +def print_enclosed(title, content): + print("::group::" + title) + print(content) + print("::endgroup::") + + +print_enclosed("LOG: changed_files", changed_files) +print_enclosed("LOG: last_failed_jobs", last_failed_jobs) def set_output(name: str, value): From a651696c5c5bfdb945c06645963f3b56ad0cc9eb Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 10 Mar 2023 23:07:29 -0500 Subject: [PATCH 020/225] pick up latest tinyusb changes --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 990fb6ae5c..be21413361 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 990fb6ae5c4d9d4b77c5a9ecb3a2abe899dd2712 +Subproject commit be214133615684327b114a5f167cd052841c3acf From 29cee603d32b8f7854626b8aaa90b54d5c420828 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Sat, 11 Mar 2023 11:56:04 +0530 Subject: [PATCH 021/225] update `.readthedocs.yml` and add it to docs pattern --- .readthedocs.yml | 2 +- tools/ci_set_matrix.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 29a915766f..8f1b89cb67 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -14,7 +14,7 @@ build: python: "3" jobs: post_install: - - python tools/ci_fetch_deps.py build-doc + - python tools/ci_fetch_deps.py docs formats: - pdf diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index 3cd0dbf56f..5d7e3a477b 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -52,7 +52,7 @@ IGNORE_DIRS = ["tests", "docs", ".devcontainer"] PATTERN_DOCS = ( r"^(?:\.github|docs|extmod\/ulab)|" - r"^(?:(?:ports\/\w+\/bindings|shared-bindings)\S+\.c|tools\/extract_pyi\.py|conf\.py|requirements-doc\.txt)$|" + r"^(?:(?:ports\/\w+\/bindings|shared-bindings)\S+\.c|tools\/extract_pyi\.py|\.readthedocs\.yml|conf\.py|requirements-doc\.txt)$|" r"(?:-stubs|\.(?:md|MD|rst|RST))$" ) From ec74be7cb42071c5d9e0cc0bdaf4ed260afc91ae Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Sat, 11 Mar 2023 14:00:29 +0530 Subject: [PATCH 022/225] use set for `changed_files` and minor updates --- tools/ci_set_matrix.py | 49 +++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index 5d7e3a477b..c38ef29ecc 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -42,13 +42,15 @@ from shared_bindings_matrix import ( all_ports_all_boards, ) -IGNORE = [ - "tools/ci_set_matrix.py", +# Files that never influence board builds +IGNORE_BOARD = { + ".devcontainer", + "docs", + "tests", + "tools/ci_changes_per_commit.py", "tools/ci_check_duplicate_usb_vid_pid.py", -] - -# Files in these directories never influence board builds -IGNORE_DIRS = ["tests", "docs", ".devcontainer"] + "tools/ci_set_matrix.py", +} PATTERN_DOCS = ( r"^(?:\.github|docs|extmod\/ulab)|" @@ -56,21 +58,20 @@ PATTERN_DOCS = ( r"(?:-stubs|\.(?:md|MD|rst|RST))$" ) -PATTERN_WINDOWS = [ +PATTERN_WINDOWS = { ".github/", "extmod/", "lib/", "mpy-cross/", "ports/unix/", - "ports/windows/", "py/", - "requirements", "tools/", -] + "requirements-dev.txt", +} def git_diff(pattern: str): - return ( + return set( subprocess.run( f"git diff {pattern} --name-only", capture_output=True, @@ -83,15 +84,15 @@ def git_diff(pattern: str): if len(sys.argv) > 1: print("Using files list on commandline") - changed_files = sys.argv[1:] + changed_files = set(sys.argv[1:]) elif os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA"): print("Using files list by computing diff") changed_files = git_diff("$BASE_SHA...$HEAD_SHA") if os.environ.get("GITHUB_EVENT_NAME") == "pull_request": - changed_files = list(set(changed_files).intersection(git_diff("$HEAD_SHA~...$HEAD_SHA"))) + changed_files.intersection_update(git_diff("$HEAD_SHA~...$HEAD_SHA")) else: print("Using files list in CHANGED_FILES") - changed_files = json.loads(os.environ.get("CHANGED_FILES") or "[]") + changed_files = set(json.loads(os.environ.get("CHANGED_FILES") or "[]")) print("Using jobs list in LAST_FAILED_JOBS") last_failed_jobs = json.loads(os.environ.get("LAST_FAILED_JOBS") or "{}") @@ -103,8 +104,8 @@ def print_enclosed(title, content): print("::endgroup::") -print_enclosed("LOG: changed_files", changed_files) -print_enclosed("LOG: last_failed_jobs", last_failed_jobs) +print_enclosed("Log: changed_files", changed_files) +print_enclosed("Log: last_failed_jobs", last_failed_jobs) def set_output(name: str, value): @@ -173,11 +174,7 @@ def set_boards(build_all: bool): boards_to_build.update(port_to_boards[port]) continue - # Check the ignore list to see if the file isn't used on board builds. - if p in IGNORE: - continue - - if any([p.startswith(d) for d in IGNORE_DIRS]): + if any([p.startswith(d) for d in IGNORE_BOARD]): continue # As a (nearly) last resort, for some certain files, we compute the settings from the @@ -287,7 +284,9 @@ def set_windows(build_windows: bool): else: for file in changed_files: for pattern in PATTERN_WINDOWS: - if file.startswith(pattern): + if file.startswith(pattern) and not any( + [file.startswith(d) for d in IGNORE_BOARD] + ): build_windows = True break else: @@ -302,11 +301,7 @@ def set_windows(build_windows: bool): def main(): # Build all if no changed files build_all = not changed_files - print( - "Building all docs/boards" - if build_all - else "Adding docs/boards to build based on changed files" - ) + print("Running: " + ("all" if build_all else "conditionally")) # Set jobs set_docs(build_all) From 3a4bffdd6505dac0a7fda88070b6484f67fb1708 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Sun, 12 Mar 2023 09:42:16 +0530 Subject: [PATCH 023/225] use correct commits for diff --- .github/workflows/build.yml | 6 ++---- tools/ci_set_matrix.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 150c2364ae..e322004515 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,11 +67,9 @@ jobs: run: echo "HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV - name: Set base sha (pull) if: github.event_name == 'pull_request' - run: | - git fetch --no-tags --no-recurse-submodules --depth=$((DEPTH + 1)) origin $HEAD_SHA - echo "BASE_SHA=$(git rev-list $HEAD_SHA --skip=$DEPTH --max-count=1)" >> $GITHUB_ENV + run: git cat-file -e $SHA && echo "BASE_SHA=$SHA" >> $GITHUB_ENV || true env: - DEPTH: ${{ steps.get-last-commit-with-checks.outputs.commit_depth || github.event.pull_request.commits }} + SHA: ${{ steps.get-last-commit-with-checks.outputs.commit_sha || github.event.pull_request.base.sha }} - name: Set head sha (push) if: github.event_name == 'push' run: echo "HEAD_SHA=${{ github.event.after }}" >> $GITHUB_ENV diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index c38ef29ecc..fa53c81829 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -89,7 +89,7 @@ elif os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA"): print("Using files list by computing diff") changed_files = git_diff("$BASE_SHA...$HEAD_SHA") if os.environ.get("GITHUB_EVENT_NAME") == "pull_request": - changed_files.intersection_update(git_diff("$HEAD_SHA~...$HEAD_SHA")) + changed_files.intersection_update(git_diff("$GITHUB_SHA~...$GITHUB_SHA")) else: print("Using files list in CHANGED_FILES") changed_files = set(json.loads(os.environ.get("CHANGED_FILES") or "[]")) From daa927a114148904f82604f4fb47aca84cb00df2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 12 Mar 2023 14:02:38 -0400 Subject: [PATCH 024/225] switch STM to dwc2 USB --- ports/stm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm/Makefile b/ports/stm/Makefile index 325b13b1bc..d6afeb5f29 100755 --- a/ports/stm/Makefile +++ b/ports/stm/Makefile @@ -215,7 +215,7 @@ ifneq ($(CIRCUITPY_AUDIOBUSIO_PDMIN),0) endif ifneq ($(CIRCUITPY_USB),0) -SRC_C += lib/tinyusb/src/portable/st/synopsys/dcd_synopsys.c +SRC_C += lib/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c endif SRC_S = \ From 49e9ea2e9aa77060275b764d064d025a29b43712 Mon Sep 17 00:00:00 2001 From: Matthias Kreier <43933271+kreier@users.noreply.github.com> Date: Mon, 13 Mar 2023 15:17:55 +0700 Subject: [PATCH 025/225] add missing pins 4, 36 and 39 - and 4 aliases The original list left D4 (GPIO4), VN (GPIO39) and VP (GPIO36) out. Added aliases for 1, 3, 16 and 17 with their GPIO names, even though they won't be used as such since they are UART0 and UART2 --- ports/espressif/boards/doit_esp32_devkit_v1/pins.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ports/espressif/boards/doit_esp32_devkit_v1/pins.c b/ports/espressif/boards/doit_esp32_devkit_v1/pins.c index 78c37897ac..673728e9f3 100644 --- a/ports/espressif/boards/doit_esp32_devkit_v1/pins.c +++ b/ports/espressif/boards/doit_esp32_devkit_v1/pins.c @@ -3,9 +3,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - // External pins are in silkscreen order, from top to bottom, left side, then right side + // External pins are in silkscreen order, from top to bottom, left side {MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15)}, {MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2)}, + {MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4)}, {MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_GPIO16)}, {MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_GPIO17)}, {MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5)}, @@ -16,6 +17,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { {MP_ROM_QSTR(MP_QSTR_TX0), MP_ROM_PTR(&pin_GPIO3)}, {MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO22)}, {MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO23)}, + // External pins are in silkscreen order, from top to bottom, right side {MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13)}, {MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12)}, {MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14)}, @@ -26,6 +28,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { {MP_ROM_QSTR(MP_QSTR_D32), MP_ROM_PTR(&pin_GPIO32)}, {MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35)}, {MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34)}, + {MP_ROM_QSTR(MP_QSTR_VN), MP_ROM_PTR(&pin_GPIO39)}, + {MP_ROM_QSTR(MP_QSTR_VP), MP_ROM_PTR(&pin_GPIO36)}, {MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2)}, @@ -38,6 +42,11 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { {MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO17)}, {MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO16)}, + + {MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1)}, + {MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3)}, + {MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16)}, + {MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17)}, {MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj)}, {MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj)}, From f5b8b8d6f22eed5e36499060d085eb88812a35ca Mon Sep 17 00:00:00 2001 From: Matthias Kreier <43933271+kreier@users.noreply.github.com> Date: Mon, 13 Mar 2023 15:30:52 +0700 Subject: [PATCH 026/225] tailing whitespace removed (pre-commit run failed) --- ports/espressif/boards/doit_esp32_devkit_v1/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/doit_esp32_devkit_v1/pins.c b/ports/espressif/boards/doit_esp32_devkit_v1/pins.c index 673728e9f3..8381fa0644 100644 --- a/ports/espressif/boards/doit_esp32_devkit_v1/pins.c +++ b/ports/espressif/boards/doit_esp32_devkit_v1/pins.c @@ -42,7 +42,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { {MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO17)}, {MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO16)}, - + {MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1)}, {MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3)}, {MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16)}, From b432cf62019d40b103e1cba6fbfecb5813cd61a7 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 13 Mar 2023 21:49:01 +0700 Subject: [PATCH 027/225] fix rp2040 with new shared irq usb handler --- ports/raspberrypi/supervisor/usb.c | 11 ++--------- supervisor/shared/usb/usb.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ports/raspberrypi/supervisor/usb.c b/ports/raspberrypi/supervisor/usb.c index d0e9b2e466..fb4f72134d 100644 --- a/ports/raspberrypi/supervisor/usb.c +++ b/ports/raspberrypi/supervisor/usb.c @@ -39,15 +39,8 @@ STATIC void _usb_irq_wrapper(void) { } void post_usb_init(void) { - irq_set_enabled(USBCTRL_IRQ, false); - - irq_handler_t usb_handler = irq_get_exclusive_handler(USBCTRL_IRQ); - if (usb_handler) { - irq_remove_handler(USBCTRL_IRQ, usb_handler); - } - irq_set_exclusive_handler(USBCTRL_IRQ, _usb_irq_wrapper); - - irq_set_enabled(USBCTRL_IRQ, true); + irq_add_shared_handler(USBCTRL_IRQ, _usb_irq_wrapper, + PICO_SHARED_IRQ_HANDLER_LOWEST_ORDER_PRIORITY); // There is a small window where the USB interrupt may be handled by the // pico-sdk instead of CircuitPython. If that is the case, then we'll have diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index fa85cddb83..5ac8454312 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -225,13 +225,17 @@ void usb_background_schedule(void) { } void usb_irq_handler(int instance) { + #if CFG_TUSB_MCU != OPT_MCU_RP2040 + // For rp2040, IRQ handler is already installed and invoked automatically if (instance == CIRCUITPY_USB_DEVICE_INSTANCE) { tud_int_handler(instance); - } else if (instance == CIRCUITPY_USB_HOST_INSTANCE) { - #if CIRCUITPY_USB_HOST - tuh_int_handler(instance); - #endif } + #if CIRCUITPY_USB_HOST + else if (instance == CIRCUITPY_USB_HOST_INSTANCE) { + tuh_int_handler(instance); + } + #endif + #endif usb_background_schedule(); } From d85970b7a2cfb0aeb4d89575d839c91ce3e6d1ad Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 13 Mar 2023 17:53:32 -0400 Subject: [PATCH 028/225] update TinyUSB again for latest changes --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index be21413361..7cf67b2845 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit be214133615684327b114a5f167cd052841c3acf +Subproject commit 7cf67b28456f6cb8738956bd6af1fd2b8300de4f From 2497b3ea7a67c7371a857deae32ca4a5ed572dff Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 13 Mar 2023 22:11:02 -0400 Subject: [PATCH 029/225] update tinyusb --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 7cf67b2845..ea8ecea59a 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 7cf67b28456f6cb8738956bd6af1fd2b8300de4f +Subproject commit ea8ecea59aa60a1028cce16b0f15bb33918b11af From d4840cbf1022f447d2fa76eac4f40c4257425e9a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 14 Mar 2023 13:13:58 -0400 Subject: [PATCH 030/225] translate() messages must be one string --- ports/espressif/common-hal/espcamera/Camera.c | 3 +-- shared-bindings/pwmio/PWMOut.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ports/espressif/common-hal/espcamera/Camera.c b/ports/espressif/common-hal/espcamera/Camera.c index e3e5ef49f9..574b4e846b 100644 --- a/ports/espressif/common-hal/espcamera/Camera.c +++ b/ports/espressif/common-hal/espcamera/Camera.c @@ -79,8 +79,7 @@ void common_hal_espcamera_camera_construct( if (common_hal_espidf_get_reserved_psram() == 0) { mp_raise_msg(&mp_type_MemoryError, translate( - "espcamera.Camera requires reserved PSRAM to be configured. " - "See the documentation for instructions.")); + "espcamera.Camera requires reserved PSRAM to be configured. See the documentation for instructions.")); } for (int i = 0; i < 8; i++) { claim_pin_number(data_pins[i]); diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 24c0097c0c..784f87a025 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -271,8 +271,7 @@ STATIC mp_obj_t pwmio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t freque check_for_deinit(self); if (!common_hal_pwmio_pwmout_get_variable_frequency(self)) { mp_raise_AttributeError(translate( - "PWM frequency not writable when variable_frequency is False on " - "construction.")); + "PWM frequency not writable when variable_frequency is False on construction.")); } mp_int_t freq = mp_obj_get_int(frequency); if (freq == 0) { From 5ec586019ba5e293451534e5368769136493f2e9 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 14 Mar 2023 13:27:57 -0400 Subject: [PATCH 031/225] fix TimeAlarm signature --- shared-bindings/alarm/time/TimeAlarm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index abbb050c64..86c96de1d4 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -45,7 +45,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| """Trigger an alarm when the specified time is reached.""" //| //| def __init__( -//| self, monotonic_time: Optional[float] = None, epoch_time: Optional[int] = None +//| self, *, monotonic_time: Optional[float] = None, epoch_time: Optional[int] = None //| ) -> None: //| """Create an alarm that will be triggered when `time.monotonic()` would equal //| ``monotonic_time``, or when `time.time()` would equal ``epoch_time``. From 5bb8a7a7c68781e6edbd3aebaf7eeeecb310bd86 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 28 Feb 2023 15:07:35 -0800 Subject: [PATCH 032/225] Improve iMX RT performance * Enable dcache for OCRAM where the VM heap lives. * Add CIRCUITPY_SWO_TRACE for pushing program counters out over the SWO pin via the ITM module in the CPU. Exempt some functions from instrumentation to reduce traffic and allow inlining. * Place more functions in ITCM to handle errors using code in RAM-only and speed up CP. * Use SET and CLEAR registers for digitalio. The SDK does read, mask and write. * Switch to 2MiB reserved for CircuitPython code. Up from 1MiB. * Run USB interrupts during flash erase and write. * Allow storage writes from CP if the USB drive is disabled. * Get perf bench tests running on CircuitPython and increase timeouts so it works when instrumentation is active. --- ports/atmel-samd/Makefile | 2 +- ports/mimxrt10xx/Makefile | 15 +- ports/mimxrt10xx/background.c | 7 +- .../boards/imxrt1010_evk/mpconfigboard.h | 5 + ports/mimxrt10xx/boards/metro_m7_1011/board.c | 15 ++ .../boards/metro_m7_1011/flash_config.c | 4 +- .../common-hal/digitalio/DigitalInOut.c | 7 +- .../common-hal/microcontroller/__init__.c | 7 +- .../common-hal/neopixel_write/__init__.c | 8 +- ports/mimxrt10xx/linking/common.ld | 76 ++++++-- ports/mimxrt10xx/mpconfigport.mk | 2 + ports/mimxrt10xx/reset.c | 3 +- .../supervisor/flexspi_nor_flash_ops.c | 16 +- ports/mimxrt10xx/supervisor/internal_flash.c | 40 ++-- ports/mimxrt10xx/supervisor/internal_flash.h | 1 + ports/mimxrt10xx/supervisor/port.c | 172 ++++++++++++++---- ports/mimxrt10xx/supervisor/serial.c | 90 --------- ports/mimxrt10xx/supervisor/usb.c | 6 +- py/argcheck.c | 2 +- py/bc.c | 2 +- py/circuitpy_mpconfig.h | 12 ++ py/circuitpy_mpconfig.mk | 4 + py/gc.c | 8 +- py/mpconfig.h | 17 ++ py/obj.h | 74 ++++---- py/objdict.c | 4 +- py/objfun.c | 14 +- py/objproperty.c | 2 +- py/pystack.c | 2 +- py/pystack.h | 26 +-- py/qstr.c | 2 +- py/runtime.c | 61 ++++--- py/runtime.h | 12 +- py/stackctrl.c | 4 +- shared-bindings/digitalio/DigitalInOut.c | 2 +- shared-module/storage/__init__.c | 1 + supervisor/linker.h | 3 +- supervisor/shared/background_callback.c | 6 +- supervisor/shared/filesystem.c | 3 +- supervisor/shared/flash.c | 2 +- supervisor/shared/safe_mode.c | 5 +- supervisor/shared/status_bar.c | 4 +- supervisor/shared/translate/translate_impl.h | 4 +- supervisor/shared/usb/usb.c | 4 +- tests/perf_bench/benchrun.py | 2 +- tools/cortex-m-fault-gdb.py | 106 +++++++++++ tools/cpboard.py | 26 ++- tools/gen_display_resources.py | 10 +- tools/swo_function_trace.py | 143 +++++++++++++++ tools/swo_viewer.py | 67 +++++++ 50 files changed, 809 insertions(+), 301 deletions(-) delete mode 100644 ports/mimxrt10xx/supervisor/serial.c create mode 100644 tools/cortex-m-fault-gdb.py create mode 100644 tools/swo_function_trace.py create mode 100644 tools/swo_viewer.py diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 0ac326d3cc..5a4e5111da 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -366,7 +366,7 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE) $(STEPECHO) "LINK $@" $(Q)echo $(OBJ) > $(BUILD)/firmware.objs - $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--print-memory-usage -Wl,--start-group $(LIBS) -Wl,--end-group $(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index b38f120ee2..c561b894d3 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -49,7 +49,12 @@ INC += \ CFLAGS += -ftree-vrp -DNDEBUG # TinyUSB defines -CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX -DCFG_TUD_MIDI_RX_BUFSIZE=512 -DCFG_TUD_CDC_RX_BUFSIZE=512 -DCFG_TUD_MIDI_TX_BUFSIZE=512 -DCFG_TUD_CDC_TX_BUFSIZE=512 -DCFG_TUD_MSC_BUFSIZE=1024 +CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX -DCFG_TUD_CDC_RX_BUFSIZE=512 -DCFG_TUD_CDC_TX_BUFSIZE=512 +ifeq ($(CHIP_FAMILY), MIMXRT1011) +CFLAGS += -DCFG_TUD_MIDI_RX_BUFSIZE=64 -DCFG_TUD_MIDI_TX_BUFSIZE=64 -DCFG_TUD_MSC_BUFSIZE=512 +else +CFLAGS += -DCFG_TUD_MIDI_RX_BUFSIZE=512 -DCFG_TUD_MIDI_TX_BUFSIZE=512 -DCFG_TUD_MSC_BUFSIZE=1024 +endif #Debugging/Optimization # Never set -fno-inline because we use inline to move small functions into routines that must be @@ -76,11 +81,15 @@ CFLAGS += \ -g3 -Wno-unused-parameter \ -ffunction-sections -fdata-sections -fstack-usage -OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions +OPTIMIZATION_FLAGS ?= -O2 # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk CFLAGS += $(OPTIMIZATION_FLAGS) +ifeq ($(CIRCUITPY_SWO_TRACE), 1) + CFLAGS += -finstrument-functions -finstrument-functions-exclude-file-list=tinyusb -finstrument-functions-exclude-function-list='USB_OTG1_IRQHandler,usb_irq_handler,nlr_push,CLOCK_EnableClock,CLOCK_SetDiv,CLOCK_SetMux,__DMB,__ISB,__DSB,SCB_EnableICache,SCB_EnableDCache,ARM_MPU_Disable,ARM_MPU_Enable,SCB_DisableDCache,SCB_DisableICache,__enable_irq,__disable_irq,__set_MSP,port_get_raw_ticks,supervisor_ticks_ms64' +endif + LD_FILES = $(wildcard boards/$(BOARD)/*.ld) $(addprefix linking/, flash/$(FLASH).ld chip_family/$(CHIP_FAMILY).ld common.ld) LD_SCRIPT_FLAG := -Wl,-T, @@ -171,7 +180,7 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex $(BUILD)/firmware.elf: $(OBJ) $(LD_FILES) $(STEPECHO) "LINK $@" - $(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out %.ld, $^) -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out %.ld, $^) -Wl,--print-memory-usage -Wl,--start-group $(LIBS) -Wl,--end-group $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" diff --git a/ports/mimxrt10xx/background.c b/ports/mimxrt10xx/background.c index 5815c222b4..529f791a39 100644 --- a/ports/mimxrt10xx/background.c +++ b/ports/mimxrt10xx/background.c @@ -27,7 +27,11 @@ #include "supervisor/port.h" -void port_background_task(void) { +#include "supervisor/linker.h" + +#include "fsl_common.h" + +void PLACE_IN_ITCM(port_background_task)(void) { } void port_background_tick(void) { @@ -38,5 +42,6 @@ void port_background_tick(void) { void port_start_background_task(void) { } + void port_finish_background_task(void) { } diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h index 77d458d75b..192c265f88 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h @@ -16,3 +16,8 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO_09) #define DEFAULT_UART_BUS_TX (&pin_GPIO_10) + +#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO_09) +#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO_10) + +#define MICROPY_HW_LED_STATUS (&pin_GPIO_11) diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/board.c b/ports/mimxrt10xx/boards/metro_m7_1011/board.c index 27cbd3eb96..62be2303a5 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/board.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/board.c @@ -47,3 +47,18 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = { }; // Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. + +bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin) { + #if CIRCUITPY_SWO_TRACE + if (pin == &pin_GPIO_AD_09) { + IOMUXC_SetPinMux( /* Add these lines*/ + IOMUXC_GPIO_AD_09_ARM_TRACE_SWO, + 0U); + IOMUXC_SetPinConfig( /* Add these lines*/ + IOMUXC_GPIO_AD_09_ARM_TRACE_SWO, + 0x00F9U); + return true; + } + #endif + return false; +} diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c index b2894d7669..3477de9e34 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c @@ -10,7 +10,7 @@ #include "fsl_flexspi_nor_boot.h" -__attribute__((section(".boot_hdr.ivt"))) +__attribute__((section(".boot_hdr.ivt"),used)) /************************************* * IVT Data *************************************/ @@ -25,7 +25,7 @@ const ivt image_vector_table = { IVT_RSVD /* Reserved = 0 */ }; -__attribute__((section(".boot_hdr.boot_data"))) +__attribute__((section(".boot_hdr.boot_data"),used)) /************************************* * Boot Data *************************************/ diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c index 7639204bc6..d800de15de 100644 --- a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c @@ -118,7 +118,12 @@ digitalio_direction_t common_hal_digitalio_digitalinout_get_direction( void common_hal_digitalio_digitalinout_set_value( digitalio_digitalinout_obj_t *self, bool value) { - GPIO_PinWrite(self->pin->gpio, self->pin->number, value); + GPIO_Type *gpio = self->pin->gpio; + if (value) { + gpio->DR_SET = 1 << self->pin->number; + } else { + gpio->DR_CLEAR = 1 << self->pin->number; + } } bool common_hal_digitalio_digitalinout_get_value( diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 5388f404de..1b10b4d4ee 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -36,6 +36,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" +#include "supervisor/linker.h" #include "supervisor/shared/safe_mode.h" #include "supervisor/shared/translate/translate.h" @@ -43,14 +44,14 @@ void common_hal_mcu_delay_us(uint32_t delay) { mp_hal_delay_us(delay); } -volatile uint32_t nesting_count = 0; -void common_hal_mcu_disable_interrupts(void) { +volatile uint32_t PLACE_IN_DTCM_BSS(nesting_count) = 0; +void PLACE_IN_ITCM(common_hal_mcu_disable_interrupts)(void) { __disable_irq(); __DMB(); nesting_count++; } -void common_hal_mcu_enable_interrupts(void) { +void PLACE_IN_ITCM(common_hal_mcu_enable_interrupts)(void) { if (nesting_count == 0) { // This is very very bad because it means there was mismatched disable/enables reset_into_safe_mode(SAFE_MODE_INTERRUPT_ERROR); diff --git a/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c b/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c index 88d0453065..933d8aa444 100644 --- a/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c +++ b/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c @@ -64,9 +64,7 @@ void PLACE_IN_ITCM(common_hal_neopixel_write)(const digitalio_digitalinout_obj_t const uint32_t pin = digitalinout->pin->number; __disable_irq(); - // Enable DWT in debug core. Useable when interrupts disabled, as opposed to Systick->VAL - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; + // Use DWT in debug core. Useable when interrupts disabled, as opposed to Systick->VAL DWT->CYCCNT = 0; for (;;) { @@ -88,12 +86,12 @@ void PLACE_IN_ITCM(common_hal_neopixel_write)(const digitalio_digitalinout_obj_t mask = 0x80; } } + // Enable interrupts again + __enable_irq(); // Update the next start. next_start_raw_ticks = port_get_raw_ticks(NULL) + 4; - // Enable interrupts again - __enable_irq(); } #pragma GCC pop_options diff --git a/ports/mimxrt10xx/linking/common.ld b/ports/mimxrt10xx/linking/common.ld index b6f1acc8d0..61a9a2299f 100644 --- a/ports/mimxrt10xx/linking/common.ld +++ b/ports/mimxrt10xx/linking/common.ld @@ -6,7 +6,7 @@ Boards can setup reserved flash with _ld_reserved_flash_size in board.ld. */ ENTRY(Reset_Handler) -code_size = 1M; +code_size = 2M; _ld_default_stack_size = 20K; /* Default reserved flash to nothing. */ @@ -22,9 +22,9 @@ MEMORY FLASH_IVT (rx) : ORIGIN = 0x60001000, LENGTH = 4K /* Place the ISRs 48k in to leave room for the bootloader when it is available. */ FLASH_FIRMWARE (rx) : ORIGIN = 0x6000C000, LENGTH = code_size - 48K - FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = _ld_flash_size - code_size - _ld_reserved_flash_size + FLASH_FATFS (r) : ORIGIN = 0x60000000 + code_size, LENGTH = _ld_flash_size - code_size - _ld_reserved_flash_size /* Teensy uses the last bit of flash for recovery. */ - RESERVED_FLASH : ORIGIN = 0x60100000 + _ld_flash_size - _ld_reserved_flash_size, LENGTH = _ld_reserved_flash_size + RESERVED_FLASH : ORIGIN = 0x60000000 + code_size + _ld_flash_size - _ld_reserved_flash_size, LENGTH = _ld_reserved_flash_size OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = ram_size - 64K DTCM (x) : ORIGIN = 0x20000000, LENGTH = 32K ITCM (x) : ORIGIN = 0x00000000, LENGTH = 32K @@ -55,21 +55,42 @@ SECTIONS .text : { . = ALIGN(4); - __VECTOR_TABLE = .; - __VECTOR_RAM = .; - _ld_isr_table = .; - - KEEP(*(.isr_vector)) /* Startup code */ *(EXCLUDE_FILE( *fsl_flexspi.o + *dcd_ci_hs.o + *tusb_fifo.o + *usbd.o + *string0.o + *py/nlr*.o + *py/obj.o + *py/gc.o + *py/map.o + *py/runtime.o + *py/objboundmeth.o + *py/objtype.o ) .text*) /* .text* sections (code) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + + /* Keep USB processing functions out of RAM because we don't know which will be used. + We try to only keep USB interrupt related functions. */ + *dcd_ci_hs.o(.text.process_*_request .text.dcd_edpt* .text.dcd_init .text.dcd_set_address) + *usbd.o(.text.process_*_request .text.process_[gs]et* .text.tud_* .text.usbd_* .text.configuration_reset .text.invoke_*) + + /* Anything marked cold/unlikely should be in flash. */ + *(.text.unlikely.*) + + *(EXCLUDE_FILE( + *dcd_ci_hs.o + *py/objboundmeth.o + *py/objtype.o + ) .rodata*) /* .rodata* sections (constants, strings, etc.) */ . = ALIGN(4); } > FLASH_FIRMWARE .ARM.exidx : { + __exidx_start = .; *(.ARM.exidx*) + __exidx_end = .; *(.gnu.linkonce.armexidx.*) _etext = .; /* define a global symbol at end of code */ __etext = .; /* define a global symbol at end of code */ @@ -81,7 +102,6 @@ SECTIONS { . = ALIGN(4); *(.data*) /* .data* sections */ - *fsl_flexspi.o(.text*) . = ALIGN(4); } > OCRAM AT> FLASH_FIRMWARE _ld_ocram_data_destination = ADDR(.data); @@ -93,7 +113,7 @@ SECTIONS { . = ALIGN(4); - *(.bss*) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))) *(COMMON) . = ALIGN(4); @@ -103,22 +123,50 @@ SECTIONS _ld_heap_start = _ld_ocram_bss_start + _ld_ocram_bss_size; _ld_heap_end = ORIGIN(OCRAM) + LENGTH(OCRAM); - .itcm : + + .itcm : ALIGN(4) { . = ALIGN(4); *(.itcm.*) - + *fsl_flexspi.o(.text*) + *dcd_ci_hs.o(.text*) + *tusb_fifo.o(.text*) + *py/objboundmeth.o(.text*) + *py/objtype.o(.text*) + *py/obj.o(.text*) + *py/gc.o(.text*) + *py/map.o(.text*) + *py/nlr*.o(.text*) + *py/runtime.o(.text*) + *(.text.process_*_isr .text.dcd_event_* .text.osal_queue*) + *string0.o(.text*) . = ALIGN(4); } > ITCM AT> FLASH_FIRMWARE _ld_itcm_destination = ADDR(.itcm); _ld_itcm_flash_copy = LOADADDR(.itcm); _ld_itcm_size = SIZEOF(.itcm); + /* Align for 256 ISR entries */ + .isr_vector : ALIGN(4 * 256) + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } > ITCM AT> FLASH_FIRMWARE + _ld_isr_destination = ADDR(.isr_vector); + _ld_isr_flash_copy = LOADADDR(.isr_vector); + _ld_isr_size = SIZEOF(.isr_vector); + /* Used by the bootloader to start user code. */ + __VECTOR_TABLE = LOADADDR(.isr_vector); + .dtcm_data : { . = ALIGN(4); *(.dtcm_data.*) + *dcd_ci_hs.o(.rodata*) + *py/objboundmeth.o(.rodata*) + *py/objtype.o(.rodata*) . = ALIGN(4); } > DTCM AT> FLASH_FIRMWARE @@ -139,7 +187,7 @@ SECTIONS _ld_dtcm_bss_start = ADDR(.dtcm_bss); _ld_dtcm_bss_size = SIZEOF(.dtcm_bss); - .stack : + .stack (NOLOAD) : { . = ALIGN(8); _ld_stack_bottom = .; diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index cee2d9a698..236d5b9966 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -6,6 +6,8 @@ USB_HIGHSPEED = 1 # Number of USB endpoint pairs. USB_NUM_ENDPOINT_PAIRS = 8 +# Align buffers on the cache boundary so we don't inadvertently load them early. +CIRCUITPY_TUSB_MEM_ALIGN = 32 INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/mimxrt10xx/reset.c b/ports/mimxrt10xx/reset.c index a3a4f667de..3d9a0b071b 100644 --- a/ports/mimxrt10xx/reset.c +++ b/ports/mimxrt10xx/reset.c @@ -26,10 +26,11 @@ #include "reset.h" #include "supervisor/filesystem.h" +#include "supervisor/linker.h" #include "fsl_common.h" -void reset(void) { +void PLACE_IN_ITCM(reset)(void) { filesystem_flush(); NVIC_SystemReset(); } diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c index 950e9aa403..7563f386f9 100644 --- a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -13,6 +13,17 @@ #include "supervisor/internal_flash.h" #include "supervisor/linker.h" +STATIC uint8_t _busy_bit_shift; +STATIC bool _busy_bit_polarity; +STATIC bool _inited = false; + +void flexspi_nor_init(void) { + // Copy busy bit info into RAM so we can use if when flash isn't available. + _busy_bit_shift = qspiflash_config.memConfig.busyOffset; + _busy_bit_polarity = qspiflash_config.memConfig.busyBitPolarity; + _inited = true; +} + STATIC status_t PLACE_IN_ITCM(flexspi_nor_write_enable)(FLEXSPI_Type * base, uint32_t baseAddr) { flexspi_transfer_t flashXfer; @@ -53,9 +64,8 @@ STATIC status_t PLACE_IN_ITCM(flexspi_nor_wait_bus_busy)(FLEXSPI_Type * base) if (status != kStatus_Success) { return status; } - size_t busyBit = readValue & (1U << qspiflash_config.memConfig.busyOffset); - isBusy = (qspiflash_config.memConfig.busyBitPolarity == 0 && busyBit != 0) || - (qspiflash_config.memConfig.busyBitPolarity == 1 && busyBit == 0); + bool busyBit = (readValue >> _busy_bit_shift) & 0x1; + isBusy = busyBit != _busy_bit_polarity; } while (isBusy); return status; diff --git a/ports/mimxrt10xx/supervisor/internal_flash.c b/ports/mimxrt10xx/supervisor/internal_flash.c index 72d57d1dd4..30a033a183 100644 --- a/ports/mimxrt10xx/supervisor/internal_flash.c +++ b/ports/mimxrt10xx/supervisor/internal_flash.c @@ -53,8 +53,15 @@ uint8_t _flash_cache[SECTOR_SIZE] __attribute__((aligned(4))); uint32_t _flash_page_addr = NO_CACHE; void PLACE_IN_ITCM(supervisor_flash_init)(void) { - // Update the LUT to make sure all entries are available. - FLEXSPI_UpdateLUT(FLEXSPI, 0, (const uint32_t *)&qspiflash_config.memConfig.lookupTable, 64); + // Update the LUT to make sure all entries are available. Copy the values to + // memory first so that we don't read from the flash as we update the LUT. + uint32_t lut_copy[64]; + memcpy(lut_copy, (const uint32_t *)&qspiflash_config.memConfig.lookupTable, 64 * sizeof(uint32_t)); + FLEXSPI_UpdateLUT(FLEXSPI, 0, lut_copy, 64); + // Make sure everything is flushed after updating the LUT. + __DSB(); + __ISB(); + flexspi_nor_init(); } static inline uint32_t lba2addr(uint32_t block) { @@ -79,20 +86,21 @@ void PLACE_IN_ITCM(port_internal_flash_flush)(void) { if (memcmp(_flash_cache, (void *)_flash_page_addr, SECTOR_SIZE) != 0) { volatile uint32_t sector_addr = (_flash_page_addr - FlexSPI_AMBA_BASE); - __disable_irq(); + // Disable interrupts of priority 8+. They likely use code in flash + // itself. Higher priority interrupts (<8) should ensure all of their + // code is in RAM. + __set_BASEPRI(8 << (8 - __NVIC_PRIO_BITS)); status = flexspi_nor_flash_erase_sector(FLEXSPI, sector_addr); - __enable_irq(); + __set_BASEPRI(0U); if (status != kStatus_Success) { - printf("Page erase failure %ld!\r\n", status); return; } for (int i = 0; i < SECTOR_SIZE / FLASH_PAGE_SIZE; ++i) { - __disable_irq(); + __set_BASEPRI(8 << (8 - __NVIC_PRIO_BITS)); status = flexspi_nor_flash_page_program(FLEXSPI, sector_addr + i * FLASH_PAGE_SIZE, (void *)_flash_cache + i * FLASH_PAGE_SIZE); - __enable_irq(); + __set_BASEPRI(0U); if (status != kStatus_Success) { - printf("Page program failure %ld!\r\n", status); return; } } @@ -103,11 +111,17 @@ void PLACE_IN_ITCM(port_internal_flash_flush)(void) { } mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { - // Must write out anything in cache before trying to read. - supervisor_flash_flush(); + for (size_t i = 0; i < num_blocks; i++) { + uint32_t src = lba2addr(block + i); + uint32_t page_addr = src & ~(SECTOR_SIZE - 1); + // Copy from the cache if our page matches the cached one. + if (page_addr == _flash_page_addr) { + src = ((uint32_t)&_flash_cache) + (src - page_addr); + } + + memcpy(dest + FILESYSTEM_BLOCK_SIZE * i, (uint8_t *)src, FILESYSTEM_BLOCK_SIZE); + } - uint32_t src = lba2addr(block); - memcpy(dest, (uint8_t *)src, FILESYSTEM_BLOCK_SIZE * num_blocks); return 0; // success } @@ -141,5 +155,5 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32 return 0; // success } -void supervisor_flash_release_cache(void) { +void PLACE_IN_ITCM(supervisor_flash_release_cache)(void) { } diff --git a/ports/mimxrt10xx/supervisor/internal_flash.h b/ports/mimxrt10xx/supervisor/internal_flash.h index 66d3f73db1..c38e2bc416 100644 --- a/ports/mimxrt10xx/supervisor/internal_flash.h +++ b/ports/mimxrt10xx/supervisor/internal_flash.h @@ -42,6 +42,7 @@ #define ROM_INDEX_PAGEPROGRAM 9 #define ROM_INDEX_READSTATUSREG 1 +extern void flexspi_nor_init(void); extern status_t flexspi_nor_flash_erase_sector(FLEXSPI_Type *base, uint32_t address); extern status_t flexspi_nor_flash_page_program(FLEXSPI_Type *base, uint32_t dstAddr, const uint32_t *src); extern status_t flexspi_nor_enable_quad_mode(FLEXSPI_Type *base); diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 6997b4bae5..a27ab3ea58 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -42,13 +42,14 @@ #include "common-hal/busio/SPI.h" #include "shared-bindings/microcontroller/__init__.h" -#include "reset.h" - -#include "supervisor/background_callback.h" - #if CIRCUITPY_PEW #include "shared-module/_pew/PewPew.h" #endif + +#include "reset.h" + +#include "supervisor/background_callback.h" +#include "supervisor/linker.h" #include "supervisor/shared/tick.h" #include "clocks.h" @@ -97,16 +98,25 @@ extern uint32_t _ld_dtcm_data_flash_copy; extern uint32_t _ld_itcm_destination; extern uint32_t _ld_itcm_size; extern uint32_t _ld_itcm_flash_copy; +extern uint32_t _ld_isr_destination; +extern uint32_t _ld_isr_size; +extern uint32_t _ld_isr_flash_copy; extern void main(void); // This replaces the Reset_Handler in startup_*.S and SystemInit in system_*.c. +// Turn off optimize("no-tree-loop-distribute-patterns") so that this isn't replaced +// by calls to memcpy because we're copying it over now. void Reset_Handler(void); -__attribute__((used, naked)) void Reset_Handler(void) { +__attribute__((used, naked, no_instrument_function, optimize("no-tree-loop-distribute-patterns"))) void Reset_Handler(void) { __disable_irq(); - SCB->VTOR = (uint32_t)&__isr_vector; + // Set the VTOR to the flash copy since we haven't copied it into RAM. + SCB->VTOR = (uint32_t)&_ld_isr_flash_copy; __set_MSP((uint32_t)&_ld_stack_top); + // Turn off any residual ITM outputs. + ITM->TER = 0; + /* Disable I cache and D cache */ SCB_DisableICache(); SCB_DisableDCache(); @@ -128,6 +138,11 @@ __attribute__((used, naked)) void Reset_Handler(void) { current_gpr14 |= IOMUXC_GPR_GPR14_CM7_CFGITCMSZ(0x6); IOMUXC_GPR->GPR14 = current_gpr14; + // Enable FlexRAM interrupts on invalid access. + FLEXRAM->INT_STAT_EN = FLEXRAM_INT_STAT_EN_ITCM_ERR_STAT_EN(1) | + FLEXRAM_INT_STAT_EN_DTCM_ERR_STAT_EN(1) | + FLEXRAM_INT_STAT_EN_OCRAM_ERR_STAT_EN(1); + #if ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10, CP11 Full Access */ #endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */ @@ -157,6 +172,13 @@ __attribute__((used, naked)) void Reset_Handler(void) { (&_ld_itcm_destination)[i] = (&_ld_itcm_flash_copy)[i]; } + for (uint32_t i = 0; i < ((size_t)&_ld_isr_size) / 4; i++) { + (&_ld_isr_destination)[i] = (&_ld_isr_flash_copy)[i]; + } + + // Now that we've copied the ISR table over, use that VTOR. + SCB->VTOR = (uint32_t)&_ld_isr_destination; + // The first number in RBAR is the region number. When searching for a policy, the region with // the highest number wins. If none match, then the default policy set at enable applies. @@ -170,14 +192,19 @@ __attribute__((used, naked)) void Reset_Handler(void) { // FlexSPI2 is 0x70000000 - // This the first 1MB of flash is the bootloader and CircuitPython read-only data. - MPU->RBAR = ARM_MPU_RBAR(10, 0x60000000U); - MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, NO_SUBREGIONS, ARM_MPU_REGION_SIZE_1MB); + // This the first portion (1MB, 2MB or 4MB) of flash is the bootloader and CircuitPython read-only data. + MPU->RBAR = ARM_MPU_RBAR(10, FlexSPI_AMBA_BASE); + uint32_t region_size = ARM_MPU_REGION_SIZE_32B; + uint32_t code_size = ((uint32_t)&_ld_filesystem_start) - FlexSPI_AMBA_BASE; + while (code_size > (1u << (region_size + 1))) { + region_size += 1; + } + MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, NO_SUBREGIONS, region_size); // The remainder of flash is the fat filesystem which could have code on it too. Make sure that // we set the region to the minimal size so that bad data doesn't get speculatively fetched. // Thanks to Damien for the tip! - uint32_t region_size = ARM_MPU_REGION_SIZE_32B; + region_size = ARM_MPU_REGION_SIZE_32B; uint32_t filesystem_size = &_ld_filesystem_end - &_ld_filesystem_start; while (filesystem_size > (1u << (region_size + 1))) { region_size += 1; @@ -189,7 +216,7 @@ __attribute__((used, naked)) void Reset_Handler(void) { uint32_t subregion_size = (1u << (region_size + 1)) / 8; uint8_t subregion_mask = (0xff00 >> (remainder / subregion_size)) & 0xff; - MPU->RBAR = ARM_MPU_RBAR(11, 0x60100000U); + MPU->RBAR = ARM_MPU_RBAR(11, (size_t)&_ld_filesystem_start); MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, subregion_mask, region_size); // This the ITCM. Set it to read-only because we've loaded everything already and it's easy to @@ -205,9 +232,10 @@ __attribute__((used, naked)) void Reset_Handler(void) { // cost of 1/4 speed OCRAM accesses. It will leave more room for caching data from the flash // too which might be a net win. MPU->RBAR = ARM_MPU_RBAR(14, 0x20200000U); - MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, SHAREABLE, CACHEABLE, BUFFERABLE, NO_SUBREGIONS, ARM_MPU_REGION_SIZE_512KB); + MPU->RASR = ARM_MPU_RASR(NO_EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, NO_SUBREGIONS, ARM_MPU_REGION_SIZE_512KB); // We steal 64k from FlexRAM for ITCM and DTCM so disable those memory regions here. + // We use 64k from FlexRAM for ITCM and DTCM so disable those memory regions here. MPU->RBAR = ARM_MPU_RBAR(15, 0x20280000U); MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, 0x80, ARM_MPU_REGION_SIZE_512KB); @@ -239,14 +267,97 @@ __attribute__((used, naked)) void Reset_Handler(void) { } __enable_irq(); + main(); } +void __attribute__((no_instrument_function,section(".itcm.profile_enter"),long_call)) __cyg_profile_func_enter(void *this_fn, + void *call_site) { + if ((ITM->TER & (1 << 3)) == 0) { + return; + } + uint32_t addr = (uint32_t)this_fn; + while (ITM->PORT[3U].u32 == 0UL) { + // addr |= 1; + } + ITM->PORT[3].u32 = addr; +} + +void __attribute__((no_instrument_function,section(".itcm.profile_exit"),long_call)) __cyg_profile_func_exit(void *this_fn, + void *call_site) { + if ((ITM->TER & (1 << 4)) == 0) { + return; + } + uint32_t addr = (uint32_t)this_fn; + while (ITM->PORT[4U].u32 == 0UL) { + // addr |= 1; + } + ITM->PORT[4].u32 = addr; +} + safe_mode_t port_init(void) { CLOCK_SetMode(kCLOCK_ModeRun); clocks_init(); + // Turn on the DWT so that neopixel_write can use CYCCNT for timing. + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + DWT->CTRL = 0x2 << DWT_CTRL_SYNCTAP_Pos | DWT_CTRL_CYCCNTENA_Msk; + + // Enable SWO if needed. + #if CIRCUITPY_SWO_TRACE + + // Turn on the 528 MHz clock to the TPIU. + CLOCK_EnableClock(kCLOCK_Trace); /* Make these edits*/ + /* Set TRACE_PODF. */ + CLOCK_SetDiv(kCLOCK_TraceDiv, 0); /* Make these edits*/ + /* Set Trace clock source. */ + CLOCK_SetMux(kCLOCK_TraceMux, 0); /* Make these edits*/ + + ITM->TCR = ITM_TCR_TSENA_Msk | ITM_TCR_ITMENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_DWTENA_Msk; + + // Run at 2.75 mbaud. CP2102N says it can do up to 3. + // Base clock is 528 mhz (not 500 like the core). + // TPI->ACPR = 191; + // Run at 1 mbaud so that USB isn't bottlenecked. + TPI->ACPR = 527; + TPI->SPPR = 0x2; // NRZ aka UART + TPI->FFCR = 0; + + IOMUXC_SetPinMux( /* Add these lines*/ + IOMUXC_GPIO_AD_09_ARM_TRACE_SWO, + 0U); + IOMUXC_SetPinConfig( /* Add these lines*/ + IOMUXC_GPIO_AD_09_ARM_TRACE_SWO, + 0x00F9U); + + // Enable ports 0-4: + // * 0 is serial output + // * + // * 3 is addresses of functions beginning. + // * 4 is addresses of functions ending. + ITM->TER |= 0x1f; + ITM->PORT[0].u8 = 'C'; + ITM->PORT[0].u8 = 'P'; + ITM->PORT[0].u8 = '\n'; + #endif + + // Set all peripheral interrupt priorities to the lowest priority by default. + for (uint16_t i = 0; i < NUMBER_OF_INT_VECTORS; i++) { + NVIC_SetPriority(i, (1UL << __NVIC_PRIO_BITS) - 1UL); + } + NVIC_SetPriority(USB_OTG1_IRQn, 1); + #ifdef USBPHY2 + NVIC_SetPriority(USB_OTG2_IRQn, 1); + #endif + + NVIC_SetPriority(FLEXRAM_IRQn, 0); + NVIC_EnableIRQ(FLEXRAM_IRQn); + + // Priorities 8+ will be disabled during flash operations. To run during + // flash operations, ensure all code is in RAM (not flash) and set the + // priority < 8. + #if CIRCUITPY_RTC rtc_init(); #endif @@ -305,7 +416,7 @@ void reset_to_bootloader(void) { reset(); } -void reset_cpu(void) { +void PLACE_IN_ITCM(reset_cpu)(void) { reset(); } @@ -332,7 +443,7 @@ uint32_t *port_heap_get_top(void) { } // Place the word into the low power section of the SNVS. -void port_set_saved_word(uint32_t value) { +void PLACE_IN_ITCM(port_set_saved_word)(uint32_t value) { SNVS->LPGPR[1] = value; } @@ -355,7 +466,7 @@ uint64_t port_get_raw_ticks(uint8_t *subticks) { void SNVS_HP_WRAPPER_IRQHandler(void); __attribute__((used)) -void SNVS_HP_WRAPPER_IRQHandler(void) { +void PLACE_IN_ITCM(SNVS_HP_WRAPPER_IRQHandler)(void) { if ((SNVS->HPSR & SNVS_HPSR_PI_MASK) != 0) { supervisor_tick(); SNVS->HPSR = SNVS_HPSR_PI_MASK; @@ -414,44 +525,43 @@ void port_idle_until_interrupt(void) { common_hal_mcu_enable_interrupts(); } -/** - * \brief Default interrupt handler for unused IRQs. - */ +// Catch faults where the memory access violates MPU settings. void MemManage_Handler(void); -__attribute__((used)) void MemManage_Handler(void) { +__attribute__((used)) void PLACE_IN_ITCM(MemManage_Handler)(void) { reset_into_safe_mode(SAFE_MODE_HARD_FAULT); while (true) { asm ("nop;"); } } -/** - * \brief Default interrupt handler for unused IRQs. - */ void BusFault_Handler(void); -__attribute__((used)) void BusFault_Handler(void) { +__attribute__((used)) void PLACE_IN_ITCM(BusFault_Handler)(void) { reset_into_safe_mode(SAFE_MODE_HARD_FAULT); while (true) { asm ("nop;"); } } -/** - * \brief Default interrupt handler for unused IRQs. - */ void UsageFault_Handler(void); -__attribute__((used)) void UsageFault_Handler(void) { +__attribute__((used)) void PLACE_IN_ITCM(UsageFault_Handler)(void) { reset_into_safe_mode(SAFE_MODE_HARD_FAULT); while (true) { asm ("nop;"); } } -/** - * \brief Default interrupt handler for unused IRQs. - */ +// Default fault handler. void HardFault_Handler(void); -__attribute__((used)) void HardFault_Handler(void) { +__attribute__((used)) void PLACE_IN_ITCM(HardFault_Handler)(void) { + reset_into_safe_mode(SAFE_MODE_HARD_FAULT); + while (true) { + asm ("nop;"); + } +} + +// Catch access errors to FlexRAM (if the MPU didn't catch it first.) +void FLEXRAM_IRQHandler(void); +__attribute__((used)) void PLACE_IN_ITCM(FLEXRAM_IRQHandler)(void) { reset_into_safe_mode(SAFE_MODE_HARD_FAULT); while (true) { asm ("nop;"); diff --git a/ports/mimxrt10xx/supervisor/serial.c b/ports/mimxrt10xx/supervisor/serial.c deleted file mode 100644 index cb557d36a8..0000000000 --- a/ports/mimxrt10xx/supervisor/serial.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017, 2018 Scott Shawcroft for Adafruit Industries - * Copyright (c) 2019 Lucian Copeland for Adafruit Industries - * Copyright (c) 2019 Artur Pacholec - * - * 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/serial.h" -#include "py/mphal.h" -#include - -#include "fsl_clock.h" -#include "fsl_lpuart.h" - -#if defined(CIRCUITPY_CONSOLE_UART) -// static LPUART_Type *uart_instance = LPUART1; // evk -static LPUART_Type *uart_instance = LPUART4; // feather 1011 -// static LPUART_Type *uart_instance = LPUART2; // feather 1062 -static uint32_t UartSrcFreq(void) { - uint32_t freq; - - /* To make it simple, we assume default PLL and divider settings, and the only - variable from application is use PLL3 source or OSC source */ - /* PLL3 div6 80M */ - if (CLOCK_GetMux(kCLOCK_UartMux) == 0) { - freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / - (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); - } else { - freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); - } - - return freq; -} - -void port_serial_init(void) { - lpuart_config_t config; - - LPUART_GetDefaultConfig(&config); - config.baudRate_Bps = 115200; - config.enableTx = true; - config.enableRx = true; - - LPUART_Init(uart_instance, &config, UartSrcFreq()); -} - -bool port_serial_connected(void) { - return true; -} - -char port_serial_read(void) { - uint8_t data; - - LPUART_ReadBlocking(uart_instance, &data, sizeof(data)); - - return data; -} - -bool port_serial_bytes_available(void) { - return LPUART_GetStatusFlags(uart_instance) & kLPUART_RxDataRegFullFlag; -} - -void port_serial_write_substring(const char *text, uint32_t len) { - if (len == 0) { - return; - } - - LPUART_WriteBlocking(uart_instance, (uint8_t *)text, len); -} -#endif // CIRCUITPY_CONSOLE_UART diff --git a/ports/mimxrt10xx/supervisor/usb.c b/ports/mimxrt10xx/supervisor/usb.c index 2094a943b5..bc6bc5f0cd 100644 --- a/ports/mimxrt10xx/supervisor/usb.c +++ b/ports/mimxrt10xx/supervisor/usb.c @@ -27,6 +27,8 @@ #include "fsl_clock.h" #include "tusb.h" + +#include "supervisor/linker.h" #include "supervisor/usb.h" STATIC void init_usb_instance(mp_int_t instance) { @@ -78,13 +80,13 @@ STATIC void init_usb_instance(mp_int_t instance) { // Provide the prototypes for the interrupt handlers. The iMX RT SDK doesn't. // The SDK only links to them from assembly. void USB_OTG1_IRQHandler(void); - void USB_OTG1_IRQHandler(void) { + void PLACE_IN_ITCM(USB_OTG1_IRQHandler)(void) { usb_irq_handler(0); } #ifdef USBPHY2 void USB_OTG2_IRQHandler(void); - void USB_OTG2_IRQHandler(void) { + void PLACE_IN_ITCM(USB_OTG2_IRQHandler)(void) { usb_irq_handler(1); } #endif diff --git a/py/argcheck.c b/py/argcheck.c index 05c2567ca2..465a82c97e 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -31,7 +31,7 @@ #include "supervisor/shared/translate/translate.h" -void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) { +void PLACE_IN_ITCM(mp_arg_check_num_sig)(size_t n_args, size_t n_kw, uint32_t sig) { // TODO maybe take the function name as an argument so we can print nicer error messages // The reverse of MP_OBJ_FUN_MAKE_SIG diff --git a/py/bc.c b/py/bc.c index e1645dbff0..e7ad43389a 100644 --- a/py/bc.c +++ b/py/bc.c @@ -111,7 +111,7 @@ STATIC void dump_args(const mp_obj_t *a, size_t sz) { // - code_state->fun_bc should contain a pointer to the function object // - code_state->ip should contain the offset in bytes from the pointer // code_state->fun_bc->bytecode to the entry n_state (0 for bytecode, non-zero for native) -void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) { +void PLACE_IN_ITCM(mp_setup_code_state)(mp_code_state_t * code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) { // This function is pretty complicated. It's main aim is to be efficient in speed and RAM // usage for the common case of positional only args. diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index a514b6a160..fb85983675 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -583,6 +583,18 @@ void supervisor_run_background_tasks_if_tick(void); #define MICROPY_WRAP_MP_EXECUTE_BYTECODE PLACE_IN_ITCM #endif +#ifndef MICROPY_WRAP_MP_LOAD_GLOBAL +#define MICROPY_WRAP_MP_LOAD_GLOBAL PLACE_IN_ITCM +#endif + +#ifndef MICROPY_WRAP_MP_LOAD_NAME +#define MICROPY_WRAP_MP_LOAD_NAME PLACE_IN_ITCM +#endif + +#ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE +#define MICROPY_WRAP_MP_OBJ_GET_TYPE PLACE_IN_ITCM +#endif + #ifndef CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY #define CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY (0) #endif diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c849a12851..d002ab4d43 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -560,6 +560,10 @@ CFLAGS += -DCIRCUITPY_TUSB_MEM_ALIGN=$(CIRCUITPY_TUSB_MEM_ALIGN) CIRCUITPY_TUSB_ATTR_USBRAM ?= ".bss.usbram" CFLAGS += -DCIRCUITPY_TUSB_ATTR_USBRAM=$(CIRCUITPY_TUSB_ATTR_USBRAM) +# Output function trace information from the ARM ITM. +CIRCUITPY_SWO_TRACE ?= 0 +CFLAGS += -DCIRCUITPY_SWO_TRACE=$(CIRCUITPY_SWO_TRACE) + # Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk # $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. # This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. diff --git a/py/gc.c b/py/gc.c index 0ced4c854d..1812507c61 100644 --- a/py/gc.c +++ b/py/gc.c @@ -231,7 +231,9 @@ bool gc_is_locked(void) { // children: mark the unmarked child blocks and put those newly marked // blocks on the stack. When all children have been checked, pop off the // topmost block on the stack and repeat with that one. -STATIC void gc_mark_subtree(size_t block) { +// We don't instrument these functions because they occur a lot during GC and +// fill up the output buffer quickly. +STATIC void MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_mark_subtree)(size_t block) { // Start with the block passed in the argument. size_t sp = 0; for (;;) { @@ -350,7 +352,7 @@ STATIC void gc_sweep(void) { } // Mark can handle NULL pointers because it verifies the pointer is within the heap bounds. -STATIC void gc_mark(void *ptr) { +STATIC void MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_mark)(void *ptr) { if (VERIFY_PTR(ptr)) { size_t block = BLOCK_FROM_PTR(ptr); if (ATB_GET_KIND(block) == AT_HEAD) { @@ -397,7 +399,7 @@ void gc_collect_ptr(void *ptr) { #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) __attribute__((no_sanitize_address)) #endif -static void *gc_get_ptr(void **ptrs, int i) { +static void *MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_get_ptr)(void **ptrs, int i) { #if MICROPY_DEBUG_VALGRIND if (!VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&ptrs[i], sizeof(*ptrs))) { return NULL; diff --git a/py/mpconfig.h b/py/mpconfig.h index 9d68f4ce9d..d3842afbe7 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1827,6 +1827,17 @@ typedef double mp_float_t; #define MP_WEAK __attribute__((weak)) #endif +// Modifier for functions which should not be instrumented when tracing with +// -finstrument-functions +#ifndef MP_NO_INSTRUMENT +#define MP_NO_INSTRUMENT __attribute__((no_instrument_function)) +#endif + +// Modifier for functions which should ideally inlined +#ifndef MP_INLINE +#define MP_INLINE inline MP_NO_INSTRUMENT +#endif + // Modifier for functions which should be never inlined #ifndef MP_NOINLINE #define MP_NOINLINE __attribute__((noinline)) @@ -1847,6 +1858,12 @@ typedef double mp_float_t; #define MP_UNLIKELY(x) __builtin_expect((x), 0) #endif +// Modifier for functions which aren't often used. Calls will also be considered +// unlikely. Section names are `.text.unlikely` for use in linker scripts. +#ifndef MP_COLD +#define MP_COLD __attribute__((cold)) +#endif + // To annotate that code is unreachable #ifndef MP_UNREACHABLE #if defined(__GNUC__) diff --git a/py/obj.h b/py/obj.h index 86fbe5155f..92732b31dd 100644 --- a/py/obj.h +++ b/py/obj.h @@ -86,19 +86,19 @@ typedef struct _mp_obj_base_t mp_obj_base_t; #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A -static inline bool mp_obj_is_small_int(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_small_int(mp_const_obj_t o) { return (((mp_int_t)(o)) & 1) != 0; } #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 1) #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1)) -static inline bool mp_obj_is_qstr(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_qstr(mp_const_obj_t o) { return (((mp_int_t)(o)) & 7) == 2; } #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 3) #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 2)) -static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_immediate_obj(mp_const_obj_t o) { return (((mp_int_t)(o)) & 7) == 6; } #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 3) @@ -115,25 +115,25 @@ mp_float_t mp_obj_float_get(mp_obj_t self_in); mp_obj_t mp_obj_new_float(mp_float_t value); #endif -static inline bool mp_obj_is_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_obj(mp_const_obj_t o) { return (((mp_int_t)(o)) & 3) == 0; } #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B -static inline bool mp_obj_is_small_int(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_small_int(mp_const_obj_t o) { return (((mp_int_t)(o)) & 3) == 1; } #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 2) #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 2) | 1)) -static inline bool mp_obj_is_qstr(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_qstr(mp_const_obj_t o) { return (((mp_int_t)(o)) & 7) == 3; } #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 3) #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 3)) -static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_immediate_obj(mp_const_obj_t o) { return (((mp_int_t)(o)) & 7) == 7; } #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 3) @@ -150,13 +150,13 @@ mp_float_t mp_obj_float_get(mp_obj_t self_in); mp_obj_t mp_obj_new_float(mp_float_t value); #endif -static inline bool mp_obj_is_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_obj(mp_const_obj_t o) { return (((mp_int_t)(o)) & 1) == 0; } #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C -static inline bool mp_obj_is_small_int(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_small_int(mp_const_obj_t o) { return (((mp_int_t)(o)) & 1) != 0; } #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 1) @@ -166,17 +166,17 @@ static inline bool mp_obj_is_small_int(mp_const_obj_t o) { #define mp_const_float_e MP_ROM_PTR((mp_obj_t)(((0x402df854 & ~3) | 2) + 0x80800000)) #define mp_const_float_pi MP_ROM_PTR((mp_obj_t)(((0x40490fdb & ~3) | 2) + 0x80800000)) -static inline bool mp_obj_is_float(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_float(mp_const_obj_t o) { return (((mp_uint_t)(o)) & 3) == 2 && (((mp_uint_t)(o)) & 0xff800007) != 0x00000006; } -static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) { +static MP_INLINE mp_float_t mp_obj_float_get(mp_const_obj_t o) { union { mp_float_t f; mp_uint_t u; } num = {.u = ((mp_uint_t)o - 0x80800000) & ~3}; return num.f; } -static inline mp_obj_t mp_obj_new_float(mp_float_t f) { +static MP_INLINE mp_obj_t mp_obj_new_float(mp_float_t f) { union { mp_float_t f; mp_uint_t u; @@ -185,37 +185,37 @@ static inline mp_obj_t mp_obj_new_float(mp_float_t f) { } #endif -static inline bool mp_obj_is_qstr(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_qstr(mp_const_obj_t o) { return (((mp_uint_t)(o)) & 0xff80000f) == 0x00000006; } #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 4) #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 4) | 0x00000006)) -static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_immediate_obj(mp_const_obj_t o) { return (((mp_uint_t)(o)) & 0xff80000f) == 0x0000000e; } #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 4) #define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 4) | 0xe)) -static inline bool mp_obj_is_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_obj(mp_const_obj_t o) { return (((mp_int_t)(o)) & 3) == 0; } #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D -static inline bool mp_obj_is_small_int(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_small_int(mp_const_obj_t o) { return (((uint64_t)(o)) & 0xffff000000000000) == 0x0001000000000000; } #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)((o) << 16)) >> 17) #define MP_OBJ_NEW_SMALL_INT(small_int) (((((uint64_t)(small_int)) & 0x7fffffffffff) << 1) | 0x0001000000000001) -static inline bool mp_obj_is_qstr(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_qstr(mp_const_obj_t o) { return (((uint64_t)(o)) & 0xffff000000000000) == 0x0002000000000000; } #define MP_OBJ_QSTR_VALUE(o) ((((uint32_t)(o)) >> 1) & 0xffffffff) #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)(((uint64_t)(((uint32_t)(qst)) << 1)) | 0x0002000000000001)) -static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_immediate_obj(mp_const_obj_t o) { return (((uint64_t)(o)) & 0xffff000000000000) == 0x0003000000000000; } #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) ((((uint32_t)(o)) >> 46) & 3) @@ -230,17 +230,17 @@ static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) { #define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b145769 + 0x8004000000000000))} #define mp_const_float_pi {((mp_obj_t)((uint64_t)0x400921fb54442d18 + 0x8004000000000000))} -static inline bool mp_obj_is_float(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_float(mp_const_obj_t o) { return ((uint64_t)(o) & 0xfffc000000000000) != 0; } -static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) { +static MP_INLINE mp_float_t mp_obj_float_get(mp_const_obj_t o) { union { mp_float_t f; uint64_t r; } num = {.r = o - 0x8004000000000000}; return num.f; } -static inline mp_obj_t mp_obj_new_float(mp_float_t f) { +static MP_INLINE mp_obj_t mp_obj_new_float(mp_float_t f) { union { mp_float_t f; uint64_t r; @@ -249,7 +249,7 @@ static inline mp_obj_t mp_obj_new_float(mp_float_t f) { } #endif -static inline bool mp_obj_is_obj(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_obj(mp_const_obj_t o) { return (((uint64_t)(o)) & 0xffff000000000000) == 0x0000000000000000; } #define MP_OBJ_TO_PTR(o) ((void *)(uintptr_t)(o)) @@ -454,7 +454,7 @@ typedef enum _mp_map_lookup_kind_t { MP_MAP_LOOKUP_ADD_IF_NOT_FOUND_OR_REMOVE_IF_FOUND = 3, // only valid for mp_set_lookup } mp_map_lookup_kind_t; -static inline bool mp_map_slot_is_filled(const mp_map_t *map, size_t pos) { +static MP_INLINE bool mp_map_slot_is_filled(const mp_map_t *map, size_t pos) { assert(pos < map->alloc); return (map)->table[pos].key != MP_OBJ_NULL && (map)->table[pos].key != MP_OBJ_SENTINEL; } @@ -476,7 +476,7 @@ typedef struct _mp_set_t { mp_obj_t *table; } mp_set_t; -static inline bool mp_set_slot_is_filled(const mp_set_t *set, size_t pos) { +static MP_INLINE bool mp_set_slot_is_filled(const mp_set_t *set, size_t pos) { return (set)->table[pos] != MP_OBJ_NULL && (set)->table[pos] != MP_OBJ_SENTINEL; } @@ -821,7 +821,7 @@ extern const struct _mp_obj_exception_t mp_static_GeneratorExit_obj; #define mp_obj_is_tuple_compatible(o) (mp_type_get_getiter_slot(mp_obj_get_type(o)) == mp_obj_tuple_getiter) mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict); -static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { +static MP_INLINE mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? mp_const_true : mp_const_false; } mp_obj_t mp_obj_new_cell(mp_obj_t obj); @@ -893,7 +893,7 @@ mp_obj_t mp_obj_equal_not_equal(mp_binary_op_t op, mp_obj_t o1, mp_obj_t o2); bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2); // returns true if o is bool, small int or long int -static inline bool mp_obj_is_integer(mp_const_obj_t o) { +static MP_INLINE bool mp_obj_is_integer(mp_const_obj_t o) { return mp_obj_is_int(o) || mp_obj_is_bool(o); } @@ -940,7 +940,7 @@ mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in); mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in); void mp_init_emergency_exception_buf(void); -static inline mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { +static MP_INLINE mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { assert(exc_type->make_new == mp_obj_exception_make_new); return mp_obj_exception_make_new(exc_type, 1, 0, &arg); } @@ -957,42 +957,42 @@ void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t s #if MICROPY_PY_BUILTINS_FLOAT // float #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -static inline float mp_obj_get_float_to_f(mp_obj_t o) { +static MP_INLINE float mp_obj_get_float_to_f(mp_obj_t o) { return mp_obj_get_float(o); } -static inline double mp_obj_get_float_to_d(mp_obj_t o) { +static MP_INLINE double mp_obj_get_float_to_d(mp_obj_t o) { return (double)mp_obj_get_float(o); } -static inline mp_obj_t mp_obj_new_float_from_f(float o) { +static MP_INLINE mp_obj_t mp_obj_new_float_from_f(float o) { return mp_obj_new_float(o); } -static inline mp_obj_t mp_obj_new_float_from_d(double o) { +static MP_INLINE mp_obj_t mp_obj_new_float_from_d(double o) { return mp_obj_new_float((mp_float_t)o); } #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE -static inline float mp_obj_get_float_to_f(mp_obj_t o) { +static MP_INLINE float mp_obj_get_float_to_f(mp_obj_t o) { return (float)mp_obj_get_float(o); } -static inline double mp_obj_get_float_to_d(mp_obj_t o) { +static MP_INLINE double mp_obj_get_float_to_d(mp_obj_t o) { return mp_obj_get_float(o); } -static inline mp_obj_t mp_obj_new_float_from_f(float o) { +static MP_INLINE mp_obj_t mp_obj_new_float_from_f(float o) { return mp_obj_new_float((mp_float_t)o); } -static inline mp_obj_t mp_obj_new_float_from_d(double o) { +static MP_INLINE mp_obj_t mp_obj_new_float_from_d(double o) { return mp_obj_new_float(o); } #endif #if MICROPY_FLOAT_HIGH_QUALITY_HASH mp_int_t mp_float_hash(mp_float_t val); #else -static inline mp_int_t mp_float_hash(mp_float_t val) { +static MP_INLINE mp_int_t mp_float_hash(mp_float_t val) { return (mp_int_t)val; } #endif @@ -1031,7 +1031,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index); mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value); mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key); mp_obj_t mp_obj_dict_copy(mp_obj_t self_in); -static inline mp_map_t *mp_obj_dict_get_map(mp_obj_t dict) { +static MP_INLINE mp_map_t *mp_obj_dict_get_map(mp_obj_t dict) { return &((mp_obj_dict_t *)MP_OBJ_TO_PTR(dict))->map; } diff --git a/py/objdict.c b/py/objdict.c index 306205d12f..02aedacdd6 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -229,7 +229,7 @@ STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { /******************************************************************************/ /* dict methods */ -STATIC void mp_ensure_not_fixed(const mp_obj_dict_t *dict) { +STATIC void PLACE_IN_ITCM(mp_ensure_not_fixed)(const mp_obj_dict_t * dict) { if (dict->map.is_fixed) { mp_raise_TypeError(NULL); } @@ -643,7 +643,7 @@ size_t mp_obj_dict_len(mp_obj_t self_in) { return self->map.used; } -mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value) { +mp_obj_t PLACE_IN_ITCM(mp_obj_dict_store)(mp_obj_t self_in, mp_obj_t key, mp_obj_t value) { mp_check_self(mp_obj_is_dict_or_ordereddict(self_in)); mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); mp_ensure_not_fixed(self); diff --git a/py/objfun.c b/py/objfun.c index 55c3fbbb06..5a02869fcf 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -50,7 +50,7 @@ /******************************************************************************/ /* builtin functions */ -STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t PLACE_IN_ITCM(fun_builtin_0_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)args; assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_0)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); @@ -68,7 +68,7 @@ const mp_obj_type_t mp_type_fun_builtin_0 = { ), }; -STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t PLACE_IN_ITCM(fun_builtin_1_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_1)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); mp_arg_check_num(n_args, n_kw, 1, 1, false); @@ -85,7 +85,7 @@ const mp_obj_type_t mp_type_fun_builtin_1 = { ), }; -STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t PLACE_IN_ITCM(fun_builtin_2_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_2)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); mp_arg_check_num(n_args, n_kw, 2, 2, false); @@ -102,7 +102,7 @@ const mp_obj_type_t mp_type_fun_builtin_2 = { ), }; -STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t PLACE_IN_ITCM(fun_builtin_3_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_3)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); mp_arg_check_num(n_args, n_kw, 3, 3, false); @@ -119,7 +119,7 @@ const mp_obj_type_t mp_type_fun_builtin_3 = { ), }; -STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t PLACE_IN_ITCM(fun_builtin_var_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_var)); mp_obj_fun_builtin_var_t *self = MP_OBJ_TO_PTR(self_in); @@ -418,7 +418,7 @@ mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byt #if MICROPY_EMIT_NATIVE -STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t PLACE_IN_ITCM(fun_native_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { MP_STACK_CHECK(); mp_obj_fun_bc_t *self = self_in; mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode); @@ -505,7 +505,7 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) { } } -STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t PLACE_IN_ITCM(fun_asm_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_fun_asm_t *self = self_in; mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); diff --git a/py/objproperty.c b/py/objproperty.c index e8ae5094fa..f55efc8bdb 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -99,7 +99,7 @@ const mp_obj_type_t mp_type_property = { extern const mp_obj_property_t __property_getter_start, __property_getter_end, __property_getset_start, __property_getset_end; #endif -const mp_obj_t *mp_obj_property_get(mp_obj_t self_in, size_t *n_proxy) { +const mp_obj_t *PLACE_IN_ITCM(mp_obj_property_get)(mp_obj_t self_in, size_t *n_proxy) { mp_check_self(mp_obj_is_type(self_in, &mp_type_property)); mp_obj_property_t *self = MP_OBJ_TO_PTR(self_in); #if MICROPY_PY_OPTIMIZE_PROPERTY_FLASH_SIZE diff --git a/py/pystack.c b/py/pystack.c index 43dfd4ed6c..696b033377 100644 --- a/py/pystack.c +++ b/py/pystack.c @@ -36,7 +36,7 @@ void mp_pystack_init(void *start, void *end) { MP_STATE_THREAD(pystack_cur) = start; } -void *mp_pystack_alloc(size_t n_bytes) { +void *PLACE_IN_ITCM(mp_pystack_alloc)(size_t n_bytes) { n_bytes = (n_bytes + (MICROPY_PYSTACK_ALIGN - 1)) & ~(MICROPY_PYSTACK_ALIGN - 1); #if MP_PYSTACK_DEBUG n_bytes += MICROPY_PYSTACK_ALIGN; diff --git a/py/pystack.h b/py/pystack.h index ed51e0c7e3..169d58b6f7 100644 --- a/py/pystack.h +++ b/py/pystack.h @@ -41,7 +41,7 @@ void *mp_pystack_alloc(size_t n_bytes); // This function can free multiple continuous blocks at once: just pass the // pointer to the block that was allocated first and it and all subsequently // allocated blocks will be freed. -static inline void mp_pystack_free(void *ptr) { +static MP_INLINE void mp_pystack_free(void *ptr) { assert((uint8_t *)ptr >= MP_STATE_THREAD(pystack_start)); assert((uint8_t *)ptr <= MP_STATE_THREAD(pystack_cur)); #if MP_PYSTACK_DEBUG @@ -59,16 +59,16 @@ static inline void mp_pystack_free(void *ptr) { MP_STATE_THREAD(pystack_cur) = (uint8_t *)ptr; } -static inline void mp_pystack_realloc(void *ptr, size_t n_bytes) { +static MP_INLINE void mp_pystack_realloc(void *ptr, size_t n_bytes) { mp_pystack_free(ptr); mp_pystack_alloc(n_bytes); } -static inline size_t mp_pystack_usage(void) { +static MP_INLINE size_t mp_pystack_usage(void) { return MP_STATE_THREAD(pystack_cur) - MP_STATE_THREAD(pystack_start); } -static inline size_t mp_pystack_limit(void) { +static MP_INLINE size_t mp_pystack_limit(void) { return MP_STATE_THREAD(pystack_end) - MP_STATE_THREAD(pystack_start); } @@ -78,43 +78,43 @@ static inline size_t mp_pystack_limit(void) { #define mp_local_alloc(n_bytes) alloca(n_bytes) -static inline void mp_local_free(void *ptr) { +static MP_INLINE void mp_local_free(void *ptr) { (void)ptr; } -static inline void *mp_nonlocal_alloc(size_t n_bytes) { +static MP_INLINE void *mp_nonlocal_alloc(size_t n_bytes) { return m_new(uint8_t, n_bytes); } -static inline void *mp_nonlocal_realloc(void *ptr, size_t old_n_bytes, size_t new_n_bytes) { +static MP_INLINE void *mp_nonlocal_realloc(void *ptr, size_t old_n_bytes, size_t new_n_bytes) { return m_renew(uint8_t, ptr, old_n_bytes, new_n_bytes); } -static inline void mp_nonlocal_free(void *ptr, size_t n_bytes) { +static MP_INLINE void mp_nonlocal_free(void *ptr, size_t n_bytes) { m_del(uint8_t, ptr, n_bytes); } #else -static inline void *mp_local_alloc(size_t n_bytes) { +static MP_INLINE void *mp_local_alloc(size_t n_bytes) { return mp_pystack_alloc(n_bytes); } -static inline void mp_local_free(void *ptr) { +static MP_INLINE void mp_local_free(void *ptr) { mp_pystack_free(ptr); } -static inline void *mp_nonlocal_alloc(size_t n_bytes) { +static MP_INLINE void *mp_nonlocal_alloc(size_t n_bytes) { return mp_pystack_alloc(n_bytes); } -static inline void *mp_nonlocal_realloc(void *ptr, size_t old_n_bytes, size_t new_n_bytes) { +static MP_INLINE void *mp_nonlocal_realloc(void *ptr, size_t old_n_bytes, size_t new_n_bytes) { (void)old_n_bytes; mp_pystack_realloc(ptr, new_n_bytes); return ptr; } -static inline void mp_nonlocal_free(void *ptr, size_t n_bytes) { +static MP_INLINE void mp_nonlocal_free(void *ptr, size_t n_bytes) { (void)n_bytes; mp_pystack_free(ptr); } diff --git a/py/qstr.c b/py/qstr.c index 083e12d6f0..96e2a79192 100644 --- a/py/qstr.c +++ b/py/qstr.c @@ -137,7 +137,7 @@ void qstr_init(void) { #endif } -STATIC const char *find_qstr(qstr q, qstr_attr_t *attr) { +STATIC const char *PLACE_IN_ITCM(find_qstr)(qstr q, qstr_attr_t *attr) { // search pool for this qstr // total_prev_len==0 in the final pool, so the loop will always terminate const qstr_pool_t *pool = MP_STATE_VM(last_pool); diff --git a/py/runtime.c b/py/runtime.c index 9227594d83..91d9eb1c6d 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1588,7 +1588,7 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i #endif // MICROPY_ENABLE_COMPILER -NORETURN void m_malloc_fail(size_t num_bytes) { +NORETURN MP_COLD void m_malloc_fail(size_t num_bytes) { DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes); #if MICROPY_ENABLE_GC if (gc_is_locked()) { @@ -1601,25 +1601,25 @@ NORETURN void m_malloc_fail(size_t num_bytes) { #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NONE -NORETURN void mp_raise_type(const mp_obj_type_t *exc_type) { +NORETURN MP_COLD void mp_raise_type(const mp_obj_type_t *exc_type) { nlr_raise(mp_obj_new_exception(exc_type)); } -NORETURN void mp_raise_ValueError_no_msg(void) { +NORETURN MP_COLD void mp_raise_ValueError_no_msg(void) { mp_raise_type(&mp_type_ValueError); } -NORETURN void mp_raise_TypeError_no_msg(void) { +NORETURN MP_COLD void mp_raise_TypeError_no_msg(void) { mp_raise_type(&mp_type_TypeError); } -NORETURN void mp_raise_NotImplementedError_no_msg(void) { +NORETURN MP_COLD void mp_raise_NotImplementedError_no_msg(void) { mp_raise_type(&mp_type_NotImplementedError); } #else -NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) { if (msg == NULL) { nlr_raise(mp_obj_new_exception(exc_type)); } else { @@ -1627,19 +1627,19 @@ NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_strin } } -NORETURN void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr) { +NORETURN MP_COLD void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr) { mp_obj_t exception = mp_obj_new_exception_msg_vlist(exc_type, fmt, argptr); nlr_raise(exception); } -NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...) { +NORETURN MP_COLD void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_raise_msg_vlist(exc_type, fmt, argptr); va_end(argptr); } -NORETURN void mp_raise_msg_str(const mp_obj_type_t *exc_type, const char *msg) { +NORETURN MP_COLD void mp_raise_msg_str(const mp_obj_type_t *exc_type, const char *msg) { if (msg == NULL) { nlr_raise(mp_obj_new_exception(exc_type)); } else { @@ -1647,56 +1647,56 @@ NORETURN void mp_raise_msg_str(const mp_obj_type_t *exc_type, const char *msg) { } } -NORETURN void mp_raise_AttributeError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_AttributeError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_AttributeError, msg); } -NORETURN void mp_raise_RuntimeError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_RuntimeError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_RuntimeError, msg); } -NORETURN void mp_raise_ImportError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_ImportError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_ImportError, msg); } -NORETURN void mp_raise_IndexError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_IndexError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_IndexError, msg); } -NORETURN void mp_raise_IndexError_varg(const compressed_string_t *fmt, ...) { +NORETURN MP_COLD void mp_raise_IndexError_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_raise_msg_vlist(&mp_type_IndexError, fmt, argptr); va_end(argptr); } -NORETURN void mp_raise_ValueError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_ValueError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_ValueError, msg); } -NORETURN void mp_raise_ValueError_varg(const compressed_string_t *fmt, ...) { +NORETURN MP_COLD void mp_raise_ValueError_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_raise_msg_vlist(&mp_type_ValueError, fmt, argptr); va_end(argptr); } -NORETURN void mp_raise_TypeError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_TypeError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_TypeError, msg); } -NORETURN void mp_raise_TypeError_varg(const compressed_string_t *fmt, ...) { +NORETURN MP_COLD void mp_raise_TypeError_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_raise_msg_vlist(&mp_type_TypeError, fmt, argptr); va_end(argptr); } -NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_OSError_msg(const compressed_string_t *msg) { mp_raise_msg(&mp_type_OSError, msg); } -NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str) { +NORETURN MP_COLD void mp_raise_OSError_errno_str(int errno_, mp_obj_t str) { mp_obj_t args[2] = { MP_OBJ_NEW_SMALL_INT(errno_), str, @@ -1704,26 +1704,26 @@ NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str) { nlr_raise(mp_obj_new_exception_args(&mp_type_OSError, 2, args)); } -NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) { +NORETURN MP_COLD void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_raise_msg_vlist(&mp_type_OSError, fmt, argptr); va_end(argptr); } -NORETURN void mp_raise_ConnectionError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_ConnectionError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_ConnectionError, msg); } -NORETURN void mp_raise_BrokenPipeError(void) { +NORETURN MP_COLD void mp_raise_BrokenPipeError(void) { mp_raise_type_arg(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE)); } -NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) { +NORETURN MP_COLD void mp_raise_NotImplementedError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_NotImplementedError, msg); } -NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...) { +NORETURN MP_COLD void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_raise_msg_vlist(&mp_type_NotImplementedError, fmt, argptr); @@ -1731,17 +1731,18 @@ NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, } -NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) { +NORETURN MP_COLD void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_raise_msg_vlist(&mp_type_OverflowError, fmt, argptr); va_end(argptr); } -NORETURN void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg) { +NORETURN MP_COLD void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg) { nlr_raise(mp_obj_new_exception_arg1(exc_type, arg)); } +// Leave this as not COLD because it is used by iterators in normal execution. NORETURN void mp_raise_StopIteration(mp_obj_t arg) { if (arg == MP_OBJ_NULL) { mp_raise_type(&mp_type_StopIteration); @@ -1750,18 +1751,18 @@ NORETURN void mp_raise_StopIteration(mp_obj_t arg) { } } -NORETURN void mp_raise_OSError(int errno_) { +NORETURN MP_COLD void mp_raise_OSError(int errno_) { mp_raise_type_arg(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_)); } #endif #if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK -NORETURN void mp_raise_recursion_depth(void) { +NORETURN MP_COLD void mp_raise_recursion_depth(void) { mp_raise_RuntimeError(MP_ERROR_TEXT("maximum recursion depth exceeded")); } #endif -NORETURN void mp_raise_ZeroDivisionError(void) { +NORETURN MP_COLD void mp_raise_ZeroDivisionError(void) { mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("division by zero")); } diff --git a/py/runtime.h b/py/runtime.h index 1a7a5d1698..d154772508 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -86,7 +86,7 @@ bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg); int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int base_char, int flags, char fill, int width, int prec); void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig); -static inline void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw) { +static MP_INLINE void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw) { mp_arg_check_num_sig(n_args, n_kw, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, takes_kw)); } void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals); @@ -115,16 +115,16 @@ mp_obj_t mp_arg_validate_type_or_none(mp_obj_t obj, const mp_obj_type_t *type, q mp_int_t mp_arg_validate_type_int(mp_obj_t obj, qstr arg_name); mp_obj_t mp_arg_validate_type_string(mp_obj_t obj, qstr arg_name); -static inline mp_obj_dict_t *PLACE_IN_ITCM(mp_locals_get)(void) { +static MP_INLINE mp_obj_dict_t *mp_locals_get(void) { return MP_STATE_THREAD(dict_locals); } -static inline void PLACE_IN_ITCM(mp_locals_set)(mp_obj_dict_t * d) { +static MP_INLINE void mp_locals_set(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_locals) = d; } -static inline mp_obj_dict_t *PLACE_IN_ITCM(mp_globals_get)(void) { +static MP_INLINE mp_obj_dict_t *mp_globals_get(void) { return MP_STATE_THREAD(dict_globals); } -static inline void PLACE_IN_ITCM(mp_globals_set)(mp_obj_dict_t * d) { +static MP_INLINE void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_globals) = d; } @@ -181,7 +181,7 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o); // may return MP_OBJ_STOP_ITERATIO mp_obj_t mp_iternext(mp_obj_t o); // will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration(...) mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val); -static inline mp_obj_t mp_make_stop_iteration(mp_obj_t o) { +static MP_INLINE mp_obj_t mp_make_stop_iteration(mp_obj_t o) { MP_STATE_THREAD(stop_iteration_arg) = o; return MP_OBJ_STOP_ITERATION; } diff --git a/py/stackctrl.c b/py/stackctrl.c index d699d6da61..546987f04d 100644 --- a/py/stackctrl.c +++ b/py/stackctrl.c @@ -38,7 +38,7 @@ void mp_stack_set_top(void *top) { MP_STATE_THREAD(stack_top) = top; } -mp_uint_t mp_stack_usage(void) { +mp_uint_t PLACE_IN_ITCM(mp_stack_usage)(void) { // Assumes descending stack // Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto. __asm volatile (""); @@ -52,7 +52,7 @@ void mp_stack_set_limit(mp_uint_t limit) { MP_STATE_THREAD(stack_limit) = limit; } -void mp_stack_check(void) { +void PLACE_IN_ITCM(mp_stack_check)(void) { if (mp_stack_usage() >= MP_STATE_THREAD(stack_limit)) { mp_raise_recursion_depth(); } diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index de4d66f9d8..c0195115fa 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -125,7 +125,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj___exit__(size_t n_args, const mp_obj_ } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(digitalio_digitalinout_obj___exit___obj, 4, 4, digitalio_digitalinout_obj___exit__); -STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) { +STATIC inline void check_for_deinit(digitalio_digitalinout_obj_t *self) { if (common_hal_digitalio_digitalinout_deinited(self)) { raise_deinited_error(); } diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index 7b6eec7e1b..060972d0c3 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -127,6 +127,7 @@ static bool usb_drive_set_enabled(bool enabled) { if (tud_connected()) { return false; } + filesystem_set_internal_writable_by_usb(enabled); storage_usb_is_enabled = enabled; return true; } diff --git a/supervisor/linker.h b/supervisor/linker.h index 58068c1a4b..c6ee8b4218 100644 --- a/supervisor/linker.h +++ b/supervisor/linker.h @@ -32,7 +32,8 @@ #if defined(IMXRT10XX) || defined(FOMU) || defined(STM32H7) || defined(RASPBERRYPI) #define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name))) #define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name))) -#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name))) name +// Don't inline ITCM functions because that may pull them out of ITCM into other sections. +#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name),noinline)) name #else #define PLACE_IN_DTCM_DATA(name) name #define PLACE_IN_DTCM_BSS(name) name diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c index db6d62f8e7..80f70b528a 100644 --- a/supervisor/shared/background_callback.c +++ b/supervisor/shared/background_callback.c @@ -42,7 +42,7 @@ STATIC volatile background_callback_t *volatile callback_head, *volatile callbac MP_WEAK void port_wake_main_task(void) { } -void background_callback_add_core(background_callback_t *cb) { +void PLACE_IN_ITCM(background_callback_add_core)(background_callback_t * cb) { CALLBACK_CRITICAL_BEGIN; if (cb->prev || callback_head == cb) { CALLBACK_CRITICAL_END; @@ -62,13 +62,13 @@ void background_callback_add_core(background_callback_t *cb) { port_wake_main_task(); } -void background_callback_add(background_callback_t *cb, background_callback_fun fun, void *data) { +void PLACE_IN_ITCM(background_callback_add)(background_callback_t * cb, background_callback_fun fun, void *data) { cb->fun = fun; cb->data = data; background_callback_add_core(cb); } -bool PLACE_IN_ITCM(background_callback_pending)(void) { +bool inline background_callback_pending(void) { return callback_head != NULL; } diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index 1eab59c384..345f55f2f1 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -33,6 +33,7 @@ #include "py/mpstate.h" #include "supervisor/flash.h" +#include "supervisor/linker.h" static mp_vfs_mount_t _mp_vfs; static fs_user_mount_t _internal_vfs; @@ -165,7 +166,7 @@ bool filesystem_init(bool create_allowed, bool force_create) { return true; } -void filesystem_flush(void) { +void PLACE_IN_ITCM(filesystem_flush)(void) { // Reset interval before next flush. filesystem_flush_interval_ms = CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS; supervisor_flash_flush(); diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c index dfd7cf2050..53815c9836 100644 --- a/supervisor/shared/flash.c +++ b/supervisor/shared/flash.c @@ -132,7 +132,7 @@ static mp_uint_t flash_write_blocks(const uint8_t *src, uint32_t block_num, uint } } -void supervisor_flash_flush(void) { +void PLACE_IN_ITCM(supervisor_flash_flush)(void) { #if INTERNAL_FLASH_FILESYSTEM port_internal_flash_flush(); #else diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 5112b17ebf..d3a31de71a 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -34,6 +34,7 @@ #include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" +#include "supervisor/linker.h" #include "supervisor/serial.h" #include "supervisor/shared/rgb_led_colors.h" #include "supervisor/shared/status_leds.h" @@ -121,12 +122,12 @@ safe_mode_t wait_for_safe_mode_reset(void) { return SAFE_MODE_NONE; } -void safe_mode_on_next_reset(safe_mode_t reason) { +void PLACE_IN_ITCM(safe_mode_on_next_reset)(safe_mode_t reason) { port_set_saved_word(SAFE_MODE_DATA_GUARD | (reason << 8)); } // Don't inline this so it's easy to break on it from GDB. -void __attribute__((noinline,)) reset_into_safe_mode(safe_mode_t reason) { +void __attribute__((noinline,)) PLACE_IN_ITCM(reset_into_safe_mode)(safe_mode_t reason) { if (_safe_mode > SAFE_MODE_BROWNOUT && reason > SAFE_MODE_BROWNOUT) { while (true) { // This very bad because it means running in safe mode didn't save us. Only ignore brownout diff --git a/supervisor/shared/status_bar.c b/supervisor/shared/status_bar.c index 4f5fa06464..16d23fe541 100644 --- a/supervisor/shared/status_bar.c +++ b/supervisor/shared/status_bar.c @@ -78,8 +78,8 @@ void supervisor_status_bar_update(void) { !shared_module_supervisor_status_bar_get_display(&shared_module_supervisor_status_bar_obj); // Suppress writes to console and/or display if status bar is not enabled for either or both. - bool prev_console_disable; - bool prev_display_disable; + bool prev_console_disable = false; + bool prev_display_disable = false; if (disable_console_writes) { prev_console_disable = serial_console_write_disable(true); diff --git a/supervisor/shared/translate/translate_impl.h b/supervisor/shared/translate/translate_impl.h index 1c144197cb..13da8c656b 100644 --- a/supervisor/shared/translate/translate_impl.h +++ b/supervisor/shared/translate/translate_impl.h @@ -48,7 +48,9 @@ inline #if !CIRCUITPY_LTO || CIRCUITPY_DEBUG < 1 __attribute__((always_inline)) #endif -const compressed_string_t *translate(const char *original) { +// Prevent instrumenting this because that disables the inlining we rely of for code size +// optimization. +__attribute__((no_instrument_function)) const compressed_string_t *translate(const char *original) { #ifndef NO_QSTR #define QDEF(id, hash, len, str) #define TRANSLATION(english_id, number) if (strcmp(original, english_id) == 0) { return &translation##number; } else diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 5ac8454312..1d600e1158 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -220,11 +220,11 @@ static void usb_background_do(void *unused) { usb_background(); } -void usb_background_schedule(void) { +void PLACE_IN_ITCM(usb_background_schedule)(void) { background_callback_add(&usb_callback, usb_background_do, NULL); } -void usb_irq_handler(int instance) { +void PLACE_IN_ITCM(usb_irq_handler)(int instance) { #if CFG_TUSB_MCU != OPT_MCU_RP2040 // For rp2040, IRQ handler is already installed and invoked automatically if (instance == CIRCUITPY_USB_DEVICE_INSTANCE) { diff --git a/tests/perf_bench/benchrun.py b/tests/perf_bench/benchrun.py index 90c303dd29..0092ecaa33 100644 --- a/tests/perf_bench/benchrun.py +++ b/tests/perf_bench/benchrun.py @@ -4,7 +4,7 @@ def bm_run(N, M): except ImportError: import time - ticks_us = lambda: int(time.perf_counter() * 1000000) + ticks_us = lambda: int(time.monotonic_ns() / 1000) ticks_diff = lambda a, b: a - b # Pick sensible parameters given N, M diff --git a/tools/cortex-m-fault-gdb.py b/tools/cortex-m-fault-gdb.py new file mode 100644 index 0000000000..31b76aa1d4 --- /dev/null +++ b/tools/cortex-m-fault-gdb.py @@ -0,0 +1,106 @@ +"""Source this file into gdb `source ../../tools/cortex-m-fault-gdb.py` then run + `cortex-m-fault` to print basic info about the fault registers.""" + +SCS = 0xE000E000 +SCB = SCS + 0x0D00 +CPUID = SCB + 0x000 # (R/ ) CPUID Base Register */ +ICSR = SCB + 0x004 # (R/W) Interrupt Control and State Register */ +VTOR = SCB + 0x008 # (R/W) Vector Table Offset Register */ +AIRCR = SCB + 0x00C # (R/W) Application Interrupt and Reset Control Register */ +SCR = SCB + 0x010 # (R/W) System Control Register */ +CCR = SCB + 0x014 # (R/W) Configuration Control Register */ +SHCSR = SCB + 0x024 # (R/W) System Handler Control and State Register */ +CFSR = SCB + 0x028 # (R/W) Configurable Fault Status Register */ +HFSR = SCB + 0x02C # (R/W) HardFault Status Register */ +DFSR = SCB + 0x030 # (R/W) Debug Fault Status Register */ +MMFAR = SCB + 0x034 # (R/W) MemManage Fault Address Register */ +BFAR = SCB + 0x038 # (R/W) BusFault Address Register */ +AFSR = SCB + 0x03C # (R/W) Auxiliary Fault Status Register */ + +PARTS = {0xC27: "Cortex M7"} + +EXCEPTIONS = { + 0: "Thread mode", + 2: "Non Maskable Interrupt", + 3: "Hard Fault", + 4: "MemManage Fault", + 5: "Bus Fault", + 6: "Usage Fault", + 11: "SVCAll", + 14: "PendSV", + 15: "SysTick", +} + + +class CortexMFault(gdb.Command): + def __init__(self): + super(CortexMFault, self).__init__("cortex-m-fault", gdb.COMMAND_USER) + + def _read(self, address): + i = gdb.selected_inferior() + return i.read_memory(address, 4).cast("I")[0] + + def invoke(self, arg, from_tty): + cpuid = self._read(CPUID) + implementer = cpuid >> 24 + if implementer != 0x41: + raise RuntimeError() + variant = (cpuid >> 20) & 0xF + constant = (cpuid >> 16) & 0xF + if constant != 0xF: + raise RuntimeError() + revision = cpuid & 0xF + part_no = (cpuid >> 4) & 0xFFF + print(PARTS[part_no]) + icsr = self._read(ICSR) + if (icsr & (1 << 11)) != 0: + print("No preempted exceptions") + else: + print("Another exception was preempted") + vectactive = icsr & 0x1FF + if vectactive != 0: + if vectactive in EXCEPTIONS: + print(EXCEPTIONS[vectactive]) + else: + print(vectactive - 16) + + vtor = self._read(VTOR) + # print(hex(self._read(SHCSR))) + cfsr = self._read(CFSR) + ufsr = cfsr >> 16 + bfsr = (cfsr >> 8) & 0xFF + mmfsr = cfsr & 0xFF + print("ufsr", hex(ufsr), "bfsr", hex(bfsr), "mmfsr", hex(mmfsr)) + if (bfsr & (1 << 7)) != 0: + print("Bad address", hex(self._read(BFAR))) + if (bfsr & (1 << 3)) != 0: + print("Unstacking from exception error") + if (bfsr & (1 << 2)) != 0: + print("Imprecise data bus error") + if (bfsr & (1 << 1)) != 0: + print("Precise data bus error") + if (bfsr & (1 << 0)) != 0: + print("Instruction bus error") + + if (mmfsr & (1 << 7)) != 0: + print("Bad address", hex(self._read(MMFAR))) + if (mmfsr & (1 << 3)) != 0: + print("Unstacking from exception error") + if (mmfsr & (1 << 1)) != 0: + print("Data access violation") + if (mmfsr & (1 << 0)) != 0: + print("Instruction access violation") + + if (ufsr & (1 << 8)) != 0: + print("Unaligned access") + if (ufsr & (1 << 0)) != 0: + print("Undefined instruction") + hfsr = self._read(HFSR) + if (hfsr & (1 << 30)) != 0: + print("Forced hard fault") + if (hfsr & (1 << 1)) != 0: + print("Bus fault when reading vector table") + print("VTOR", hex(vtor)) + + +CortexMFault() diff --git a/tools/cpboard.py b/tools/cpboard.py index 1f399d1dfc..658cf512a2 100644 --- a/tools/cpboard.py +++ b/tools/cpboard.py @@ -9,6 +9,7 @@ # SPDX-License-Identifier: MIT import os +import pathlib import re import serial import sys @@ -93,16 +94,18 @@ class REPL: for i in range(0, len(data), chunk_size): chunk = data[i : min(i + chunk_size, len(data))] self.session += chunk - self.serial.write(chunk) + c = self.serial.write(chunk) + if c < len(chunk): + raise RuntimeError() time.sleep(0.01) def reset(self): # Use read() since serial.reset_input_buffer() fails with termios.error now and then self.read() self.session = b"" - self.write(b"\r" + REPL.CHAR_CTRL_C + REPL.CHAR_CTRL_C) # interrupt any running program + self.write(REPL.CHAR_CTRL_C + REPL.CHAR_CTRL_C) # interrupt any running program self.write(b"\r" + REPL.CHAR_CTRL_B) # enter or reset friendly repl - data = self.read_until(b">>> ") + self.read_until(b">>> ", timeout=60) def execute(self, code, timeout=10, wait_for_response=True): self.read() # Throw away @@ -347,7 +350,7 @@ class CPboard: return cls(dev, baudrate=baudrate, wait=wait, timeout=timeout) def __init__(self, device, baudrate=115200, wait=0, timeout=10): - self.device = device + self.device = str(pathlib.Path(device).resolve()) self.usb_dev = None try: # Is it a usb.core.Device? @@ -357,7 +360,7 @@ class CPboard: else: serials = [serial for serial in os.listdir("/dev/serial/by-path") if portstr in serial] if len(serials) != 1: - raise RuntimeError("Can't find excatly one matching usb serial device") + raise RuntimeError("Can't find exactly one matching usb serial device") self.device = os.path.realpath("/dev/serial/by-path/" + serials[0]) self.usb_dev = device @@ -370,6 +373,10 @@ class CPboard: self.bootloader = False self.repl = REPL(self) + # Disable autoreload so that file copies won't mess us up. + with self: + self.exec("import supervisor;supervisor.runtime.autoreload = False") + def __enter__(self): self.open() return self @@ -507,7 +514,7 @@ class CPboard: part = [part for part in disks if "part1" in part] if not part: - raise RuntimeError("Disk not found for: " + self.device) + return None return Disk(part[0]) @@ -557,9 +564,16 @@ class Pyboard: def enter_raw_repl(self): self.board.open() + def exit_raw_repl(self): + self.close() + def execfile(self, filename): return self.board.execfile(filename) + def exec_(self, command, data_consumer=None): + output = self.board.exec(command, timeout=20000) + return output + def eval_namedtuple(board, command): from collections import namedtuple diff --git a/tools/gen_display_resources.py b/tools/gen_display_resources.py index 7165db84cc..350988bab0 100644 --- a/tools/gen_display_resources.py +++ b/tools/gen_display_resources.py @@ -121,7 +121,7 @@ if tile_y == 16: blinka_size = 16 c_file.write( """\ -uint32_t blinka_bitmap_data[32] = { +const uint32_t blinka_bitmap_data[32] = { 0x00000011, 0x11000000, 0x00000111, 0x53100000, 0x00000111, 0x56110000, @@ -145,7 +145,7 @@ else: blinka_size = 12 c_file.write( """\ -uint32_t blinka_bitmap_data[28] = { +const uint32_t blinka_bitmap_data[28] = { 0x00000111, 0x00000000, 0x00001153, 0x10000000, 0x00001156, 0x11000000, @@ -164,11 +164,11 @@ uint32_t blinka_bitmap_data[28] = { c_file.write( """\ -displayio_bitmap_t blinka_bitmap = {{ +const displayio_bitmap_t blinka_bitmap = {{ .base = {{.type = &displayio_bitmap_type }}, .width = {0}, .height = {0}, - .data = blinka_bitmap_data, + .data = (uint32_t*) blinka_bitmap_data, .stride = 2, .bits_per_value = 4, .x_shift = 3, @@ -211,7 +211,7 @@ displayio_palette_t blinka_palette = {{ displayio_tilegrid_t supervisor_blinka_sprite = {{ .base = {{.type = &displayio_tilegrid_type }}, - .bitmap = &blinka_bitmap, + .bitmap = (displayio_bitmap_t*) &blinka_bitmap, .pixel_shader = &blinka_palette, .x = 0, .y = 0, diff --git a/tools/swo_function_trace.py b/tools/swo_function_trace.py new file mode 100644 index 0000000000..bdc1b0f840 --- /dev/null +++ b/tools/swo_function_trace.py @@ -0,0 +1,143 @@ +"""This prints out Chrome Trace Formatted json that can be viewed in Perfetto or Spall. +https://ui.perfetto.dev/ +https://gravitymoth.com/spall/spall.html + +Format: +https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview# + +Connect a USB to Serial converter to the SWO pin and then provide the serial +device to this script. It should be 1MBaud SWO signal. CTRL-C when you've captured enough data and +then it'll process and output. + +pip install pysigrok-libsigrokdecode +python tools/swo_function_trace.py /dev/ttyACM0 build-metro_m7_1011/firmware.elf > trace.json +""" + +import serial +import sys +import sigrokdecode +import time +import json + +from elftools.elf.elffile import ELFFile + +f = open(sys.argv[-1], "rb") +ef = ELFFile(f) + +symtab = ef.get_section_by_name(".symtab") +symbols = {} +for s in symtab.iter_symbols(): + addr = s.entry["st_value"] + symbols[addr] = s.name +f.close() + +# sys.exit(0) + +decoder = sigrokdecode.get_decoder("arm_itm")() + +decoder.reset() +decoder.options = {"objdump": "", "elffile": ""} +decoder.start() + +dwt_timestamp = 0 +last_dwt_timestamp = 0 +streak = 0 +print("[") + +stack = [] + + +def emit(ts, addr, channel): + s = None + if addr in symbols: + s = symbols[addr] + else: + s = hex(addr) + if addr < 0x6000_0000: + s = "R:" + s + else: + s = "F:" + s + if channel[0] == "3": + stack.append(addr) + else: + if not stack or stack[-1] != addr: + return + stack.pop() + event = { + "name": s, + "ph": "B" if channel[0] == "3" else "E", + "ts": ts, + "pid": 0, + "tid": 0, + } + print(json.dumps(event), ",") + + +def decoder_cb(ss, es, data): + global streak + global last_dwt_timestamp + # print(ss, es, data) + ptype = data[0] + ts = (dwt_timestamp + (streak * 32)) / 500 + if ptype == 0: + event = {"name": data[1][0], "ph": "i", "ts": ts, "pid": 0, "tid": 0, "s": "g"} + print(json.dumps(event), ",") + if data[1][0] == "Overflow": + while stack: + emit(ts, stack[-1], "4:") + + if ptype in (0, 1): + return + if ptype == 2 and (data[1][0].startswith("3:") or data[1][0].startswith("4:")): + channel, addr = data[1][0].split() + addr = int(addr[2:], 16) + # if addr & 0x1 != 0: + # addr -= 1 + # print(dwt_timestamp + streak, channel, symbols[addr], hex(addr)) + emit(ts, addr, channel) + else: + # print(dwt_timestamp + streak, data) + pass + if dwt_timestamp == last_dwt_timestamp: + streak += 1 + else: + streak = 0 + + if last_dwt_timestamp > dwt_timestamp: + raise RuntimeError() + last_dwt_timestamp = dwt_timestamp + + +decoder.add_callback(sigrokdecode.OUTPUT_ANN, None, decoder_cb) + +s = serial.Serial(sys.argv[-2], 1000000) + + +buffers = [] +while True: + try: + start_ts = time.monotonic_ns() + b = s.read(s.in_waiting) + if b: + end_ts = time.monotonic_ns() + buffers.append((start_ts, end_ts, b)) + # print(len(b)) + # if len(buffers) > 10: + # break + except KeyboardInterrupt: + break + +time_per_bit = 1_000_000_000 / 1000000 + +min_gap = 100000000 +total_bytes = 0 +for start_ts, end_ts, buf in buffers: + # print(total_bytes, start_ts, end_ts, buf) + ts_per_byte = (end_ts - start_ts) / len(buf) + for i, b in enumerate(buf): + # print(total_bytes, hex(b)) + total_bytes += 1 + decoder.decode( + start_ts + ts_per_byte * i, start_ts + ts_per_byte * (i + 1), ("DATA", None, (b,)) + ) + dwt_timestamp = decoder.dwt_timestamp diff --git a/tools/swo_viewer.py b/tools/swo_viewer.py new file mode 100644 index 0000000000..327c450023 --- /dev/null +++ b/tools/swo_viewer.py @@ -0,0 +1,67 @@ +"""This prints out all parsed ITM packets. + +Connect a USB to Serial converter to the SWO pin and then provide the serial +device to this script. It should be 1MBaud SWO signal. CTRL-C when you've +captured enough data and then it'll process and output. + +pip install pysigrok-libsigrokdecode +python tools/swo_viewer.py /dev/ttyACM0 +""" + +import serial +import sys +import sigrokdecode +import time +import json + +decoder = sigrokdecode.get_decoder("arm_itm")() + +decoder.reset() +decoder.options = {"objdump": "", "elffile": ""} +decoder.start() + +dwt_timestamp = 0 +last_dwt_timestamp = 0 +streak = 0 + +stack = [] + + +def decoder_cb(ss, es, data): + global streak + global last_dwt_timestamp + print(dwt_timestamp, ss, es, data) + + +decoder.add_callback(sigrokdecode.OUTPUT_ANN, None, decoder_cb) + +s = serial.Serial(sys.argv[-2], 1000000) + +buffers = [] +while True: + try: + start_ts = time.monotonic_ns() + b = s.read(s.in_waiting) + if b: + end_ts = time.monotonic_ns() + buffers.append((start_ts, end_ts, b)) + # print(len(b)) + # if len(buffers) > 10: + # break + except KeyboardInterrupt: + break + +time_per_bit = 1_000_000_000 / 1000000 + +min_gap = 100000000 +total_bytes = 0 +for start_ts, end_ts, buf in buffers: + # print(total_bytes, start_ts, end_ts, buf) + ts_per_byte = (end_ts - start_ts) / len(buf) + for i, b in enumerate(buf): + # print(total_bytes, hex(b)) + total_bytes += 1 + decoder.decode( + start_ts + ts_per_byte * i, start_ts + ts_per_byte * (i + 1), ("DATA", None, (b,)) + ) + dwt_timestamp = decoder.dwt_timestamp From 6a9d69d743ba9ffc9fb96de1fceb79a0b9cac0e8 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 14 Mar 2023 16:03:42 -0400 Subject: [PATCH 033/225] add port-specific modules to support matrix --- docs/shared_bindings_matrix.py | 201 ++++++++++++++++++++------------- 1 file changed, 123 insertions(+), 78 deletions(-) diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index 761e3e29f2..9705e33585 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -31,7 +31,17 @@ import functools from concurrent.futures import ThreadPoolExecutor -SUPPORTED_PORTS = ['atmel-samd', 'broadcom', 'cxd56', 'espressif', 'litex', 'mimxrt10xx', 'nrf', 'raspberrypi', 'stm'] +SUPPORTED_PORTS = [ + "atmel-samd", + "broadcom", + "cxd56", + "espressif", + "litex", + "mimxrt10xx", + "nrf", + "raspberrypi", + "stm", +] ALIASES_BY_BOARD = { "circuitplayground_express": [ @@ -44,16 +54,11 @@ ALIASES_BY_BOARD = { } ALIASES_BRAND_NAMES = { - "circuitplayground_express_4h": - "Adafruit Circuit Playground Express 4-H", - "circuitplayground_express_digikey_pycon2019": - "Circuit Playground Express Digi-Key PyCon 2019", - "edgebadge": - "Adafruit EdgeBadge", - "pyportal_pynt": - "Adafruit PyPortal Pynt", - "gemma_m0_pycon2018": - "Adafruit Gemma M0 PyCon 2018", + "circuitplayground_express_4h": "Adafruit Circuit Playground Express 4-H", + "circuitplayground_express_digikey_pycon2019": "Circuit Playground Express Digi-Key PyCon 2019", + "edgebadge": "Adafruit EdgeBadge", + "pyportal_pynt": "Adafruit PyPortal Pynt", + "gemma_m0_pycon2018": "Adafruit Gemma M0 PyCon 2018", } ADDITIONAL_MODULES = { @@ -72,7 +77,19 @@ ADDITIONAL_MODULES = { "usb": "CIRCUITPY_USB_HOST", } -MODULES_NOT_IN_SHARED_BINDINGS = ["_asyncio", "array", "binascii", "builtins", "collections", "errno", "json", "re", "select", "sys", "ulab"] +MODULES_NOT_IN_BINDINGS = [ + "_asyncio", + "array", + "binascii", + "builtins", + "collections", + "errno", + "json", + "re", + "select", + "sys", + "ulab", +] FROZEN_EXCLUDES = ["examples", "docs", "tests", "utils", "conf.py", "setup.py"] """Files and dirs at the root of a frozen directory that should be ignored. @@ -83,16 +100,23 @@ repository_urls = {} root_dir = pathlib.Path(__file__).resolve().parent.parent + def get_circuitpython_root_dir(): - """ The path to the root './circuitpython' directory. - """ + """The path to the root './circuitpython' directory.""" return root_dir -def get_shared_bindings(): - """ Get a list of modules in shared-bindings based on folder names. - """ - shared_bindings_dir = get_circuitpython_root_dir() / "shared-bindings" - return [item.name for item in shared_bindings_dir.iterdir()] + MODULES_NOT_IN_SHARED_BINDINGS + +def get_bindings(): + """Get a list of modules in shared-bindings and ports/*/bindings based on folder names.""" + shared_bindings_modules = [ + module.name + for module in (get_circuitpython_root_dir() / "shared-bindings").iterdir() + if module.is_dir() + ] + bindings_modules = [] + for d in get_circuitpython_root_dir().glob("ports/*/bindings"): + bindings_modules.extend(module.name for module in d.iterdir() if d.is_dir()) + return shared_bindings_modules + bindings_modules + MODULES_NOT_IN_BINDINGS def get_board_mapping(): @@ -124,8 +148,7 @@ def get_board_mapping(): def read_mpconfig(): - """ Open 'circuitpy_mpconfig.mk' and return the contents. - """ + """Open 'circuitpy_mpconfig.mk' and return the contents.""" configs = [] cpy_mpcfg = get_circuitpython_root_dir() / "py" / "circuitpy_mpconfig.mk" with open(cpy_mpcfg) as mpconfig: @@ -135,14 +158,14 @@ def read_mpconfig(): def build_module_map(): - """ Establish the base of the JSON file, based on the contents from - `configs`. Base will contain module names, if they're part of - the `FULL_BUILD`, or their default value (0, 1, or a list of - modules that determine default [see audiocore, audiomixer, etc.]). + """Establish the base of the JSON file, based on the contents from + `configs`. Base will contain module names, if they're part of + the `FULL_BUILD`, or their default value (0, 1, or a list of + modules that determine default [see audiocore, audiomixer, etc.]). """ base = dict() - modules = get_shared_bindings() + modules = get_bindings() configs = read_mpconfig() full_build = False for module in modules: @@ -150,7 +173,7 @@ def build_module_map(): if module in ADDITIONAL_MODULES: search_identifier = ADDITIONAL_MODULES[module] else: - search_identifier = 'CIRCUITPY_'+module.lstrip("_").upper() + search_identifier = "CIRCUITPY_" + module.lstrip("_").upper() re_pattern = f"{re.escape(search_identifier)}\s*\??=\s*(.+)" find_config = re.findall(re_pattern, configs) if not find_config: @@ -173,21 +196,22 @@ def build_module_map(): return base -def get_settings_from_makefile(port_dir, board_name): - """ Invoke make in a mode which prints the database, then parse it for - settings. - This means that the effect of all Makefile directives is taken - into account, without having to re-encode the logic that sets them - in this script, something that has proved error-prone +def get_settings_from_makefile(port_dir, board_name): + """Invoke make in a mode which prints the database, then parse it for + settings. + + This means that the effect of all Makefile directives is taken + into account, without having to re-encode the logic that sets them + in this script, something that has proved error-prone """ contents = subprocess.run( - ["make", "-C", port_dir, f"BOARD={board_name}", "-qp", "print-CC"], - encoding="utf-8", - errors="replace", - stdout=subprocess.PIPE, - stderr=subprocess.PIPE - ) + ["make", "-C", port_dir, f"BOARD={board_name}", "-qp", "print-CC"], + encoding="utf-8", + errors="replace", + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) # Make signals errors with exit status 2; 0 and 1 are "non-error" statuses if contents.returncode not in (0, 1): error_msg = ( @@ -197,22 +221,23 @@ def get_settings_from_makefile(port_dir, board_name): raise RuntimeError(error_msg) settings = {} - for line in contents.stdout.split('\n'): + for line in contents.stdout.split("\n"): # Handle both = and := definitions. - m = re.match(r'^([A-Z][A-Z0-9_]*) :?= (.*)$', line) + m = re.match(r"^([A-Z][A-Z0-9_]*) :?= (.*)$", line) if m: settings[m.group(1)] = m.group(2) return settings + def get_repository_url(directory): if directory in repository_urls: return repository_urls[directory] readme = None for readme_path in ( - os.path.join(directory, "README.rst"), - os.path.join(os.path.dirname(directory), "README.rst") - ): + os.path.join(directory, "README.rst"), + os.path.join(os.path.dirname(directory), "README.rst"), + ): if os.path.exists(readme_path): readme = readme_path break @@ -220,7 +245,10 @@ def get_repository_url(directory): if readme: with open(readme, "r") as fp: for line in fp.readlines(): - if m := re.match("\s+:target:\s+(http\S+(docs.circuitpython|readthedocs)\S+)\s*", line): + if m := re.match( + "\s+:target:\s+(http\S+(docs.circuitpython|readthedocs)\S+)\s*", + line, + ): path = m.group(1) break if m := re.search("<(http[^>]+)>", line): @@ -233,12 +261,13 @@ def get_repository_url(directory): errors="replace", stdout=subprocess.PIPE, stderr=subprocess.PIPE, - cwd=directory + cwd=directory, ) path = contents.stdout.strip() repository_urls[directory] = path return path + def frozen_modules_from_dirs(frozen_mpy_dirs, withurl): """ Go through the list of frozen directories and extract the python modules. @@ -261,34 +290,36 @@ def frozen_modules_from_dirs(frozen_mpy_dirs, withurl): else: frozen_modules.append(sub.name[:-3]) continue - if next(sub.glob("**/*.py"), None): # tests if not empty + if next(sub.glob("**/*.py"), None): # tests if not empty if withurl: frozen_modules.append((sub.name, url_repository)) else: frozen_modules.append(sub.name) return frozen_modules -def lookup_setting(settings, key, default=''): + +def lookup_setting(settings, key, default=""): while True: value = settings.get(key, default) - if not value.startswith('$'): + if not value.startswith("$"): break key = value[2:-1] return value + @functools.cache def all_ports_all_boards(ports=SUPPORTED_PORTS): for port in ports: - port_dir = get_circuitpython_root_dir() / "ports" / port for entry in (port_dir / "boards").iterdir(): if not entry.is_dir(): continue yield (port, entry) + def support_matrix_by_board(use_branded_name=True, withurl=True): - """ Compiles a list of the available core modules available for each - board. + """Compiles a list of the available core modules available for each + board. """ base = build_module_map() @@ -300,8 +331,9 @@ def support_matrix_by_board(use_branded_name=True, withurl=True): if use_branded_name: with open(entry / "mpconfigboard.h") as get_name: board_contents = get_name.read() - board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", - board_contents) + board_name_re = re.search( + r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", board_contents + ) if board_name_re: board_name = board_name_re.group(1).strip('"') else: @@ -309,56 +341,69 @@ def support_matrix_by_board(use_branded_name=True, withurl=True): board_modules = [] for module in base: - key = base[module]['key'] - if int(lookup_setting(settings, key, '0')): - board_modules.append(base[module]['name']) + key = base[module]["key"] + if int(lookup_setting(settings, key, "0")): + board_modules.append(base[module]["name"]) board_modules.sort() if "CIRCUITPY_BUILD_EXTENSIONS" in settings: board_extensions = [ - extension.strip() for extension in - settings["CIRCUITPY_BUILD_EXTENSIONS"].split(",") + extension.strip() + for extension in settings["CIRCUITPY_BUILD_EXTENSIONS"].split(",") ] else: raise OSError(f"Board extensions undefined: {board_name}.") frozen_modules = [] if "FROZEN_MPY_DIRS" in settings: - frozen_modules = frozen_modules_from_dirs(settings["FROZEN_MPY_DIRS"], withurl) + frozen_modules = frozen_modules_from_dirs( + settings["FROZEN_MPY_DIRS"], withurl + ) if frozen_modules: frozen_modules.sort() # generate alias boards too - board_matrix = [( - board_name, { - "modules": board_modules, - "frozen_libraries": frozen_modules, - "extensions": board_extensions, - } - )] + board_matrix = [ + ( + board_name, + { + "modules": board_modules, + "frozen_libraries": frozen_modules, + "extensions": board_extensions, + }, + ) + ] if entry.name in ALIASES_BY_BOARD: for alias in ALIASES_BY_BOARD[entry.name]: if use_branded_name: if alias in ALIASES_BRAND_NAMES: alias = ALIASES_BRAND_NAMES[alias] else: - alias = alias.replace("_"," ").title() - board_matrix.append(( - alias, { - "modules": board_modules, - "frozen_libraries": frozen_modules, - "extensions": board_extensions, - }, - )) + alias = alias.replace("_", " ").title() + board_matrix.append( + ( + alias, + { + "modules": board_modules, + "frozen_libraries": frozen_modules, + "extensions": board_extensions, + }, + ) + ) - return board_matrix # this is now a list of (board,modules) + return board_matrix # this is now a list of (board,modules) executor = ThreadPoolExecutor(max_workers=os.cpu_count()) mapped_exec = executor.map(support_matrix, all_ports_all_boards()) # flatmap with comprehensions - boards = dict(sorted([board for matrix in mapped_exec for board in matrix], key=lambda x: x[0])) + boards = dict( + sorted( + [board for matrix in mapped_exec for board in matrix], key=lambda x: x[0] + ) + ) return boards -if __name__ == '__main__': + +if __name__ == "__main__": print(json.dumps(support_matrix_by_board(), indent=2)) From 408406c84fb51c01fa9b2055d44ddcefad00ab60 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Mar 2023 18:09:18 -0500 Subject: [PATCH 034/225] starting diskinfo api --- supervisor/shared/web_workflow/web_workflow.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 97530b970b..8b3250a0ec 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -828,6 +828,46 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request * _send_chunk(socket, ""); } +static void _reply_with_diskinfo_json(socketpool_socket_obj_t *socket, _request *request) { + _send_str(socket, OK_JSON); + _cors_header(socket, request); + _send_str(socket, "\r\n"); + mp_print_t _socket_print = {socket, _print_chunk}; + + const char *hostname = ""; + #if CIRCUITPY_MDNS + if (!common_hal_mdns_server_deinited(&mdns)) { + hostname = common_hal_mdns_server_get_hostname(&mdns); + } + #endif + _update_encoded_ip(); + // Note: this leverages the fact that C concats consecutive string literals together. + mp_printf(&_socket_print, + "{\"web_api_version\": 1, " + "\"version\": \"" MICROPY_GIT_TAG "\", " + "\"build_date\": \"" MICROPY_BUILD_DATE "\", " + "\"board_name\": \"" MICROPY_HW_BOARD_NAME "\", " + "\"mcu_name\": \"" MICROPY_HW_MCU_NAME "\", " + "\"board_id\": \"" CIRCUITPY_BOARD_ID "\", " + "\"creator_id\": %u, " + "\"creation_id\": %u, " + "\"hostname\": \"%s\", " + "\"port\": %d, ", CIRCUITPY_CREATOR_ID, CIRCUITPY_CREATION_ID, hostname, web_api_port, _our_ip_encoded); + #if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0 + uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; + common_hal_mcu_processor_get_uid(raw_id); + mp_printf(&_socket_print, "\"UID\": \""); + for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { + mp_printf(&_socket_print, "%02X", raw_id[i]); + } + mp_printf(&_socket_print, "\", "); + #endif + mp_printf(&_socket_print, "\"ip\": \"%s\"}", _our_ip_encoded); + // Empty chunk signals the end of the response. + _send_chunk(socket, ""); +} + + // FATFS has a two second timestamp resolution but the BLE API allows for nanosecond resolution. // This function truncates the time the time to a resolution storable by FATFS and fills in the // FATFS encoded version into fattime. @@ -1228,6 +1268,8 @@ static bool _reply(socketpool_socket_obj_t *socket, _request *request) { _reply_with_devices_json(socket, request); } else if (strcmp(path, "/version.json") == 0) { _reply_with_version_json(socket, request); + } else if (strcmp(path, "/diskinfo.json") == 0) { + _reply_with_diskinfo_json(socket, request); } else if (strcmp(path, "/serial/") == 0) { if (!request->authenticated) { if (_api_password[0] != '\0') { From f2931dec7aed790e26c8ce1136e097cce0fff7c6 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Mar 2023 18:26:23 -0500 Subject: [PATCH 035/225] empty RUN_BACKGROUND_TASKS for unix port --- ports/unix/mpconfigport.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index c94845229c..237b99bfe8 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -194,6 +194,8 @@ extern const struct _mp_print_t mp_stderr_print; +#define RUN_BACKGROUND_TASKS + #if !(defined(MICROPY_GCREGS_SETJMP) || defined(__x86_64__) || defined(__i386__) || defined(__thumb2__) || defined(__thumb__) || defined(__arm__)) // Fall back to setjmp() implementation for discovery of GC pointers in registers. #define MICROPY_GCREGS_SETJMP (1) From 069a058a83ebb9fbf35bbe3c76691564a830f3ad Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 14 Mar 2023 22:37:56 -0400 Subject: [PATCH 036/225] update build_board_info.py per Neradoc --- tools/build_board_info.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 5209337b95..01d935ac46 100755 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -6,6 +6,7 @@ import json import os +import requests import subprocess import sys import sh @@ -96,7 +97,19 @@ def get_current_info(): response = response.json() git_info = commit_sha, response["sha"] - current_list = json.loads(base64.b64decode(response["content"]).decode("utf-8")) + + if response["content"] != "": + # if the file is there + current_list = json.loads(base64.b64decode(response["content"]).decode("utf-8")) + else: + # if too big, the file is not included + download_url = response["download_url"] + response = requests.get(download_url) + if not response.ok: + print(response.text) + raise RuntimeError("cannot get previous files.json") + current_list = response.json() + current_info = {} for info in current_list: current_info[info["id"]] = info From 60e7df1b0ebaed428871d99077952a4bd4518433 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 14 Mar 2023 22:37:56 -0400 Subject: [PATCH 037/225] update build_board_info.py per Neradoc --- tools/build_board_info.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 5209337b95..01d935ac46 100755 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -6,6 +6,7 @@ import json import os +import requests import subprocess import sys import sh @@ -96,7 +97,19 @@ def get_current_info(): response = response.json() git_info = commit_sha, response["sha"] - current_list = json.loads(base64.b64decode(response["content"]).decode("utf-8")) + + if response["content"] != "": + # if the file is there + current_list = json.loads(base64.b64decode(response["content"]).decode("utf-8")) + else: + # if too big, the file is not included + download_url = response["download_url"] + response = requests.get(download_url) + if not response.ok: + print(response.text) + raise RuntimeError("cannot get previous files.json") + current_list = response.json() + current_info = {} for info in current_list: current_info[info["id"]] = info From 6062e75b0885743fb9f03c4781b8667fde82a2a9 Mon Sep 17 00:00:00 2001 From: Kyle Brown Date: Sat, 19 Nov 2022 12:11:13 -0800 Subject: [PATCH 038/225] add Blok --- .../boards/boardsource_blok/board.c | 45 +++++++++++++++++ .../boards/boardsource_blok/mpconfigboard.h | 4 ++ .../boards/boardsource_blok/mpconfigboard.mk | 14 ++++++ .../boardsource_blok/pico-sdk-configboard.h | 4 ++ .../boards/boardsource_blok/pins.c | 50 +++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 ports/raspberrypi/boards/boardsource_blok/board.c create mode 100644 ports/raspberrypi/boards/boardsource_blok/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/boardsource_blok/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/boardsource_blok/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/boardsource_blok/pins.c diff --git a/ports/raspberrypi/boards/boardsource_blok/board.c b/ports/raspberrypi/boards/boardsource_blok/board.c new file mode 100644 index 0000000000..55540c965a --- /dev/null +++ b/ports/raspberrypi/boards/boardsource_blok/board.c @@ -0,0 +1,45 @@ +/* + * 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" +#include "shared-bindings/microcontroller/Pin.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "supervisor/shared/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + // turn off any left over LED + // board_reset_user_neopixels(&pin_GPIO29, 62); +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/boardsource_blok/mpconfigboard.h b/ports/raspberrypi/boards/boardsource_blok/mpconfigboard.h new file mode 100644 index 0000000000..0ac77bf54e --- /dev/null +++ b/ports/raspberrypi/boards/boardsource_blok/mpconfigboard.h @@ -0,0 +1,4 @@ +#define MICROPY_HW_BOARD_NAME "BLOK" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO29) diff --git a/ports/raspberrypi/boards/boardsource_blok/mpconfigboard.mk b/ports/raspberrypi/boards/boardsource_blok/mpconfigboard.mk new file mode 100644 index 0000000000..aba2838864 --- /dev/null +++ b/ports/raspberrypi/boards/boardsource_blok/mpconfigboard.mk @@ -0,0 +1,14 @@ +USB_VID = 0x2E8A +USB_PID = 0x104A +USB_PRODUCT = "BLOK" +USB_MANUFACTURER = "Boardsource" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel + + +# CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/boardsource_blok/pico-sdk-configboard.h b/ports/raspberrypi/boards/boardsource_blok/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/boardsource_blok/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/boardsource_blok/pins.c b/ports/raspberrypi/boards/boardsource_blok/pins.c new file mode 100644 index 0000000000..e3b0ba0169 --- /dev/null +++ b/ports/raspberrypi/boards/boardsource_blok/pins.c @@ -0,0 +1,50 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + {MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0)}, + {MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1)}, + {MP_ROM_QSTR(MP_QSTR_GP02), MP_ROM_PTR(&pin_GPIO2)}, + {MP_ROM_QSTR(MP_QSTR_GP03), MP_ROM_PTR(&pin_GPIO3)}, + {MP_ROM_QSTR(MP_QSTR_GP04), MP_ROM_PTR(&pin_GPIO4)}, + {MP_ROM_QSTR(MP_QSTR_GP05), MP_ROM_PTR(&pin_GPIO5)}, + {MP_ROM_QSTR(MP_QSTR_GP06), MP_ROM_PTR(&pin_GPIO6)}, + {MP_ROM_QSTR(MP_QSTR_GP07), MP_ROM_PTR(&pin_GPIO7)}, + {MP_ROM_QSTR(MP_QSTR_GP08), MP_ROM_PTR(&pin_GPIO8)}, + {MP_ROM_QSTR(MP_QSTR_GP09), 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_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_GP24), MP_ROM_PTR(&pin_GPIO24)}, + {MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25)}, + {MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO25)}, + {MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26)}, + {MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27)}, + {MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28)}, + {MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29)}, + {MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO16)}, + {MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO17)}, + + {MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO26)}, + {MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO28)}, + {MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO27)}, + + {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_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 4f1627f68e3b931147f94fdbd26b62237f20f683 Mon Sep 17 00:00:00 2001 From: kreasteve Date: Thu, 16 Mar 2023 10:56:22 +0100 Subject: [PATCH 039/225] bugfix --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index ada9f46020..bbf076ba68 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -341,7 +341,10 @@ STATIC mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_ mp_buffer_info_t bufinfo; mp_get_buffer_raise(instruction_obj, &bufinfo, MP_BUFFER_READ); - common_hal_rp2pio_statemachine_run(self, bufinfo.buf, bufinfo.len); + if (bufinfo.len % 2 != 0) { + mp_raise_ValueError(translate("Program size invalid")); + } + common_hal_rp2pio_statemachine_run(self, bufinfo.buf, (size_t)bufinfo.len / 2); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_run_obj, rp2pio_statemachine_run); From d7fb21ec7607fbeeaff4391125cb00f87ffbe148 Mon Sep 17 00:00:00 2001 From: kreasteve Date: Thu, 16 Mar 2023 11:02:41 +0100 Subject: [PATCH 040/225] Revert "bugfix" This reverts commit 4f1627f68e3b931147f94fdbd26b62237f20f683. --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index bbf076ba68..ada9f46020 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -341,10 +341,7 @@ STATIC mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_ mp_buffer_info_t bufinfo; mp_get_buffer_raise(instruction_obj, &bufinfo, MP_BUFFER_READ); - if (bufinfo.len % 2 != 0) { - mp_raise_ValueError(translate("Program size invalid")); - } - common_hal_rp2pio_statemachine_run(self, bufinfo.buf, (size_t)bufinfo.len / 2); + common_hal_rp2pio_statemachine_run(self, bufinfo.buf, bufinfo.len); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_run_obj, rp2pio_statemachine_run); From 208c081c95e70ebbccfd9f9eb2f4b0e1bd9b0eef Mon Sep 17 00:00:00 2001 From: kreasteve Date: Thu, 16 Mar 2023 11:10:57 +0100 Subject: [PATCH 041/225] bugfix_#7706 --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index ada9f46020..bbf076ba68 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -341,7 +341,10 @@ STATIC mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_ mp_buffer_info_t bufinfo; mp_get_buffer_raise(instruction_obj, &bufinfo, MP_BUFFER_READ); - common_hal_rp2pio_statemachine_run(self, bufinfo.buf, bufinfo.len); + if (bufinfo.len % 2 != 0) { + mp_raise_ValueError(translate("Program size invalid")); + } + common_hal_rp2pio_statemachine_run(self, bufinfo.buf, (size_t)bufinfo.len / 2); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_run_obj, rp2pio_statemachine_run); From eab8633a9ef77aae21c3c1af28f1d3b14a1adc1d Mon Sep 17 00:00:00 2001 From: Benjamin Shockley Date: Thu, 16 Mar 2023 16:41:49 -0500 Subject: [PATCH 042/225] Updated Fig Pi Pins and Added Memory Option Updated the Fig Pi pin definition to match latest production and fix errors. Added an optional memory chip for parts shortage issues. --- .../boards/bwshockley_figpi/mpconfigboard.h | 1 - .../boards/bwshockley_figpi/mpconfigboard.mk | 2 +- ports/raspberrypi/boards/bwshockley_figpi/pins.c | 14 ++++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.h b/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.h index fbd03379dd..88847a21bc 100644 --- a/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.h +++ b/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.h @@ -2,7 +2,6 @@ #define MICROPY_HW_MCU_NAME "rp2040" #define MICROPY_HW_NEOPIXEL (&pin_GPIO13) -#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO1) #define CIRCUITPY_BOARD_I2C (2) #define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO17, .sda = &pin_GPIO16}, \ diff --git a/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk b/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk index 95bd9715d6..789816cd70 100644 --- a/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk +++ b/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk @@ -6,4 +6,4 @@ USB_MANUFACTURER = "Benjamin Shockley" CHIP_VARIANT = RP2040 CHIP_FAMILY = rp2 -EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" +EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JVxQ" \ No newline at end of file diff --git a/ports/raspberrypi/boards/bwshockley_figpi/pins.c b/ports/raspberrypi/boards/bwshockley_figpi/pins.c index 1bec6fd91b..1a68e8ec80 100644 --- a/ports/raspberrypi/boards/bwshockley_figpi/pins.c +++ b/ports/raspberrypi/boards/bwshockley_figpi/pins.c @@ -40,23 +40,25 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO23) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO00) }, { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO5) }, - { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO3) }, - { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO2) }, - { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO13) }, - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO00) }, { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO20) }, { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO19) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C0), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C0), 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_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_stemma_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C1), MP_ROM_PTR(&board_stemma_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C1), MP_ROM_PTR(&board_stemma_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From d59a57ecc935c805f20618b12e461b8a4e268a5b Mon Sep 17 00:00:00 2001 From: Benjamin Shockley Date: Thu, 16 Mar 2023 16:54:38 -0500 Subject: [PATCH 043/225] Update pins.c Changed GIO00 to GIO0 --- ports/raspberrypi/boards/bwshockley_figpi/pins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/boards/bwshockley_figpi/pins.c b/ports/raspberrypi/boards/bwshockley_figpi/pins.c index 1a68e8ec80..f178e533fb 100644 --- a/ports/raspberrypi/boards/bwshockley_figpi/pins.c +++ b/ports/raspberrypi/boards/bwshockley_figpi/pins.c @@ -40,11 +40,11 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO23) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO22) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO00) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO13) }, - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO00) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO20) }, From f35af4c9ce86885f89cae31029684340c82b6e91 Mon Sep 17 00:00:00 2001 From: Benjamin Shockley Date: Thu, 16 Mar 2023 16:54:55 -0500 Subject: [PATCH 044/225] Update mpconfigboard.mk Added trailing line --- ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk b/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk index 789816cd70..06c9f2e958 100644 --- a/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk +++ b/ports/raspberrypi/boards/bwshockley_figpi/mpconfigboard.mk @@ -6,4 +6,4 @@ USB_MANUFACTURER = "Benjamin Shockley" CHIP_VARIANT = RP2040 CHIP_FAMILY = rp2 -EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JVxQ" \ No newline at end of file +EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JVxQ" From 058a8e65d841d0bfab9466dd50b84d6849c786c4 Mon Sep 17 00:00:00 2001 From: Carlin Kartchner Date: Thu, 16 Mar 2023 18:22:24 -0400 Subject: [PATCH 045/225] define frame delay before reference --- shared-bindings/gifio/OnDiskGif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index 7fb3fcf2bd..ca77459ac8 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -52,7 +52,7 @@ //| odg = gifio.OnDiskGif('/sample.gif') //| //| start = time.monotonic() -//| odg.next_frame() # Load the first frame +//| next_delay = odg.next_frame() # Load the first frame //| end = time.monotonic() //| overhead = end - start //| From 6ff58fd94af5cf0aa03bae5c1d021b892d4df2d4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 17 Mar 2023 09:37:15 -0500 Subject: [PATCH 046/225] re-enable mkfs for >4GB filesystems whenver FULL_BUILD --- py/circuitpy_mpconfig.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index a514b6a160..641da7814f 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -255,6 +255,10 @@ typedef long mp_off_t; #define MICROPY_FATFS_EXFAT (CIRCUITPY_FULL_BUILD) #endif +#ifndef MICROPY_FF_MKFS_FAT32 +#define MICROPY_FF_MKFS_FAT32 (CIRCUITPY_FULL_BUILD) +#endif + // LONGINT_IMPL_xxx are defined in the Makefile. // #ifdef LONGINT_IMPL_NONE From 5569f101a7ed92ca7242e0d3e86b22442b939dc6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 17 Mar 2023 10:50:07 -0400 Subject: [PATCH 047/225] Document that storage.VfsFat.mkfs() is a @staticmethod --- shared-bindings/storage/__init__.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 8e2eee6511..5e8f32f17e 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -266,6 +266,7 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { //| This property cannot be changed, use `storage.remount` instead.""" //| ... //| +//| @staticmethod //| def mkfs(self) -> None: //| """Format the block device, deleting any data that may have been there""" //| ... From ca292f342795ee36de7263f1024bee166a1415d3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 17 Mar 2023 12:18:24 -0400 Subject: [PATCH 048/225] Turn off mkfs FAT32 on all SAMD21 builds; note in doc --- ports/atmel-samd/mpconfigport.h | 4 +++- shared-bindings/storage/__init__.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 9d4ddd7134..887748c7a0 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -60,7 +60,9 @@ X(EISDIR) \ X(EINVAL) \ -#define MICROPY_FATFS_EXFAT 0 +#define MICROPY_FATFS_EXFAT (0) +// FAT32 mkfs takes about 500 bytes. +#define MICROPY_FF_MKFS_FAT32 (0) // Only support simpler HID descriptors on SAMD21. #define CIRCUITPY_USB_HID_MAX_REPORT_IDS_PER_DESCRIPTOR (1) diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 5e8f32f17e..9e82654bc9 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -268,7 +268,13 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { //| //| @staticmethod //| def mkfs(self) -> None: -//| """Format the block device, deleting any data that may have been there""" +//| """Format the block device, deleting any data that may have been there. +//| +//| **Limitations**: On SAMD21 builds, `mkfs()` will raise ``OSError(22)`` when +//| attempting to format filesystems larger than 4GB. The extra code to format larger +//| filesystems will not fit on these builds. You can still access +//| larger filesystems, but you will need to format the filesystem on another device. +//| """ //| ... //| def open(self, path: str, mode: str) -> None: //| """Like builtin ``open()``""" From f1b7612b5a362d8251dc02180fe667b40a2fd178 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sat, 18 Mar 2023 00:58:43 +0100 Subject: [PATCH 049/225] Add Lilygo T-Watch 2020 V3 (ESP32) - DISPLAY is in, brightness is ok - default busses and pin names - enabled PSRAM --- .../boards/lilygo_twatch_2020_v3/board.c | 161 ++++++++++++++++++ .../lilygo_twatch_2020_v3/mpconfigboard.h | 44 +++++ .../lilygo_twatch_2020_v3/mpconfigboard.mk | 8 + .../boards/lilygo_twatch_2020_v3/pins.c | 54 ++++++ .../boards/lilygo_twatch_2020_v3/sdkconfig | 31 ++++ 5 files changed, 298 insertions(+) create mode 100644 ports/espressif/boards/lilygo_twatch_2020_v3/board.c create mode 100644 ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.h create mode 100644 ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.mk create mode 100644 ports/espressif/boards/lilygo_twatch_2020_v3/pins.c create mode 100644 ports/espressif/boards/lilygo_twatch_2020_v3/sdkconfig diff --git a/ports/espressif/boards/lilygo_twatch_2020_v3/board.c b/ports/espressif/boards/lilygo_twatch_2020_v3/board.c new file mode 100644 index 0000000000..6a60ada6b0 --- /dev/null +++ b/ports/espressif/boards/lilygo_twatch_2020_v3/board.c @@ -0,0 +1,161 @@ +/* + * 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" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" + +#define DELAY 0x80 + +// display init sequence for ST7789 (works in python) +uint8_t display_init_sequence[] = { + // sw reset + 0x01, 0 | DELAY, 0x96, + // sleep out + 0x11, 0 | DELAY, 0xFF, + 0x3A, 1 | DELAY, 0x55, 10, + 0x36, 1, 0x08, + 0x21, 0 | DELAY, 10, + 0x13, 0 | DELAY, 10, + 0x36, 1, 0xC0, + // display on + 0x29, 0 | DELAY, 255, +}; + +static void display_init(void) { + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + + common_hal_busio_spi_construct( + spi, + &pin_GPIO18, // CLK + &pin_GPIO19, // MOSI + NULL, // MISO not connected + false // Not half-duplex + ); + + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + + common_hal_displayio_fourwire_construct( + bus, + spi, + &pin_GPIO27, // DC + &pin_GPIO5, // CS + NULL, // RST + 24000000, // baudrate + 0, // polarity + 0 // phase + ); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + + common_hal_displayio_display_construct( + display, + bus, + 240, // width (after rotation) + 240, // height (after rotation) + 0, // column start + 80, // row start + 0, // rotation + 16, // color depth + false, // grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command + MIPI_COMMAND_WRITE_MEMORY_START, // write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO15, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false, // SH1107_addressing + 5000 // backlight pwm frequency + ); +} + +/* +#define APX202_ADDRESS (0x35) +#define AXP202_LDO2 (2) +#define AXP202_ON (1) +#define AXP202_OFF (0) +#define AXP202_DCDC3 (1) +#define AXP202_IC_TYPE (0x03) +#define AXP202_LDO234_DC23_CTL (0x12) +#define AXP_PASS (1) +#define AXP_FAIL (-1) +#define AXP202_CHIP_ID (0x41) +#define AXP192_CHIP_ID (0x03) +#define FORCED_OPEN_DCDC3(x) (x |= (AXP202_ON << AXP202_DCDC3)) + +static void backlight_init(void) { + // Turn LDO2 on for display + busio_i2c_obj_t *i2c = common_hal_board_create_i2c(0); + uint8_t data = 0; + uint8_t outputReg = 0; + uint8_t read = 0; + // lock + // _readByte(AXP202_LDO234_DC23_CTL, 1, &outputReg) + // time.sleep(0.001) + // _readByte(AXP202_LDO234_DC23_CTL, 1, &data) + // time.sleep(0.001) + // data |= 1 << AXP202_LDO2 + // FORCED_OPEN_DCDC3(data) + // _writeByte(AXP202_LDO234_DC23_CTL, 1, &data) + // time.sleep(0.001) + // unlock +} +*/ + +void board_init(void) { + // Display + display_init(); + // backlight_init(); +} + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + if (pin_number == MOTOR_PIN) { + // no motor + gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(pin_number, false); + return true; + } + return false; +} + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.h b/ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.h new file mode 100644 index 0000000000..bf65b394f7 --- /dev/null +++ b/ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Dan Halbert 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 "Lilygo T-watch 2020 V3" +#define MICROPY_HW_MCU_NAME "ESP32" + +#define MOTOR_PIN (4) +#define MICROPY_HW_LED_STATUS (&pin_GPIO4) + +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO22, .sda = &pin_GPIO21}, \ + {.scl = &pin_GPIO32, .sda = &pin_GPIO23}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO18, .mosi = &pin_GPIO19, .miso = NULL}} + +// UART pins attached to the USB-serial converter chip +#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) +#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3) diff --git a/ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.mk b/ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.mk new file mode 100644 index 0000000000..9d6c8dc25b --- /dev/null +++ b/ports/espressif/boards/lilygo_twatch_2020_v3/mpconfigboard.mk @@ -0,0 +1,8 @@ +CIRCUITPY_CREATOR_ID = 0xC3C30000 +CIRCUITPY_CREATION_ID = 0x00320001 + +IDF_TARGET = esp32 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 16MB diff --git a/ports/espressif/boards/lilygo_twatch_2020_v3/pins.c b/ports/espressif/boards/lilygo_twatch_2020_v3/pins.c new file mode 100644 index 0000000000..8dd20b1a69 --- /dev/null +++ b/ports/espressif/boards/lilygo_twatch_2020_v3/pins.c @@ -0,0 +1,54 @@ +#include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" + +CIRCUITPY_BOARD_BUS_SINGLETON(touch_i2c, i2c, 1) + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + // buzz buzz + { MP_ROM_QSTR(MP_QSTR_VIBRATE), MP_ROM_PTR(&pin_GPIO4) }, + + // I2S out + { MP_ROM_QSTR(MP_QSTR_I2S_SCK), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_I2S_OUT), MP_ROM_PTR(&pin_GPIO33) }, + + // PDM in + { MP_ROM_QSTR(MP_QSTR_PDM_CLK), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_PDM_DATA), MP_ROM_PTR(&pin_GPIO2) }, + + // IR send + { MP_ROM_QSTR(MP_QSTR_IR_LED), MP_ROM_PTR(&pin_GPIO13) }, + + // main I2C port, for the AXP202, and 2 others + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + + // interrupt pins for sensors + { MP_ROM_QSTR(MP_QSTR_BMA423_INT), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_PCF8563_INT), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_AXP202_INT), MP_ROM_PTR(&pin_GPIO35) }, + + // I2C port for the FT6336 touch sensor + { MP_ROM_QSTR(MP_QSTR_TOUCH_SCL), MP_ROM_PTR(&pin_GPIO32) }, + { MP_ROM_QSTR(MP_QSTR_TOUCH_SDA), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_TOUCH_RST), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_TOUCH_I2C), MP_ROM_PTR(&board_touch_i2c_obj) }, + + // LCD display + { MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_LCD_BRIGHTNESS), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_spi_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/lilygo_twatch_2020_v3/sdkconfig b/ports/espressif/boards/lilygo_twatch_2020_v3/sdkconfig new file mode 100644 index 0000000000..89647ab5a1 --- /dev/null +++ b/ports/espressif/boards/lilygo_twatch_2020_v3/sdkconfig @@ -0,0 +1,31 @@ +# SPI RAM config +# +CONFIG_ESP32_SPIRAM_SUPPORT=y +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_SPIRAM_USE_MEMMAP=y +CONFIG_SPIRAM_MEMTEST=y +CONFIG_SPIRAM_CACHE_WORKAROUND=y + +# Uncomment (remove ###) to send ESP_LOG output to TX/RX pins +# +# ESP System Settings +# +CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y +# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set +CONFIG_ESP_CONSOLE_UART_CUSTOM=y +# CONFIG_ESP_CONSOLE_NONE is not set +CONFIG_ESP_CONSOLE_UART=y +CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y +# CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_1 is not set +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_UART_TX_GPIO=1 +CONFIG_ESP_CONSOLE_UART_RX_GPIO=3 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +# CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set +# end of ESP System Settings From a1506df805b127d715f275248d1b82457553a388 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 17 Mar 2023 21:36:13 -0500 Subject: [PATCH 050/225] implement real diskinfo functionality --- supervisor/shared/web_workflow/web_workflow.c | 41 +++++++------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 8b3250a0ec..c006a9e7cb 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -49,6 +49,7 @@ #include "shared-bindings/hashlib/__init__.h" #include "shared-bindings/hashlib/Hash.h" +#include "lib/oofatfs/diskio.h" #if CIRCUITPY_MDNS #include "shared-bindings/mdns/RemoteService.h" @@ -834,35 +835,21 @@ static void _reply_with_diskinfo_json(socketpool_socket_obj_t *socket, _request _send_str(socket, "\r\n"); mp_print_t _socket_print = {socket, _print_chunk}; - const char *hostname = ""; - #if CIRCUITPY_MDNS - if (!common_hal_mdns_server_deinited(&mdns)) { - hostname = common_hal_mdns_server_get_hostname(&mdns); + DWORD free_clusters; + FATFS *fs = filesystem_circuitpy(); + FRESULT blk_result = f_getfree(fs, &free_clusters); + uint16_t block_size; + if (blk_result == FR_OK) { + disk_ioctl(fs, GET_SECTOR_SIZE, &block_size); } - #endif - _update_encoded_ip(); - // Note: this leverages the fact that C concats consecutive string literals together. + + uint16_t total_size = fs->n_fatent - 2; + mp_printf(&_socket_print, - "{\"web_api_version\": 1, " - "\"version\": \"" MICROPY_GIT_TAG "\", " - "\"build_date\": \"" MICROPY_BUILD_DATE "\", " - "\"board_name\": \"" MICROPY_HW_BOARD_NAME "\", " - "\"mcu_name\": \"" MICROPY_HW_MCU_NAME "\", " - "\"board_id\": \"" CIRCUITPY_BOARD_ID "\", " - "\"creator_id\": %u, " - "\"creation_id\": %u, " - "\"hostname\": \"%s\", " - "\"port\": %d, ", CIRCUITPY_CREATOR_ID, CIRCUITPY_CREATION_ID, hostname, web_api_port, _our_ip_encoded); - #if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0 - uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; - common_hal_mcu_processor_get_uid(raw_id); - mp_printf(&_socket_print, "\"UID\": \""); - for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { - mp_printf(&_socket_print, "%02X", raw_id[i]); - } - mp_printf(&_socket_print, "\", "); - #endif - mp_printf(&_socket_print, "\"ip\": \"%s\"}", _our_ip_encoded); + "{\"free\": %d, " + "\"block_size\": %d, " + "\"total\": %d}", free_clusters * block_size, block_size, total_size * block_size); + // Empty chunk signals the end of the response. _send_chunk(socket, ""); } From e7c349ea43d22e1fbc3efb2fa14827087b464ad1 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sat, 18 Mar 2023 15:27:59 +0100 Subject: [PATCH 051/225] Add Lilygo TTGO T-display ESP32 board --- .../lilygo_ttgo_tdisplay_esp32_16m/board.c | 114 ++++++++++++++++++ .../mpconfigboard.h | 34 ++++++ .../mpconfigboard.mk | 10 ++ .../lilygo_ttgo_tdisplay_esp32_16m/pins.c | 41 +++++++ .../lilygo_ttgo_tdisplay_esp32_16m/sdkconfig | 5 + 5 files changed, 204 insertions(+) create mode 100644 ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c create mode 100644 ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.h create mode 100644 ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.mk create mode 100644 ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/pins.c create mode 100644 ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/sdkconfig diff --git a/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c new file mode 100644 index 0000000000..630de0b63f --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c @@ -0,0 +1,114 @@ +/* + * 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" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" + +#define DELAY 0x80 + +// display init sequence according to LilyGO example app +uint8_t display_init_sequence[] = { + 0x01, DELAY, 0x96, // _SWRESET and Delay 150ms + 0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms + 0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD and Delay 10ms + 0x36, 0x01, 0x08, // _MADCTL + 0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms + 0x13, DELAY, 0x0A, // _NORON and Delay 10ms + 0x36, 0x01, 0xC0, // _MADCTL + 0x29, DELAY, 0xFF, // _DISPON and Delay 500ms +}; + +static void display_init(void) { + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + + common_hal_busio_spi_construct( + spi, + &pin_GPIO18, // CLK + &pin_GPIO19, // MOSI + NULL, // MISO not connected + false); // Not half-duplex + + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + + common_hal_displayio_fourwire_construct( + bus, + spi, + &pin_GPIO16, // DC + &pin_GPIO5, // CS + &pin_GPIO23, // RST + 24000000, // baudrate (default from the driver) + // 40000000, + 0, // polarity + 0 // phase + ); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + + common_hal_displayio_display_construct( + display, + bus, + 240, // width (after rotation) + 135, // height (after rotation) + 53, // column start + 40, // row start + 270, // rotation + 16, // color depth + false, // grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command + MIPI_COMMAND_WRITE_MEMORY_START, // write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO4, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false, // SH1107_addressing + 50000 // backlight pwm frequency + ); +} + +void board_init(void) { + // Display + display_init(); +} + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.h b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.h new file mode 100644 index 0000000000..39febafb6a --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.h @@ -0,0 +1,34 @@ +/* + * 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 "LILYGO TTGO T-DISPLAY v1.1" +#define MICROPY_HW_MCU_NAME "ESP32" + +// UART pins attached to the USB-serial converter chip +#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) +#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3) diff --git a/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.mk b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.mk new file mode 100644 index 0000000000..dd177ec1c9 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0xC3C30000 +CIRCUITPY_CREATION_ID = 0x00320002 + +IDF_TARGET = esp32 + +CIRCUITPY_ESP_FLASH_MODE = qio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 16MB + +CIRCUITPY_ESPCAMERA = 0 diff --git a/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/pins.c b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/pins.c new file mode 100644 index 0000000000..5a72b0f416 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/pins.c @@ -0,0 +1,41 @@ +#include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { 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_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_IO25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_IO27), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_IO32), MP_ROM_PTR(&pin_GPIO32) }, + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + + // 1.14 inch LCD ST7789 + { MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_LCD_BCKL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D_C), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, + + // Battery Sense + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO34) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/sdkconfig b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/sdkconfig new file mode 100644 index 0000000000..55052e98ca --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="TTGO-TDISPLAY" +# end of LWIP From d9fee4c354fdebc5470f378cae799adb7a97efac Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 18 Mar 2023 21:28:45 +0700 Subject: [PATCH 052/225] add codespell --- .codespell/exclude-file.txt | 0 .codespell/ignore-words.txt | 4 ++++ .codespellrc | 10 ++++++++++ .pre-commit-config.yaml | 6 ++++++ 4 files changed, 20 insertions(+) create mode 100644 .codespell/exclude-file.txt create mode 100644 .codespell/ignore-words.txt create mode 100644 .codespellrc diff --git a/.codespell/exclude-file.txt b/.codespell/exclude-file.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.codespell/ignore-words.txt b/.codespell/ignore-words.txt new file mode 100644 index 0000000000..84171bfd52 --- /dev/null +++ b/.codespell/ignore-words.txt @@ -0,0 +1,4 @@ +ans +ure +clen +ser diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000000..dd495c65bd --- /dev/null +++ b/.codespellrc @@ -0,0 +1,10 @@ +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to 'ignore-words.txt' (one word per line). +# Or copy & paste the whole problematic line to 'exclude-file.txt' +ignore-words = .codespell/ignore-words.txt +exclude-file = .codespell/exclude-file.txt +check-filenames = +check-hidden = +count = +skip = .cproject,.git,./lib,./locale diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1905b233cf..c1a3a61387 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,12 @@ repos: exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/espressif/esp-idf-config/.*|ports/espressif/boards/.*/sdkconfig)' - id: trailing-whitespace exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|lib/mbedtls_errors/.*)' +- repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + #args: [-w] + exclude: ^locale/ - repo: local hooks: - id: translations From fecc1bdedbfff71448474c654ff543c1dbc52560 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 18 Mar 2023 22:17:02 +0700 Subject: [PATCH 053/225] fix typos (partial) detected by codepell --- .codespell/ignore-words.txt | 13 +++++ .codespellrc | 2 +- .pre-commit-config.yaml | 2 +- devices/ble_hci/common-hal/_bleio/Adapter.c | 2 +- devices/ble_hci/common-hal/_bleio/Adapter.h | 2 +- .../ble_hci/common-hal/_bleio/Connection.c | 2 +- devices/ble_hci/common-hal/_bleio/att.c | 4 +- .../_bleio/hci_include/att_internal.h | 4 +- docs/library/collections.rst | 4 +- examples/natmod/features1/features1.c | 2 +- lib/cmsis/inc/core_armv81mml.h | 4 +- lib/cmsis/inc/core_sc300.h | 2 +- lib/cmsis/inc/mpu_armv8.h | 2 +- lib/libm_dbl/__rem_pio2_large.c | 6 +-- lib/libm_dbl/fmod.c | 2 +- lib/libm_dbl/sqrt.c | 2 +- lib/littlefs/lfs1.h | 12 ++--- lib/littlefs/lfs2.c | 6 +-- lib/littlefs/lfs2.h | 14 +++--- lib/oofatfs/diskio.h | 4 +- lib/oofatfs/ff.c | 48 +++++++++---------- lib/oofatfs/ff.h | 2 +- lib/oofatfs/ffconf.h | 6 +-- lib/oofatfs/ffunicode.c | 2 +- lib/sdmmc/sdmmc_io.c | 2 +- lib/uzlib/tinflate.c | 2 +- locale/circuitpython.pot | 31 ++++++------ .../asf4_conf/samd21/hpl_tc_config.h | 2 +- .../asf4_conf/samd51/hpl_tc_config.h | 2 +- .../asf4_conf/same51/hpl_tc_config.h | 2 +- .../asf4_conf/same54/hpl_tc_config.h | 2 +- .../boards/hallowing_m0_express/board.c | 2 +- ports/atmel-samd/boards/pybadge/board.c | 2 +- ports/atmel-samd/boards/pygamer/board.c | 2 +- ports/atmel-samd/boards/ugame10/board.c | 2 +- .../common-hal/alarm/time/TimeAlarm.c | 2 +- .../common-hal/frequencyio/FrequencyIn.c | 2 +- ports/atmel-samd/mpconfigport.h | 2 +- ports/atmel-samd/sd_mmc/sd_mmc.c | 10 ++-- ports/atmel-samd/sd_mmc/sd_mmc.h | 4 +- ports/atmel-samd/sd_mmc/sd_mmc_protocol.h | 16 +++---- ports/atmel-samd/supervisor/port.c | 4 +- ports/espressif/README.rst | 6 +-- ports/espressif/bindings/espcamera/Camera.c | 4 +- ports/espressif/bindings/espnow/Peer.c | 2 +- ports/espressif/boards/lolin_s2_mini/pins.c | 4 +- .../espressif/boards/m5stack_stick_c/board.c | 2 +- .../waveshare_esp32_s2_pico_lcd/board.c | 2 +- ports/espressif/common-hal/_bleio/Adapter.c | 2 +- .../espressif/common-hal/_bleio/Connection.c | 2 +- .../common-hal/alarm/touch/TouchAlarm.c | 4 +- ports/espressif/common-hal/pulseio/PulseIn.c | 2 +- ports/espressif/common-hal/pwmio/PWMOut.c | 2 +- .../common-hal/rotaryio/IncrementalEncoder.c | 2 +- ports/espressif/i2s_lcd_driver.h | 2 +- ports/litex/boards/fomu/fomu-spi.ld | 2 +- .../common-hal/neopixel_write/__init__.c | 2 +- ports/litex/crt0-vexriscv.S | 2 +- .../common-hal/neopixel_write/__init__.c | 2 +- ports/nrf/Makefile | 2 +- .../s140_nrf52_6.1.0_API/include/ble_l2cap.h | 2 +- .../s140_nrf52_7.0.1_API/include/ble_l2cap.h | 2 +- .../s140_nrf52_7.0.1_API/include/nrf_sdm.h | 4 +- .../boards/feather_nrf52840_express/README.md | 2 +- ports/nrf/boards/hiibot_bluefi/pins.c | 2 +- .../sparkfun_nrf52840_micromod/README.md | 4 +- ports/nrf/common-hal/_bleio/Adapter.c | 4 +- ports/nrf/common-hal/_bleio/Characteristic.c | 2 +- ports/nrf/common-hal/_bleio/Connection.c | 2 +- ports/nrf/common-hal/_bleio/__init__.c | 2 +- .../nrf/common-hal/microcontroller/__init__.c | 2 +- ports/nrf/common-hal/pwmio/PWMOut.c | 2 +- ports/nrf/mpconfigport.h | 2 +- ports/nrf/supervisor/qspi_flash.c | 2 +- ports/raspberrypi/bindings/cyw43/__init__.c | 2 +- ports/raspberrypi/common-hal/ssl/SSLSocket.c | 4 +- ports/raspberrypi/common-hal/wifi/Radio.c | 2 +- ports/raspberrypi/common-hal/wifi/__init__.c | 2 +- ports/stm/boards/common_default.ld | 2 +- ports/stm/boards/common_nvm.ld | 2 +- ports/stm/boards/common_tcm.ld | 2 +- .../stm/boards/espruino_pico/mpconfigboard.mk | 2 +- ports/stm/boards/meowbit_v121/board.c | 2 +- ports/stm/boards/swan_r5/tests/enable_3v3.py | 2 +- ports/stm/common-hal/audiobusio/MEMS_Audio.h | 2 +- .../stm/common-hal/neopixel_write/__init__.c | 2 +- ports/unix/coverage.c | 2 +- ports/unix/modos.c | 2 +- ports/unix/modtermios.c | 2 +- py/asmthumb.c | 2 +- py/circuitpy_mpconfig.h | 2 +- py/circuitpy_mpconfig.mk | 2 +- py/compile.c | 2 +- py/formatfloat.c | 4 +- py/makecompresseddata.py | 2 +- py/mkrules.mk | 4 +- py/objexcept.c | 2 +- py/objtype.c | 2 +- py/runtime.c | 2 +- py/sequence.c | 2 +- shared-bindings/alarm/__init__.c | 2 +- shared-bindings/alarm/__init__.h | 2 +- shared-bindings/audiomp3/__init__.c | 2 +- shared-bindings/bitmaptools/__init__.c | 10 ++-- shared-bindings/board/__init__.c | 2 +- shared-bindings/busio/UART.c | 2 +- shared-bindings/countio/__init__.c | 2 +- shared-bindings/displayio/__init__.c | 2 +- shared-bindings/keypad/Event.c | 2 +- shared-bindings/keypad/KeyMatrix.c | 2 +- shared-bindings/microcontroller/ResetReason.c | 14 +++--- shared-bindings/paralleldisplay/ParallelBus.c | 2 +- shared-bindings/rotaryio/IncrementalEncoder.c | 2 +- shared-module/bitmaptools/__init__.c | 2 +- shared/netutils/dhcpserver.c | 4 +- shared/runtime/pyexec.c | 2 +- .../shared/external_flash/external_flash.c | 2 +- supervisor/shared/safe_mode.c | 2 +- .../shared/translate/compressed_string.h | 2 +- tests/basics/annotate_var.py | 2 +- tests/basics/deque2.py | 4 +- tests/basics/struct1.py | 2 +- tests/cpydiff/core_fstring_repr.py | 2 +- tests/cpydiff/core_import_path.py | 2 +- tests/cpydiff/core_import_split_ns_pkgs.py | 2 +- tests/extmod/framebuf_palette.py | 2 +- tests/extmod/uctypes_sizeof_layout.py | 2 +- tests/extmod/utimeq1.py | 2 +- tests/thread/thread_lock1.py | 2 +- tools/analyze_heap_dump.py | 2 +- tools/cpboard.py | 2 +- tools/gendoc.py | 2 +- tools/makemanifest.py | 2 +- tools/preprocess_frozen_modules.py | 10 ++-- tools/pydfu.py | 2 +- tools/uncrustify.cfg | 14 +++--- tools/verifygitlog.py | 2 +- 137 files changed, 253 insertions(+), 243 deletions(-) diff --git a/.codespell/ignore-words.txt b/.codespell/ignore-words.txt index 84171bfd52..76849278a0 100644 --- a/.codespell/ignore-words.txt +++ b/.codespell/ignore-words.txt @@ -2,3 +2,16 @@ ans ure clen ser +endianess +pris +synopsys +reenable +dout +wel +iput +hsi +astroid +busses +cyphertext +dum +extint diff --git a/.codespellrc b/.codespellrc index dd495c65bd..d4ef112d7a 100644 --- a/.codespellrc +++ b/.codespellrc @@ -7,4 +7,4 @@ exclude-file = .codespell/exclude-file.txt check-filenames = check-hidden = count = -skip = .cproject,.git,./lib,./locale +skip = .cproject,.git,./lib,./locale,ACKNOWLEDGEMENTS diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1a3a61387..1695a883b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: hooks: - id: codespell #args: [-w] - exclude: ^locale/ + exclude: ^(locale/|lib/) - repo: local hooks: - id: translations diff --git a/devices/ble_hci/common-hal/_bleio/Adapter.c b/devices/ble_hci/common-hal/_bleio/Adapter.c index f558d66d40..843c143424 100644 --- a/devices/ble_hci/common-hal/_bleio/Adapter.c +++ b/devices/ble_hci/common-hal/_bleio/Adapter.c @@ -483,7 +483,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t if (self->scan_results != NULL) { if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { - mp_raise_bleio_BluetoothError(translate("Scan already in progess. Stop with stop_scan.")); + mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan.")); } self->scan_results = NULL; } diff --git a/devices/ble_hci/common-hal/_bleio/Adapter.h b/devices/ble_hci/common-hal/_bleio/Adapter.h index 48d4f2e6a2..45a37ad67c 100644 --- a/devices/ble_hci/common-hal/_bleio/Adapter.h +++ b/devices/ble_hci/common-hal/_bleio/Adapter.h @@ -65,7 +65,7 @@ typedef struct _bleio_adapter_obj_t { uint16_t manufacturer; uint16_t lmp_subversion; - // Used to monitor advertising timeout for legacy avertising. + // Used to monitor advertising timeout for legacy advertising. uint64_t advertising_start_ticks; uint64_t advertising_timeout_msecs; // If zero, do not check. diff --git a/devices/ble_hci/common-hal/_bleio/Connection.c b/devices/ble_hci/common-hal/_bleio/Connection.c index 9531231506..e9e1254b43 100644 --- a/devices/ble_hci/common-hal/_bleio/Connection.c +++ b/devices/ble_hci/common-hal/_bleio/Connection.c @@ -515,7 +515,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern // (gattc_char->char_props.write ? CHAR_PROP_WRITE : 0) | // (gattc_char->char_props.write_wo_resp ? CHAR_PROP_WRITE_NO_RESPONSE : 0); -// // Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler. +// // Call common_hal_bleio_characteristic_construct() to initialize some fields and set up evt handler. // common_hal_bleio_characteristic_construct( // characteristic, m_char_discovery_service, gattc_char->handle_value, uuid, // props, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN, diff --git a/devices/ble_hci/common-hal/_bleio/att.c b/devices/ble_hci/common-hal/_bleio/att.c index f649967ca9..9dfe9eb26c 100644 --- a/devices/ble_hci/common-hal/_bleio/att.c +++ b/devices/ble_hci/common-hal/_bleio/att.c @@ -96,7 +96,7 @@ STATIC uint8_t bleio_properties_to_ble_spec_properties(uint8_t bleio_properties) return ble_spec_properties; } -// FIX not currently used; reenable when used. +// FIX not currently used; re-enable when used. #if 0 STATIC uint8_t ble_spec_properties_to_bleio_properties(uint8_t ble_spec_properties) { uint8_t bleio_properties = 0; @@ -964,7 +964,7 @@ static void process_read_group_req(uint16_t conn_handle, uint16_t mtu, uint8_t d // Keep track of the first one to make sure. size_t sizeof_first_service_uuid = 0; - // Size of a single bt_att_group_data chunk. Start with the intial size, and + // Size of a single bt_att_group_data chunk. Start with the initial size, and // add the uuid size in the loop below. size_t data_length = sizeof(struct bt_att_group_data); diff --git a/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h b/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h index af8695da98..0f03894caa 100644 --- a/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h +++ b/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h @@ -150,7 +150,7 @@ struct bt_att_read_mult_req { uint16_t handles[]; } __packed; -/* Read Multiple Respose */ +/* Read Multiple Response */ #define BT_ATT_OP_READ_MULT_RSP 0x0f struct bt_att_read_mult_rsp { uint8_t _dummy[0]; @@ -243,7 +243,7 @@ struct bt_att_read_mult_vl_req { uint16_t handles[]; } __packed; -/* Read Multiple Respose */ +/* Read Multiple Response */ #define BT_ATT_OP_READ_MULT_VL_RSP 0x21 struct bt_att_read_mult_vl_rsp { uint16_t len; diff --git a/docs/library/collections.rst b/docs/library/collections.rst index 2cc1a215d1..01882ba244 100644 --- a/docs/library/collections.rst +++ b/docs/library/collections.rst @@ -16,8 +16,8 @@ Classes .. function:: deque(iterable, maxlen[, flags]) - Deques (double-ended queues) are a list-like container that support O(1) - appends and pops from either side of the deque. New deques are created + Dequeues (double-ended queues) are a list-like container that support O(1) + appends and pops from either side of the deque. New dequeues are created using the following arguments: - *iterable* must be the empty tuple, and the new deque is created empty. diff --git a/examples/natmod/features1/features1.c b/examples/natmod/features1/features1.c index f865f1887c..a5e82252a1 100644 --- a/examples/natmod/features1/features1.c +++ b/examples/natmod/features1/features1.c @@ -88,7 +88,7 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a // This must be first, it sets up the globals dict and other things MP_DYNRUNTIME_INIT_ENTRY - // Messages can be printed as usualy + // Messages can be printed as usually mp_printf(&mp_plat_print, "initialising module self=%p\n", self); // Make the functions available in the module's namespace diff --git a/lib/cmsis/inc/core_armv81mml.h b/lib/cmsis/inc/core_armv81mml.h index 9425dbc321..48428fd650 100644 --- a/lib/cmsis/inc/core_armv81mml.h +++ b/lib/cmsis/inc/core_armv81mml.h @@ -2162,7 +2162,7 @@ __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + (PriorityGroupTmp << 8U) ); /* Insert write key and priority group */ SCB->AIRCR = reg_value; } @@ -2536,7 +2536,7 @@ __STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + (PriorityGroupTmp << 8U) ); /* Insert write key and priority group */ SCB_NS->AIRCR = reg_value; } diff --git a/lib/cmsis/inc/core_sc300.h b/lib/cmsis/inc/core_sc300.h index 5478ea74a5..cbbac7e82c 100644 --- a/lib/cmsis/inc/core_sc300.h +++ b/lib/cmsis/inc/core_sc300.h @@ -1467,7 +1467,7 @@ __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ + (PriorityGroupTmp << 8U) ); /* Insert write key and priority group */ SCB->AIRCR = reg_value; } diff --git a/lib/cmsis/inc/mpu_armv8.h b/lib/cmsis/inc/mpu_armv8.h index 8002738606..84fdd323ae 100644 --- a/lib/cmsis/inc/mpu_armv8.h +++ b/lib/cmsis/inc/mpu_armv8.h @@ -84,7 +84,7 @@ * \param SH Defines the Shareability domain for this memory region. * \param RO Read-Only: Set to 1 for a read-only memory region. * \param NP Non-Privileged: Set to 1 for a non-privileged memory region. -* \oaram XN eXecute Never: Set to 1 for a non-executable memory region. +* \param XN eXecute Never: Set to 1 for a non-executable memory region. */ #define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \ ((BASE & MPU_RBAR_BASE_Msk) | \ diff --git a/lib/libm_dbl/__rem_pio2_large.c b/lib/libm_dbl/__rem_pio2_large.c index 958f28c255..2d1904efc3 100644 --- a/lib/libm_dbl/__rem_pio2_large.c +++ b/lib/libm_dbl/__rem_pio2_large.c @@ -40,14 +40,14 @@ * z = (z-x[i])*2**24 * * - * y[] ouput result in an array of double precision numbers. + * y[] output result in an array of double precision numbers. * The dimension of y[] is: * 24-bit precision 1 * 53-bit precision 2 * 64-bit precision 2 * 113-bit precision 3 * The actual value is the sum of them. Thus for 113-bit - * precison, one may have to do something like: + * precision, one may have to do something like: * * long double t,w,r_head, r_tail; * t = (long double)y[2] + (long double)y[1]; @@ -78,7 +78,7 @@ * jk+1 must be 2 larger than you might expect so that our * recomputation test works. (Up to 24 bits in the integer * part (the 24 bits of it that we compute) and 23 bits in - * the fraction part may be lost to cancelation before we + * the fraction part may be lost to cancellation before we * recompute.) * * jz local integer variable indicating the number of diff --git a/lib/libm_dbl/fmod.c b/lib/libm_dbl/fmod.c index 6849722bac..cf03aacdb2 100644 --- a/lib/libm_dbl/fmod.c +++ b/lib/libm_dbl/fmod.c @@ -9,7 +9,7 @@ double fmod(double x, double y) int sx = ux.i>>63; uint64_t i; - /* in the followings uxi should be ux.i, but then gcc wrongly adds */ + /* in the following uxi should be ux.i, but then gcc wrongly adds */ /* float load/store to inner loops ruining performance and code size */ uint64_t uxi = ux.i; diff --git a/lib/libm_dbl/sqrt.c b/lib/libm_dbl/sqrt.c index b277567385..194b09fb52 100644 --- a/lib/libm_dbl/sqrt.c +++ b/lib/libm_dbl/sqrt.c @@ -37,7 +37,7 @@ * If (2) is false, then q = q ; otherwise q = q + 2 . * i+1 i i+1 i * - * With some algebric manipulation, it is not difficult to see + * With some algebraic manipulation, it is not difficult to see * that (2) is equivalent to * -(i+1) * s + 2 <= y (3) diff --git a/lib/littlefs/lfs1.h b/lib/littlefs/lfs1.h index 355c145d08..08f0b193c8 100644 --- a/lib/littlefs/lfs1.h +++ b/lib/littlefs/lfs1.h @@ -94,7 +94,7 @@ enum lfs1_open_flags { LFS1_F_DIRTY = 0x10000, // File does not match storage LFS1_F_WRITING = 0x20000, // File has been written since last flush LFS1_F_READING = 0x40000, // File has been read since last flush - LFS1_F_ERRED = 0x80000, // An error occured during write + LFS1_F_ERRED = 0x80000, // An error occurred during write }; // File seek flags @@ -111,25 +111,25 @@ struct lfs1_config { // information to the block device operations void *context; - // Read a region in a block. Negative error codes are propogated + // Read a region in a block. Negative error codes are propagated // to the user. int (*read)(const struct lfs1_config *c, lfs1_block_t block, lfs1_off_t off, void *buffer, lfs1_size_t size); // Program a region in a block. The block must have previously - // been erased. Negative error codes are propogated to the user. + // been erased. Negative error codes are propagated to the user. // May return LFS1_ERR_CORRUPT if the block should be considered bad. int (*prog)(const struct lfs1_config *c, lfs1_block_t block, lfs1_off_t off, const void *buffer, lfs1_size_t size); // Erase a block. A block must be erased before being programmed. // The state of an erased block is undefined. Negative error codes - // are propogated to the user. + // are propagated to the user. // May return LFS1_ERR_CORRUPT if the block should be considered bad. int (*erase)(const struct lfs1_config *c, lfs1_block_t block); // Sync the state of the underlying block device. Negative error codes - // are propogated to the user. + // are propagated to the user. int (*sync)(const struct lfs1_config *c); // Minimum size of a block read. This determines the size of read buffers. @@ -484,7 +484,7 @@ int lfs1_dir_rewind(lfs1_t *lfs1, lfs1_dir_t *dir); // Returns a negative error code on failure. int lfs1_traverse(lfs1_t *lfs1, int (*cb)(void*, lfs1_block_t), void *data); -// Prunes any recoverable errors that may have occured in the filesystem +// Prunes any recoverable errors that may have occurred in the filesystem // // Not needed to be called by user unless an operation is interrupted // but the filesystem is still mounted. This is already called on first diff --git a/lib/littlefs/lfs2.c b/lib/littlefs/lfs2.c index 39bd2f0d1c..7f3519acd2 100644 --- a/lib/littlefs/lfs2.c +++ b/lib/littlefs/lfs2.c @@ -1449,7 +1449,7 @@ static int lfs2_dir_alloc(lfs2_t *lfs2, lfs2_mdir_t *dir) { } } - // zero for reproducability in case initial block is unreadable + // zero for reproducibility in case initial block is unreadable dir->rev = 0; // rather than clobbering one of the blocks we just pretend @@ -1643,7 +1643,7 @@ static int lfs2_dir_compact(lfs2_t *lfs2, return err; } - // welp, we tried, if we ran out of space there's not much + // whelp, we tried, if we ran out of space there's not much // we can do, we'll error later if we've become frozen if (!err) { end = begin; @@ -4037,7 +4037,7 @@ static int lfs2_fs_relocate(lfs2_t *lfs2, lfs2_fs_prepmove(lfs2, 0x3ff, NULL); } - // replace bad pair, either we clean up desync, or no desync occured + // replace bad pair, either we clean up desync, or no desync occurred lfs2_pair_tole32(newpair); err = lfs2_dir_commit(lfs2, &parent, LFS2_MKATTRS( {LFS2_MKTAG_IF(moveid != 0x3ff, diff --git a/lib/littlefs/lfs2.h b/lib/littlefs/lfs2.h index f3b66d76ff..b819aaa3b5 100644 --- a/lib/littlefs/lfs2.h +++ b/lib/littlefs/lfs2.h @@ -159,34 +159,34 @@ struct lfs2_config { // information to the block device operations void *context; - // Read a region in a block. Negative error codes are propogated + // Read a region in a block. Negative error codes are propagated // to the user. int (*read)(const struct lfs2_config *c, lfs2_block_t block, lfs2_off_t off, void *buffer, lfs2_size_t size); // Program a region in a block. The block must have previously - // been erased. Negative error codes are propogated to the user. + // been erased. Negative error codes are propagated to the user. // May return LFS2_ERR_CORRUPT if the block should be considered bad. int (*prog)(const struct lfs2_config *c, lfs2_block_t block, lfs2_off_t off, const void *buffer, lfs2_size_t size); // Erase a block. A block must be erased before being programmed. // The state of an erased block is undefined. Negative error codes - // are propogated to the user. + // are propagated to the user. // May return LFS2_ERR_CORRUPT if the block should be considered bad. int (*erase)(const struct lfs2_config *c, lfs2_block_t block); // Sync the state of the underlying block device. Negative error codes - // are propogated to the user. + // are propagated to the user. int (*sync)(const struct lfs2_config *c); #ifdef LFS2_THREADSAFE // Lock the underlying block device. Negative error codes - // are propogated to the user. + // are propagated to the user. int (*lock)(const struct lfs2_config *c); // Unlock the underlying block device. Negative error codes - // are propogated to the user. + // are propagated to the user. int (*unlock)(const struct lfs2_config *c); #endif @@ -479,7 +479,7 @@ int lfs2_stat(lfs2_t *lfs2, const char *path, struct lfs2_info *info); // Returns the size of the attribute, or a negative error code on failure. // Note, the returned size is the size of the attribute on disk, irrespective // of the size of the buffer. This can be used to dynamically allocate a buffer -// or check for existance. +// or check for existence. lfs2_ssize_t lfs2_getattr(lfs2_t *lfs2, const char *path, uint8_t type, void *buffer, lfs2_size_t size); diff --git a/lib/oofatfs/diskio.h b/lib/oofatfs/diskio.h index d886bdd9cc..00768cac72 100644 --- a/lib/oofatfs/diskio.h +++ b/lib/oofatfs/diskio.h @@ -3,7 +3,7 @@ */ /*-----------------------------------------------------------------------/ -/ Low level disk interface modlue include file (C)ChaN, 2014 / +/ Low level disk interface module include file (C)ChaN, 2014 / /-----------------------------------------------------------------------*/ #ifndef _DISKIO_DEFINED @@ -42,7 +42,7 @@ DRESULT disk_ioctl (void *drv, BYTE cmd, void* buff); #define STA_PROTECT 0x04 /* Write protected */ -/* Command code for disk_ioctrl fucntion */ +/* Command code for disk_ioctrl function */ /* Generic command (Used by FatFs) */ #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ diff --git a/lib/oofatfs/ff.c b/lib/oofatfs/ff.c index dbcfa3efc3..a4c17f0560 100644 --- a/lib/oofatfs/ff.c +++ b/lib/oofatfs/ff.c @@ -996,7 +996,7 @@ static FRESULT dec_lock ( /* Decrement object open counter */ if (n == 0) Files[i].fs = 0; /* Delete the entry if open count gets zero */ res = FR_OK; } else { - res = FR_INT_ERR; /* Invalid index nunber */ + res = FR_INT_ERR; /* Invalid index number */ } return res; } @@ -1990,7 +1990,7 @@ static void gen_numname ( seq = (UINT)sr; } - /* itoa (hexdecimal) */ + /* itoa (hexadecimal) */ i = 7; do { c = (BYTE)((seq % 16) + '0'); @@ -2098,7 +2098,7 @@ static DWORD xsum32 ( /* Returns 32-bit checksum */ /*------------------------------------------------------*/ static void get_xfileinfo ( - BYTE* dirb, /* Pointer to the direcotry entry block 85+C0+C1s */ + BYTE* dirb, /* Pointer to the directory entry block 85+C0+C1s */ FILINFO* fno /* Buffer to store the extracted file information */ ) { @@ -2135,16 +2135,16 @@ static void get_xfileinfo ( /*-----------------------------------*/ -/* exFAT: Get a directry entry block */ +/* exFAT: Get a directory entry block */ /*-----------------------------------*/ static FRESULT load_xdir ( /* FR_INT_ERR: invalid entry block */ - DIR* dp /* Reading direcotry object pointing top of the entry block to load */ + DIR* dp /* Reading directory object pointing top of the entry block to load */ ) { FRESULT res; UINT i, sz_ent; - BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory direcotry entry block 85+C0+C1s */ + BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory directory entry block 85+C0+C1s */ /* Load file-directory entry */ @@ -2208,7 +2208,7 @@ static void init_alloc_info ( /*------------------------------------------------*/ static FRESULT load_obj_xdir ( - DIR* dp, /* Blank directory object to be used to access containing direcotry */ + DIR* dp, /* Blank directory object to be used to access containing directory */ const FFOBJID* obj /* Object with its containing directory information */ ) { @@ -2237,18 +2237,18 @@ static FRESULT load_obj_xdir ( /*----------------------------------------*/ static FRESULT store_xdir ( - DIR* dp /* Pointer to the direcotry object */ + DIR* dp /* Pointer to the directory object */ ) { FRESULT res; UINT nent; - BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the direcotry entry block 85+C0+C1s */ + BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the directory entry block 85+C0+C1s */ /* Create set sum */ st_word(dirb + XDIR_SetSum, xdir_sum(dirb)); nent = dirb[XDIR_NumSec] + 1; - /* Store the direcotry entry block to the directory */ + /* Store the directory entry block to the directory */ res = dir_sdi(dp, dp->blk_ofs); while (res == FR_OK) { res = move_window(dp->obj.fs, dp->sect); @@ -2265,11 +2265,11 @@ static FRESULT store_xdir ( /*-------------------------------------------*/ -/* exFAT: Create a new directory enrty block */ +/* exFAT: Create a new directory entry block */ /*-------------------------------------------*/ static void create_xdir ( - BYTE* dirb, /* Pointer to the direcotry entry block buffer */ + BYTE* dirb, /* Pointer to the directory entry block buffer */ const WCHAR* lfn /* Pointer to the object name */ ) { @@ -2690,7 +2690,7 @@ static void get_fileinfo ( fno->altname[di] = 0; /* Terminate the SFN (null string means SFN is invalid) */ if (fno->fname[0] == 0) { /* If LFN is invalid, altname[] needs to be copied to fname[] */ - if (di == 0) { /* If LFN and SFN both are invalid, this object is inaccesible */ + if (di == 0) { /* If LFN and SFN both are invalid, this object is inaccessible */ fno->fname[di++] = '?'; } else { for (si = di = 0, lcf = NS_BODY; fno->altname[si]; si++, di++) { /* Copy altname[] to fname[] with case information */ @@ -2764,7 +2764,7 @@ static DWORD get_achar ( /* Get a character and advances ptr */ static int pattern_matching ( /* 0:not matched, 1:matched */ const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ + const TCHAR* name, /* String to be tested */ int skip, /* Number of pre-skip chars (number of ?s) */ int inf /* Infinite search (* specified) */ ) @@ -2775,12 +2775,12 @@ static int pattern_matching ( /* 0:not matched, 1:matched */ while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ + if (!get_achar(&name)) return 0; /* Branch mismatched if less name chars */ } if (*pat == 0 && inf) return 1; /* (short circuit) */ do { - pp = pat; np = nam; /* Top of pattern and name to match */ + pp = pat; np = name; /* Top of pattern and name to match */ for (;;) { if (*pp == '?' || *pp == '*') { /* Wildcard? */ nm = nx = 0; @@ -2795,7 +2795,7 @@ static int pattern_matching ( /* 0:not matched, 1:matched */ if (pc != nc) break; /* Branch mismatched? */ if (pc == 0) return 1; /* Branch matched? (matched at end of both strings) */ } - get_achar(&nam); /* nam++ */ + get_achar(&name); /* name++ */ } while (inf && nc); /* Retry until end of name if infinite search is specified */ return 0; @@ -3183,7 +3183,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */ } while (LD2PT(fs) == 0 && fmt >= 2 && ++i < 4); } - if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ + if (fmt == 4) return FR_DISK_ERR; /* An error occurred in the disk I/O layer */ if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */ /* An FAT volume is found (bsect). Following code initializes the filesystem object */ @@ -3221,7 +3221,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred fs->volbase = bsect; fs->database = bsect + ld_dword(fs->win + BPB_DataOfsEx); fs->fatbase = bsect + ld_dword(fs->win + BPB_FatOfsEx); - if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size requiered) */ + if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size required) */ fs->dirbase = ld_dword(fs->win + BPB_RootClusEx); /* Get bitmap location and check if it is contiguous (implementation assumption) */ @@ -3365,7 +3365,7 @@ static FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */ if (obj && obj->fs && obj->fs->fs_type && obj->id == obj->fs->id) { /* Test if the object is valid */ #if FF_FS_REENTRANT if (lock_fs(obj->fs)) { /* Obtain the filesystem object */ - if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */ + if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the physical drive is kept initialized */ res = FR_OK; } else { unlock_fs(obj->fs, FR_OK); @@ -3374,7 +3374,7 @@ static FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */ res = FR_TIMEOUT; } #else - if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */ + if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the physical drive is kept initialized */ res = FR_OK; } #endif @@ -3528,7 +3528,7 @@ FRESULT f_open ( } } else { /* Open an existing file */ - if (res == FR_OK) { /* Is the object exsiting? */ + if (res == FR_OK) { /* Is the object existing? */ if (dj.obj.attr & AM_DIR) { /* File open against a directory */ res = FR_NO_FILE; } else { @@ -4339,7 +4339,7 @@ FRESULT f_opendir ( FREE_NAMBUF(); if (res == FR_NO_FILE) res = FR_NO_PATH; } - if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function faild */ + if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function failed */ LEAVE_FF(fs, res); } @@ -4779,7 +4779,7 @@ FRESULT f_mkdir ( st_clust(fs, fs->win + SZDIRE, pcl); fs->wflag = 1; } - res = dir_register(&dj); /* Register the object to the parent directoy */ + res = dir_register(&dj); /* Register the object to the parent directory */ } } if (res == FR_OK) { diff --git a/lib/oofatfs/ff.h b/lib/oofatfs/ff.h index b133d770db..fe731eb694 100644 --- a/lib/oofatfs/ff.h +++ b/lib/oofatfs/ff.h @@ -240,7 +240,7 @@ typedef struct { WORD ftime; /* Modified time */ BYTE fattrib; /* File attribute */ #if FF_USE_LFN - TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */ + TCHAR altname[FF_SFN_BUF + 1];/* Alternative file name */ TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */ #else TCHAR fname[12 + 1]; /* File name */ diff --git a/lib/oofatfs/ffconf.h b/lib/oofatfs/ffconf.h index 52ff6d0a7a..bcd7ee5baf 100644 --- a/lib/oofatfs/ffconf.h +++ b/lib/oofatfs/ffconf.h @@ -188,7 +188,7 @@ #define FF_LFN_BUF 255 #define FF_SFN_BUF 12 /* This set of options defines size of file name members in the FILINFO structure -/ which is used to read out directory items. These values should be suffcient for +/ which is used to read out directory items. These values should be sufficient for / the file names to read. The maximum possible length of the read file name depends / on character encoding. When LFN is not enabled, these options have no effect. */ @@ -251,7 +251,7 @@ / number and only an FAT volume found on the physical drive will be mounted. / When this function is enabled (1), each logical drive number can be bound to / arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() -/ funciton will be available. */ +/ function will be available. */ #define FF_MIN_SS 512 @@ -316,7 +316,7 @@ #define FF_NORTC_MON 1 #define FF_NORTC_MDAY 1 #define FF_NORTC_YEAR 2018 -/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have +/* The option FF_FS_NORTC switches timestamp function. If the system does not have / any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable / the timestamp function. Every object modified by FatFs will have a fixed timestamp / defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time. diff --git a/lib/oofatfs/ffunicode.c b/lib/oofatfs/ffunicode.c index a04577616a..ce60b42193 100644 --- a/lib/oofatfs/ffunicode.c +++ b/lib/oofatfs/ffunicode.c @@ -3,7 +3,7 @@ /*------------------------------------------------------------------------*/ /* This module will occupy a huge memory in the .const section when the / / FatFs is configured for LFN with DBCS. If the system has any Unicode / -/ utilitiy for the code conversion, this module should be modified to use / +/ utility for the code conversion, this module should be modified to use / / that function to avoid silly memory consumption. / /-------------------------------------------------------------------------*/ /* diff --git a/lib/sdmmc/sdmmc_io.c b/lib/sdmmc/sdmmc_io.c index 17ab291515..68c804982b 100644 --- a/lib/sdmmc/sdmmc_io.c +++ b/lib/sdmmc/sdmmc_io.c @@ -282,7 +282,7 @@ sdmmc_err_t sdmmc_io_rw_extended(sdmmc_card_t* card, int func, return SDMMC_ERR_INVALID_SIZE; } if (datalen == max_byte_transfer_size) { - count = 0; // See 5.3.1 SDIO simplifed spec + count = 0; // See 5.3.1 SDIO simplified spec } else { count = datalen; } diff --git a/lib/uzlib/tinflate.c b/lib/uzlib/tinflate.c index 045952c755..fbee7ce721 100644 --- a/lib/uzlib/tinflate.c +++ b/lib/uzlib/tinflate.c @@ -597,7 +597,7 @@ next_blk: if (res == TINF_DONE && !d->bfinal) { /* the block has ended (without producing more data), but we - can't return without data, so start procesing next block */ + can't return without data, so start processing next block */ goto next_blk; } diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 560dffe6a4..f3e6ffc341 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -188,10 +188,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -200,6 +196,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1229,7 +1229,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1523,10 +1524,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1939,7 +1936,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2252,6 +2249,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2287,11 +2289,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -3044,8 +3041,8 @@ msgid "extra positional arguments given" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/ports/atmel-samd/asf4_conf/samd21/hpl_tc_config.h b/ports/atmel-samd/asf4_conf/samd21/hpl_tc_config.h index d651ca33a8..706c7f4b67 100644 --- a/ports/atmel-samd/asf4_conf/samd21/hpl_tc_config.h +++ b/ports/atmel-samd/asf4_conf/samd21/hpl_tc_config.h @@ -49,7 +49,7 @@ #define CONF_TC3_WAVE_DUTY_VAL 0x1f4 #endif -/* Caculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ +/* Calculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ #if CONF_TC3_PRESCALER < TC_CTRLA_PRESCALER_DIV64_Val #define CONF_TC3_CC0 \ ((uint32_t)(((double)CONF_TC3_WAVE_PER_VAL * CONF_GCLK_TC3_FREQUENCY) / 1000000 / (1 << CONF_TC3_PRESCALER) - 1)) diff --git a/ports/atmel-samd/asf4_conf/samd51/hpl_tc_config.h b/ports/atmel-samd/asf4_conf/samd51/hpl_tc_config.h index 3bc688295b..dc08b6eb23 100644 --- a/ports/atmel-samd/asf4_conf/samd51/hpl_tc_config.h +++ b/ports/atmel-samd/asf4_conf/samd51/hpl_tc_config.h @@ -42,7 +42,7 @@ #define CONF_TC0_WAVE_DUTY_VAL 0x1f4 #endif -/* Caculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ +/* Calculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ #if CONF_TC0_PRESCALER < TC_CTRLA_PRESCALER_DIV64_Val #define CONF_TC0_CC0 \ ((uint32_t)(((double)CONF_TC0_WAVE_PER_VAL * CONF_GCLK_TC0_FREQUENCY) / 1000000 / (1 << CONF_TC0_PRESCALER) - 1)) diff --git a/ports/atmel-samd/asf4_conf/same51/hpl_tc_config.h b/ports/atmel-samd/asf4_conf/same51/hpl_tc_config.h index 3bc688295b..dc08b6eb23 100644 --- a/ports/atmel-samd/asf4_conf/same51/hpl_tc_config.h +++ b/ports/atmel-samd/asf4_conf/same51/hpl_tc_config.h @@ -42,7 +42,7 @@ #define CONF_TC0_WAVE_DUTY_VAL 0x1f4 #endif -/* Caculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ +/* Calculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ #if CONF_TC0_PRESCALER < TC_CTRLA_PRESCALER_DIV64_Val #define CONF_TC0_CC0 \ ((uint32_t)(((double)CONF_TC0_WAVE_PER_VAL * CONF_GCLK_TC0_FREQUENCY) / 1000000 / (1 << CONF_TC0_PRESCALER) - 1)) diff --git a/ports/atmel-samd/asf4_conf/same54/hpl_tc_config.h b/ports/atmel-samd/asf4_conf/same54/hpl_tc_config.h index 3bc688295b..dc08b6eb23 100644 --- a/ports/atmel-samd/asf4_conf/same54/hpl_tc_config.h +++ b/ports/atmel-samd/asf4_conf/same54/hpl_tc_config.h @@ -42,7 +42,7 @@ #define CONF_TC0_WAVE_DUTY_VAL 0x1f4 #endif -/* Caculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ +/* Calculate pwm ccx register value based on WAVE_PER_VAL and Waveform Duty Value */ #if CONF_TC0_PRESCALER < TC_CTRLA_PRESCALER_DIV64_Val #define CONF_TC0_CC0 \ ((uint32_t)(((double)CONF_TC0_WAVE_PER_VAL * CONF_GCLK_TC0_FREQUENCY) / 1000000 / (1 << CONF_TC0_PRESCALER) - 1)) diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index 701dc4a8ec..aeea62d2a2 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -51,7 +51,7 @@ uint8_t display_init_sequence[] = { 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x2a, 0, // _INVOFF 0x36, 1, 0x18, // _MADCTL bottom to top refresh - // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color 0xe0, 16, 0x02, 0x1c, 0x07, 0x12, // _GMCTRP1 Gamma diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index a1cb3a0714..11db1ba0a8 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -50,7 +50,7 @@ uint8_t display_init_sequence[] = { 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x2a, 0, // _INVOFF 0x36, 1, 0b10100000, // _MADCTL for rotation 0 - // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color 0xe0, 16, 0x02, 0x1c, 0x07, 0x12, // _GMCTRP1 Gamma diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index 8ff34f24c5..141365a4a1 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -52,7 +52,7 @@ uint8_t display_init_sequence[] = { 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x2a, 0, // _INVOFF 0x36, 1, 0b10100000, // _MADCTL for rotation 0 - // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color 0xe0, 16, 0x02, 0x1c, 0x07, 0x12, // _GMCTRP1 Gamma diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index 90cf9dff20..9953f27d02 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -52,7 +52,7 @@ uint8_t display_init_sequence[] = { 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x2a, 0, // _INVOFF 0x36, 1, 0xa8, // _MADCTL bottom to top refresh - // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color 0xe0, 16, 0x02, 0x1c, 0x07, 0x12, // _GMCTRP1 Gamma diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c index 2ead87428b..4c1d05feb2 100644 --- a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c @@ -36,7 +36,7 @@ STATIC volatile bool woke_up = false; STATIC mp_float_t wakeup_time; void common_hal_alarm_time_timealarm_construct(alarm_time_timealarm_obj_t *self, mp_float_t monotonic_time) { - // TODO: when issueing light/seep sleep, throw a ValueError if the + // TODO: when issuing light/seep sleep, throw a ValueError if the // time exceeds the maximum value. For light sleep, max = // 2**32 / 16384 = 3 days. For deep sleep, max = 2**32 / 32 // = 1550 days. diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index 22200c5d1c..6d1a3f7c0e 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -482,7 +482,7 @@ uint32_t common_hal_frequencyio_frequencyin_get_item(frequencyio_frequencyin_obj float time_each_event = self->factor / self->frequency; // get the time for each event during actual period float capture_diff = self->factor - self->capture_period; // get the difference of actual and base periods // we only need to adjust if the capture_diff can contain 1 or more events - // if so, we add how many events could have occured during the diff time + // if so, we add how many events could have occurred during the diff time if (time_each_event > capture_diff) { frequency_adjustment = capture_diff / time_each_event; } diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 887748c7a0..73686e1445 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -189,7 +189,7 @@ // - firmware // - internal CIRCUITPY flash filesystem (optional) // - internal config, used to store crystalless clock calibration info (optional) -// - microntroller.nvm (optional) +// - microcontroller.nvm (optional) // Define these regions starting up from the bottom of flash: diff --git a/ports/atmel-samd/sd_mmc/sd_mmc.c b/ports/atmel-samd/sd_mmc/sd_mmc.c index de5a3cfe17..b558922d1f 100644 --- a/ports/atmel-samd/sd_mmc/sd_mmc.c +++ b/ports/atmel-samd/sd_mmc/sd_mmc.c @@ -1073,7 +1073,7 @@ static void sd_mmc_deselect_slot(void) { * \note * This function runs the initialization procedure and the identification * process, then it sets the SD/MMC card in transfer state. - * At last, it will automaticly enable maximum bus width and transfer speed. + * At last, it will automatically enable maximum bus width and transfer speed. * * \return true if success, otherwise false */ @@ -1205,7 +1205,7 @@ static bool sd_mmc_mci_card_init(void) { * \note * This function runs the initialization procedure and the identification * process, then it sets the SD/MMC card in transfer state. - * At last, it will automaticly enable maximum bus width and transfer speed. + * At last, it will automatically enable maximum bus width and transfer speed. * * \return true if success, otherwise false */ @@ -1270,7 +1270,7 @@ static bool sd_mmc_mci_install_mmc(void) { uint8_t retry = 10; while (retry--) { /* Retry is a WORKAROUND for no compliance card (Atmel Internal ref. MMC19): - * These cards seem not ready immediatly + * These cards seem not ready immediately * after the end of busy of mmc_cmd6_set_high_speed()*/ /* Set default block size */ @@ -1427,7 +1427,7 @@ sd_mmc_err_t sd_mmc_wait_end_of_read_blocks(bool abort) { return SD_MMC_OK; } - /* All blocks are transfered then stop read operation */ + /* All blocks are transferred then stop read operation */ if (sd_mmc_nb_block_to_tranfer == 1) { /* Single block transfer, then nothing to do */ sd_mmc_deselect_slot(); @@ -1506,7 +1506,7 @@ sd_mmc_err_t sd_mmc_wait_end_of_write_blocks(bool abort) { return SD_MMC_OK; } - /* All blocks are transfered then stop write operation */ + /* All blocks are transferred then stop write operation */ if (sd_mmc_nb_block_to_tranfer == 1) { /* Single block transfer, then nothing to do */ sd_mmc_deselect_slot(); diff --git a/ports/atmel-samd/sd_mmc/sd_mmc.h b/ports/atmel-samd/sd_mmc/sd_mmc.h index e51bf17e80..667520317c 100644 --- a/ports/atmel-samd/sd_mmc/sd_mmc.h +++ b/ports/atmel-samd/sd_mmc/sd_mmc.h @@ -67,7 +67,7 @@ typedef uint8_t sd_mmc_err_t; /**< Type of return error code */ #define SD_MMC_INIT_ONGOING 1 /**< Card not initialized */ #define SD_MMC_ERR_NO_CARD 2 /**< No SD/MMC card inserted */ #define SD_MMC_ERR_UNUSABLE 3 /**< Unusable card */ -#define SD_MMC_ERR_SLOT 4 /**< Slot unknow */ +#define SD_MMC_ERR_SLOT 4 /**< Slot unknown */ #define SD_MMC_ERR_COMM 5 /**< General communication error */ #define SD_MMC_ERR_PARAM 6 /**< Illeage input parameter */ #define SD_MMC_ERR_WP 7 /**< Card write protected */ @@ -166,7 +166,7 @@ uint32_t sd_mmc_get_capacity(uint8_t slot); * * \param[in] slot Card slot * - * \return true, if write portected + * \return true, if write protected */ bool sd_mmc_is_write_protected(uint8_t slot); diff --git a/ports/atmel-samd/sd_mmc/sd_mmc_protocol.h b/ports/atmel-samd/sd_mmc/sd_mmc_protocol.h index 9b4d8e8e74..c205415559 100644 --- a/ports/atmel-samd/sd_mmc/sd_mmc_protocol.h +++ b/ports/atmel-samd/sd_mmc/sd_mmc_protocol.h @@ -73,8 +73,8 @@ extern "C" { * Responses types: * * R1, R3, R4 & R5 use a 48 bits response protected by a 7bit CRC checksum - * - R1 receiv data not specified - * - R3 receiv OCR + * - R1 receive data not specified + * - R3 receive OCR * - R4, R5 RCA management (MMC only) * - R6, R7 RCA management (SD only) * @@ -115,14 +115,14 @@ typedef uint32_t sdmmc_cmd_def_t; #define SDMMC_RESP_CRC (1lu << 12) // ! Card may send busy #define SDMMC_RESP_BUSY (1lu << 13) -// Open drain for a braodcast command (bc) +// Open drain for a broadcast command (bc) // or to enter in inactive state (MCI only) #define SDMMC_CMD_OPENDRAIN (1lu << 14) // ! To signal a data write operation #define SDMMC_CMD_WRITE (1lu << 15) -// ! To signal a SDIO tranfer in multi byte mode +// ! To signal a SDIO transfer in multi byte mode #define SDMMC_CMD_SDIO_BYTE (1lu << 16) -// ! To signal a SDIO tranfer in block mode +// ! To signal a SDIO transfer in block mode #define SDMMC_CMD_SDIO_BLOCK (1lu << 17) // ! To signal a data transfer in stream mode #define SDMMC_CMD_STREAM (1lu << 18) @@ -132,7 +132,7 @@ typedef uint32_t sdmmc_cmd_def_t; #define SDMMC_CMD_MULTI_BLOCK (1lu << 20) // ! @} -// ! \name Set of flags to define a reponse type +// ! \name Set of flags to define a response type // ! @{ #define SDMMC_CMD_NO_RESP (0) #define SDMMC_CMD_R1 (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC) @@ -324,7 +324,7 @@ typedef uint32_t sdmmc_cmd_def_t; #define SD_MCI_ACMD41_SD_SEND_OP_COND (41 | SDMMC_CMD_R3 | SDMMC_CMD_OPENDRAIN) /** * ACMD41(R1): Send host capacity support information (HCS) and activates the - * card's initilization process + * card's initialization process */ #define SD_SPI_ACMD41_SD_SEND_OP_COND (41 | SDMMC_CMD_R1) /** @@ -440,7 +440,7 @@ typedef uint32_t sdmmc_cmd_def_t; #define SDIO_R5_ERROR (1lu << 11) /**< General error */ #define SDIO_R5_FUNC_NUM (1lu << 9) /**< Invalid function number */ #define SDIO_R5_OUT_OF_RANGE (1lu << 8) /**< Argument out of range */ -#define SDIO_R5_STATUS_ERR (SDIO_R5_ERROR | SDIO_R5_FUNC_NUM | SDIO_R5_OUT_OF_RANGE) // !< Errro status bits mask +#define SDIO_R5_STATUS_ERR (SDIO_R5_ERROR | SDIO_R5_FUNC_NUM | SDIO_R5_OUT_OF_RANGE) // !< Error status bits mask // ! @} // ! \name SDIO state (in R6) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 45b999f1a1..8cba5c61e0 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -307,7 +307,7 @@ safe_mode_t port_init(void) { // because it was hard enough to figure out, and maybe there's // a mistake that could make it work in the future. #if 0 - // Designate QSPI memory mapped region as not cachable. + // Designate QSPI memory mapped region as not cacheable. // Turn off MPU in case it is on. MPU->CTRL = 0; @@ -320,7 +320,7 @@ safe_mode_t port_init(void) { 0b011 << MPU_RASR_AP_Pos | // full read/write access for privileged and user mode 0b000 << MPU_RASR_TEX_Pos | // caching not allowed, strongly ordered 1 << MPU_RASR_S_Pos | // sharable - 0 << MPU_RASR_C_Pos | // not cachable + 0 << MPU_RASR_C_Pos | // not cacheable 0 << MPU_RASR_B_Pos | // not bufferable 0b10111 << MPU_RASR_SIZE_Pos | // 16MB region size 1 << MPU_RASR_ENABLE_Pos // enable this region diff --git a/ports/espressif/README.rst b/ports/espressif/README.rst index 949f3533ae..49f372359b 100644 --- a/ports/espressif/README.rst +++ b/ports/espressif/README.rst @@ -55,7 +55,7 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-C3 to get access to the serial console and REPL and for flashing CircuitPython. +A `USB to UART converter `_ can be used for connecting to ESP32-C3 to get access to the serial console and REPL and for flashing CircuitPython. The following connections need to be made in this case: @@ -92,7 +92,7 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-S2 to get access to the serial console and REPL and for flashing CircuitPython. +A `USB to UART converter `_ can be used for connecting to ESP32-S2 to get access to the serial console and REPL and for flashing CircuitPython. The following connections need to be made in this case: @@ -129,7 +129,7 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-S3 to get access to the serial console and REPL and for flashing CircuitPython. +A `USB to UART converter `_ can be used for connecting to ESP32-S3 to get access to the serial console and REPL and for flashing CircuitPython. The following connections need to be made in this case: diff --git a/ports/espressif/bindings/espcamera/Camera.c b/ports/espressif/bindings/espcamera/Camera.c index 824bc7d3dc..5fb9576e58 100644 --- a/ports/espressif/bindings/espcamera/Camera.c +++ b/ports/espressif/bindings/espcamera/Camera.c @@ -63,7 +63,7 @@ //| """ //| Configure and initialize a camera with the given properties //| -//| This driver requires that the ``CIRCUITPY_RESERVED_PSRAM`` in ``settings.toml`` be large enough to hold the camera frambuffer(s). Generally, boards with built-in cameras will have a default setting that is large enough. If the constructor raises a MemoryError or an IDFError, this probably indicates the setting is too small and should be increased. +//| This driver requires that the ``CIRCUITPY_RESERVED_PSRAM`` in ``settings.toml`` be large enough to hold the camera framebuffer(s). Generally, boards with built-in cameras will have a default setting that is large enough. If the constructor raises a MemoryError or an IDFError, this probably indicates the setting is too small and should be increased. //| //| //| .. important:: @@ -89,7 +89,7 @@ //| :param reset_pin: The reset input to the camera module //| :param pixel_format: The pixel format of the captured image //| :param frame_size: The size of captured image -//| :param jpeg_quality: For `PixelFormat.JPEG`, the quality. Higher numbers increase quality. If the quality is too high, the JPEG data will be larger than the availalble buffer size and the image will be unusable or truncated. The exact range of appropriate values depends on the sensor and must be determined empirically. +//| :param jpeg_quality: For `PixelFormat.JPEG`, the quality. Higher numbers increase quality. If the quality is too high, the JPEG data will be larger than the available buffer size and the image will be unusable or truncated. The exact range of appropriate values depends on the sensor and must be determined empirically. //| :param framebuffer_count: The number of framebuffers (1 for single-buffered and 2 for double-buffered) //| :param grab_mode: When to grab a new frame //| """ diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index 7b6cc5f668..ca756409a6 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -32,7 +32,7 @@ #include "common-hal/espnow/__init__.h" // TODO: check peer already exist -// TODO: check peer dosen't exist +// TODO: check peer doesn't exist //| class Peer: //| """A data class to store parameters specific to a peer.""" diff --git a/ports/espressif/boards/lolin_s2_mini/pins.c b/ports/espressif/boards/lolin_s2_mini/pins.c index a4b18c4e9b..ee81e00d9e 100644 --- a/ports/espressif/boards/lolin_s2_mini/pins.c +++ b/ports/espressif/boards/lolin_s2_mini/pins.c @@ -4,7 +4,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS // S2 Mini Board bottom, right, top-bottom - // GPIO0-GPIO14: broken out as a bloc on ESP32-S2FN4R2 SoC + // GPIO0-GPIO14: broken out as a block on ESP32-S2FN4R2 SoC // mpconfigboard.h: GPIO0: CIRCUITPY_BOOT_BUTTON { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, // RTC_GPIO0,GPIO0 @@ -57,7 +57,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // skip GPIO22-GPIO25: not broken out on ESP32-S2FN4R2 SoC // skip GPIO26-GPIO32: SPI Flash & RAM, not broken out on S2 Mini (internal to ESP32-S2FN4R2 SoC?) - // GPIO33-GPIO40: broken out as a bloc on ESP32-S2FN4R2 SoC, last 2 half of JTAG + // GPIO33-GPIO40: broken out as a block on ESP32-S2FN4R2 SoC, last 2 half of JTAG { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },// SPIIO4,GPIO33,FSPIHD { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO33) },// def from Wemos MP { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO33) },// D1 mini pin D2 GPIO4 diff --git a/ports/espressif/boards/m5stack_stick_c/board.c b/ports/espressif/boards/m5stack_stick_c/board.c index bbc0447056..88d0287419 100644 --- a/ports/espressif/boards/m5stack_stick_c/board.c +++ b/ports/espressif/boards/m5stack_stick_c/board.c @@ -193,7 +193,7 @@ static bool pmic_init(void) { } // Reg: 12h - // Enable EXTEN, DCDC1, LDO2 and LDO3 + // Enable EXTENT, DCDC1, LDO2 and LDO3 write_buf[0] = AXP192_DCDC13_LDO23_CTRL; write_buf[1] = AXP192_DCDC13_LDO23_CTRL_EXTEN | AXP192_DCDC13_LDO23_CTRL_LDO3 | diff --git a/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c b/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c index 070e3418da..359263df81 100644 --- a/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c +++ b/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c @@ -51,7 +51,7 @@ uint8_t display_init_sequence[] = { 0xC5, 0x01, 0x0E, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x20, 0x00, // _INVOFF 0x36, 0x01, 0x18, // _MADCTL bottom to top refresh - // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie, // fix on VTL 0x3A, 0x01, 0x05, // COLMOD - 16bit color 0xE0, 0x10, 0x02, 0x1C, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2D, 0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10, // _GMCTRP1 Gamma diff --git a/ports/espressif/common-hal/_bleio/Adapter.c b/ports/espressif/common-hal/_bleio/Adapter.c index 3239c501cc..01adae3adb 100644 --- a/ports/espressif/common-hal/_bleio/Adapter.c +++ b/ports/espressif/common-hal/_bleio/Adapter.c @@ -221,7 +221,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) { if (self->scan_results != NULL) { if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { - mp_raise_bleio_BluetoothError(translate("Scan already in progess. Stop with stop_scan.")); + mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan.")); } self->scan_results = NULL; } diff --git a/ports/espressif/common-hal/_bleio/Connection.c b/ports/espressif/common-hal/_bleio/Connection.c index 75def8ad76..5e3e02d8e5 100644 --- a/ports/espressif/common-hal/_bleio/Connection.c +++ b/ports/espressif/common-hal/_bleio/Connection.c @@ -248,7 +248,7 @@ STATIC int _discovered_characteristic_cb(uint16_t conn_handle, ((chr->properties & BLE_GATT_CHR_PROP_WRITE) != 0 ? CHAR_PROP_WRITE : 0) | ((chr->properties & BLE_GATT_CHR_PROP_WRITE_NO_RSP) != 0 ? CHAR_PROP_WRITE_NO_RESPONSE : 0); - // Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler. + // Call common_hal_bleio_characteristic_construct() to initialize some fields and set up evt handler. common_hal_bleio_characteristic_construct( characteristic, service, chr->val_handle, uuid, props, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN, diff --git a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c index 232614ce32..b58234c9a8 100644 --- a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c @@ -119,7 +119,7 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar for (uint8_t i = 1; i <= 14; i++) { if ((touch_channel_mask & 1 << i) != 0) { touch_pad_t touch_channel = (touch_pad_t)i; - // intialize touchpad + // initialize touchpad peripherals_touch_init(touch_channel); // wait for touch data to reset @@ -166,7 +166,7 @@ void alarm_touch_touchalarm_prepare_for_deep_sleep(void) { peripherals_touch_never_reset(false); peripherals_touch_reset(); - // intialize touchpad + // initialize touchpad peripherals_touch_init(touch_channel); #if !defined(CONFIG_IDF_TARGET_ESP32) diff --git a/ports/espressif/common-hal/pulseio/PulseIn.c b/ports/espressif/common-hal/pulseio/PulseIn.c index bb6ef7f975..42db2f18bd 100644 --- a/ports/espressif/common-hal/pulseio/PulseIn.c +++ b/ports/espressif/common-hal/pulseio/PulseIn.c @@ -123,7 +123,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu rmt_config_t config = RMT_DEFAULT_CONFIG_RX(pin->number, channel); config.rx_config.filter_en = true; config.rx_config.idle_threshold = 30000; // 30*3=90ms idle required to register a sequence - config.clk_div = 240; // All measurements are divided by 3 to accomodate 65ms pulses + config.clk_div = 240; // All measurements are divided by 3 to accommodate 65ms pulses rmt_config(&config); rmt_driver_install(channel, 1000, 0); // TODO: pick a more specific buffer size? diff --git a/ports/espressif/common-hal/pwmio/PWMOut.c b/ports/espressif/common-hal/pwmio/PWMOut.c index 2cb1e6254b..519885a032 100644 --- a/ports/espressif/common-hal/pwmio/PWMOut.c +++ b/ports/espressif/common-hal/pwmio/PWMOut.c @@ -197,7 +197,7 @@ void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t *self) { if (!taken || self->variable_frequency) { ledc_timer_rst(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num); reserved_timer_freq[self->tim_handle.timer_num] = 0; - // if timer isn't varfreq this will be off aleady + // if timer isn't varfreq this will be off already varfreq_timers[self->tim_handle.timer_num] = false; never_reset_tim[self->tim_handle.timer_num] = false; } diff --git a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c index 07b97cf9a3..088f4a15dc 100644 --- a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c @@ -69,7 +69,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode .unit = unit, }; - // Reinitalize same unit, CHANNEL_1 with different parameters. + // Reinitialize same unit, CHANNEL_1 with different parameters. peripherals_pcnt_reinit(&pcnt_config_channel_1); self->pin_a = pin_a->number; diff --git a/ports/espressif/i2s_lcd_driver.h b/ports/espressif/i2s_lcd_driver.h index 0002d6b564..27c4e66b06 100644 --- a/ports/espressif/i2s_lcd_driver.h +++ b/ports/espressif/i2s_lcd_driver.h @@ -44,7 +44,7 @@ typedef struct { } i2s_lcd_config_t; /** - * @brief Initilize i2s lcd driver. + * @brief Initialize i2s lcd driver. * * @param config configuration of i2s * diff --git a/ports/litex/boards/fomu/fomu-spi.ld b/ports/litex/boards/fomu/fomu-spi.ld index e7db25b0c5..33ba3db686 100644 --- a/ports/litex/boards/fomu/fomu-spi.ld +++ b/ports/litex/boards/fomu/fomu-spi.ld @@ -93,7 +93,7 @@ SECTIONS . = ALIGN(4); _etext = .; /* define a global symbol at end of code */ - _sidata = _etext; /* This is used by the startup in order to initialize the .data secion */ + _sidata = _etext; /* This is used by the startup in order to initialize the .data section */ } >FLASH_FIRMWARE /* Uninitialized data section */ diff --git a/ports/litex/common-hal/neopixel_write/__init__.c b/ports/litex/common-hal/neopixel_write/__init__.c index e7e5600fb1..b26bbac695 100644 --- a/ports/litex/common-hal/neopixel_write/__init__.c +++ b/ports/litex/common-hal/neopixel_write/__init__.c @@ -72,7 +72,7 @@ static void ledda_init(void) { // Set clock register to 12 MHz / 64 kHz - 1 ledda_write((12000000 / 64000) - 1, LEDDBR); - // Ensure LED "breathe" effect is diabled + // Ensure LED "breathe" effect is disabled ledda_write(0, LEDDBCRR); ledda_write(0, LEDDBCFR); diff --git a/ports/litex/crt0-vexriscv.S b/ports/litex/crt0-vexriscv.S index 0419acf851..0517711865 100644 --- a/ports/litex/crt0-vexriscv.S +++ b/ports/litex/crt0-vexriscv.S @@ -6,7 +6,7 @@ _start: j crt_init - # This sentinal ensures that this program is loaded + # This sentinel ensures that this program is loaded # to RAM when loaded using dfu-util. #.word 0x17ab0f23 #.word 0x10001000 diff --git a/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c b/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c index 88d0453065..c757a28e6e 100644 --- a/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c +++ b/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c @@ -64,7 +64,7 @@ void PLACE_IN_ITCM(common_hal_neopixel_write)(const digitalio_digitalinout_obj_t const uint32_t pin = digitalinout->pin->number; __disable_irq(); - // Enable DWT in debug core. Useable when interrupts disabled, as opposed to Systick->VAL + // Enable DWT in debug core. Usable when interrupts disabled, as opposed to Systick->VAL CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; DWT->CYCCNT = 0; diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 2267a582a4..412ff86cde 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -241,7 +241,7 @@ FLASHER ?= ifeq ($(FLASHER),) -# Also update to bootloader settting to validate application and skip checksum ( app valid = 0x0001, crc = 0x0000 ) +# Also update to bootloader setting to validate application and skip checksum ( app valid = 0x0001, crc = 0x0000 ) flash: $(BUILD)/firmware.hex nrfjprog --program $< --sectorerase -f $(MCU_VARIANT) nrfjprog --erasepage $(BOOT_SETTING_ADDR) -f $(MCU_VARIANT) diff --git a/ports/nrf/bluetooth/s140_nrf52_6.1.0/s140_nrf52_6.1.0_API/include/ble_l2cap.h b/ports/nrf/bluetooth/s140_nrf52_6.1.0/s140_nrf52_6.1.0_API/include/ble_l2cap.h index d04bec3fbf..e0f005d9b0 100644 --- a/ports/nrf/bluetooth/s140_nrf52_6.1.0/s140_nrf52_6.1.0_API/include/ble_l2cap.h +++ b/ports/nrf/bluetooth/s140_nrf52_6.1.0/s140_nrf52_6.1.0_API/include/ble_l2cap.h @@ -286,7 +286,7 @@ typedef struct /**@brief L2CAP event structure. */ typedef struct { - uint16_t conn_handle; /**< Connection Handle on which the event occured. */ + uint16_t conn_handle; /**< Connection Handle on which the event occurred. */ uint16_t local_cid; /**< Local Channel ID of the L2CAP channel, or @ref BLE_L2CAP_CID_INVALID if not present. */ union diff --git a/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/ble_l2cap.h b/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/ble_l2cap.h index 933f398b57..a624338ceb 100644 --- a/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/ble_l2cap.h +++ b/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/ble_l2cap.h @@ -287,7 +287,7 @@ typedef struct /**@brief L2CAP event structure. */ typedef struct { - uint16_t conn_handle; /**< Connection Handle on which the event occured. */ + uint16_t conn_handle; /**< Connection Handle on which the event occurred. */ uint16_t local_cid; /**< Local Channel ID of the L2CAP channel, or @ref BLE_L2CAP_CID_INVALID if not present. */ union diff --git a/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_sdm.h b/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_sdm.h index 24001fb12a..3def7d6783 100644 --- a/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_sdm.h +++ b/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_sdm.h @@ -275,8 +275,8 @@ typedef struct * If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset(). * * @note It is recommended to either perform a reset in the fault handler or to let the SoftDevice reset the device. - * Otherwise SoC peripherals may behave in an undefined way. For example, the RADIO peripherial may - * continously transmit packets. + * Otherwise SoC peripherals may behave in an undefined way. For example, the RADIO peripheral may + * continuously transmit packets. * * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback. * diff --git a/ports/nrf/boards/feather_nrf52840_express/README.md b/ports/nrf/boards/feather_nrf52840_express/README.md index 8d515010f9..88a78a20fd 100644 --- a/ports/nrf/boards/feather_nrf52840_express/README.md +++ b/ports/nrf/boards/feather_nrf52840_express/README.md @@ -104,7 +104,7 @@ Parsing hex file. Erasing user available code and UICR flash areas. Applying system reset. Checking that the area to write is not protected. -Programing device. +Programming device. Applying system reset. Run. ``` diff --git a/ports/nrf/boards/hiibot_bluefi/pins.c b/ports/nrf/boards/hiibot_bluefi/pins.c index ba1910dc9d..7e0e0a94f4 100644 --- a/ports/nrf/boards/hiibot_bluefi/pins.c +++ b/ports/nrf/boards/hiibot_bluefi/pins.c @@ -117,7 +117,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_P1_13) }, { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_P1_13) }, - // P28~P33/D28~D33 connecte into QSPI FlashROM (W25Q16JV_IQ) + // P28~P33/D28~D33 connected into QSPI FlashROM (W25Q16JV_IQ) { MP_ROM_QSTR(MP_QSTR_P34), MP_ROM_PTR(&pin_P0_22) }, { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_P0_22) }, diff --git a/ports/nrf/boards/sparkfun_nrf52840_micromod/README.md b/ports/nrf/boards/sparkfun_nrf52840_micromod/README.md index 5c41fdb7cf..7040507ba6 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_micromod/README.md +++ b/ports/nrf/boards/sparkfun_nrf52840_micromod/README.md @@ -8,11 +8,11 @@ We've also routed two I2C buses, 2 SPI buses, eleven GPIO, dedicated ## CircuitPython Pin Defs -CircuitPython pin definitions, while simialr to other boards represent a slight departure from just the typical `A` and `D` pin definitions. The majority of general pins are labled as `G` (or alternatively, `BUS`,) as the MicroMod system they build on uses those names to specify pins that may not be specficially analog or digital. +CircuitPython pin definitions, while similar to other boards represent a slight departure from just the typical `A` and `D` pin definitions. The majority of general pins are labeled as `G` (or alternatively, `BUS`,) as the MicroMod system they build on uses those names to specify pins that may not be specficially analog or digital. This can be somewhat confusing, especially around the analog pins. Here's a quick pin-map: -MicroMod Pin # | ATP Pin Label | Pin Definition | Additional Definitons | Pin/Port Reference | Notes +MicroMod Pin # | ATP Pin Label | Pin Definition | Additional Definitions | Pin/Port Reference | Notes :--------------|:--------------|:--------------|:-----------------------|:-------------------|:------ 8 | G11 | | | (Not Connected) | 10 | D0 | D0 | | P0_27 | diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 1c3c829c5b..828ff8806d 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -190,7 +190,7 @@ STATIC uint32_t ble_stack_enable(void) { return err_code; } - // Increase the GATT Server attribute size to accomodate both the CircuitPython built-in service + // Increase the GATT Server attribute size to accommodate both the CircuitPython built-in service // and anything the user does. memset(&ble_conf, 0, sizeof(ble_conf)); // Each increment to the BLE_GATTS_ATTR_TAB_SIZE_DEFAULT multiplier costs 1408 bytes. @@ -529,7 +529,7 @@ STATIC bool scan_on_ble_evt(ble_evt_t *ble_evt, void *scan_results_in) { mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t *prefixes, size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) { if (self->scan_results != NULL) { if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { - mp_raise_bleio_BluetoothError(translate("Scan already in progess. Stop with stop_scan.")); + mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan.")); } self->scan_results = NULL; } diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index df86654c70..e911e5a1e3 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -283,7 +283,7 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, } // Write with response will return NRF_ERROR_BUSY if the response has not been received. - // Write without reponse will return NRF_ERROR_RESOURCES if too many writes are pending. + // Write without response will return NRF_ERROR_RESOURCES if too many writes are pending. if (err_code == NRF_ERROR_BUSY || err_code == NRF_ERROR_RESOURCES) { // We could wait for an event indicating the write is complete, but just retrying is easier. RUN_BACKGROUND_TASKS; diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 0d8d8c32f0..69e6945d21 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -528,7 +528,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio (gattc_char->char_props.write ? CHAR_PROP_WRITE : 0) | (gattc_char->char_props.write_wo_resp ? CHAR_PROP_WRITE_NO_RESPONSE : 0); - // Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler. + // Call common_hal_bleio_characteristic_construct() to initialize some fields and set up evt handler. common_hal_bleio_characteristic_construct( characteristic, m_char_discovery_service, gattc_char->handle_value, uuid, props, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN, diff --git a/ports/nrf/common-hal/_bleio/__init__.c b/ports/nrf/common-hal/_bleio/__init__.c index 718b28c7fe..75bfb60342 100644 --- a/ports/nrf/common-hal/_bleio/__init__.c +++ b/ports/nrf/common-hal/_bleio/__init__.c @@ -249,7 +249,7 @@ void common_hal_bleio_gattc_write(uint16_t handle, uint16_t conn_handle, mp_buff } // Write with response will return NRF_ERROR_BUSY if the response has not been received. - // Write without reponse will return NRF_ERROR_RESOURCES if too many writes are pending. + // Write without response will return NRF_ERROR_RESOURCES if too many writes are pending. if (err_code == NRF_ERROR_BUSY || err_code == NRF_ERROR_RESOURCES) { // We could wait for an event indicating the write is complete, but just retrying is easier. MICROPY_VM_HOOK_LOOP; diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index cd4114dcfb..7824175605 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -55,7 +55,7 @@ void common_hal_mcu_disable_interrupts() { // Unlike __disable_irq(), this should only be called the first time // "is_nested_critical_region" is sd's equivalent of our nesting count // so a nested call would store 0 in the global and make the later - // exit call not actually reenable interrupts + // exit call not actually re-enable interrupts // // This only disables interrupts of priority 2 through 7; levels 0, 1, // and 4, are exclusive to softdevice and should never be used, so diff --git a/ports/nrf/common-hal/pwmio/PWMOut.c b/ports/nrf/common-hal/pwmio/PWMOut.c index f73e3d3952..6171f5eb76 100644 --- a/ports/nrf/common-hal/pwmio/PWMOut.c +++ b/ports/nrf/common-hal/pwmio/PWMOut.c @@ -94,7 +94,7 @@ STATIC void reset_single_pwmout(uint8_t i) { for (int ch = 0; ch < CHANNELS_PER_PWM; ch++) { pwm_seq[i][ch] = (1 << 15); // polarity = 0 - pwm->PSEL.OUT[ch] = 0xFFFFFFFF; // disconnnect from I/O + pwm->PSEL.OUT[ch] = 0xFFFFFFFF; // disconnect from I/O } } diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 99effcea2f..4726d51c55 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -65,7 +65,7 @@ // This also includes mpconfigboard.h. #include "py/circuitpy_mpconfig.h" -// Definitions that might be overriden by mpconfigboard.h +// Definitions that might be overridden by mpconfigboard.h #ifndef CIRCUITPY_INTERNAL_NVM_SIZE #define CIRCUITPY_INTERNAL_NVM_SIZE (8 * 1024) diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index df80671e64..2ae166d3ad 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -59,7 +59,7 @@ static int sck_delay_saved = 0; void qspi_disable(void) { // If VBUS is detected, no need to disable QSPI if (NRF_QSPI->ENABLE && !(NRF_POWER->USBREGSTATUS & POWER_USBREGSTATUS_VBUSDETECT_Msk)) { - // Keep CS high when QSPI is diabled + // Keep CS high when QSPI is disabled nrf_gpio_cfg_output(MICROPY_QSPI_CS); nrf_gpio_pin_write(MICROPY_QSPI_CS, 1); diff --git a/ports/raspberrypi/bindings/cyw43/__init__.c b/ports/raspberrypi/bindings/cyw43/__init__.c index 778da1ab62..520d10263c 100644 --- a/ports/raspberrypi/bindings/cyw43/__init__.c +++ b/ports/raspberrypi/bindings/cyw43/__init__.c @@ -84,7 +84,7 @@ const mp_obj_type_t cyw43_pin_type = { //| The low 4 bits, ``m``, are the power management mode: //| * 0: disabled //| * 1: aggressive power saving which reduces wifi throughput -//| * 2: Power saving with high througput +//| * 2: Power saving with high throughput //| //| The next 8 bits, ``r``, specify "the maximum time to wait before going back to sleep" for power management mode 2. The units of ``r`` are 10ms. //| diff --git a/ports/raspberrypi/common-hal/ssl/SSLSocket.c b/ports/raspberrypi/common-hal/ssl/SSLSocket.c index 67508f16c8..06fe350cb6 100644 --- a/ports/raspberrypi/common-hal/ssl/SSLSocket.c +++ b/ports/raspberrypi/common-hal/ssl/SSLSocket.c @@ -257,7 +257,7 @@ mp_uint_t common_hal_ssl_sslsocket_recv_into(ssl_sslsocket_obj_t *self, uint8_t } else if (ret == MBEDTLS_ERR_SSL_WANT_WRITE) { // If handshake is not finished, read attempt may end up in protocol // wanting to write next handshake message. The same may happen with - // renegotation. + // renegotiation. ret = MP_EWOULDBLOCK; } DEBUG("raising errno [error case] %d\n", ret); @@ -276,7 +276,7 @@ mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t *self, const uint8_t } else if (ret == MBEDTLS_ERR_SSL_WANT_READ) { // If handshake is not finished, write attempt may end up in protocol // wanting to read next handshake message. The same may happen with - // renegotation. + // renegotiation. ret = MP_EWOULDBLOCK; } DEBUG("raising errno [error case] %d\n", ret); diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index ae14d29ade..2ed19a96e7 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -176,7 +176,7 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_ common_hal_wifi_radio_stop_ap(self); - // Channel can only be changed after inital powerup and config of ap. + // Channel can only be changed after initial powerup and config of ap. // Defaults to 1 if not set or invalid (i.e. 13) cyw43_wifi_ap_set_channel(&cyw43_state, (const uint32_t)channel); diff --git a/ports/raspberrypi/common-hal/wifi/__init__.c b/ports/raspberrypi/common-hal/wifi/__init__.c index e5a646f88f..91a45e8d92 100644 --- a/ports/raspberrypi/common-hal/wifi/__init__.c +++ b/ports/raspberrypi/common-hal/wifi/__init__.c @@ -107,7 +107,7 @@ void raise_cyw_error(int err) { mp_errno = MP_ETIMEDOUT; break; default: - mp_raise_OSError_msg_varg(translate("Unkown error code %d"), err); + mp_raise_OSError_msg_varg(translate("Unknown error code %d"), err); } mp_raise_OSError(mp_errno); } diff --git a/ports/stm/boards/common_default.ld b/ports/stm/boards/common_default.ld index 0c7efd01d4..7c96a42bc5 100644 --- a/ports/stm/boards/common_default.ld +++ b/ports/stm/boards/common_default.ld @@ -24,7 +24,7 @@ SECTIONS . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ - /* This first flash block is 16K annd the isr vectors only take up + /* This first flash block is 16K and the isr vectors only take up about 400 bytes. Micropython pads this with files, but this didn't work with the size of Circuitpython's ff object. */ diff --git a/ports/stm/boards/common_nvm.ld b/ports/stm/boards/common_nvm.ld index 91e453bfd9..1d10db8a31 100644 --- a/ports/stm/boards/common_nvm.ld +++ b/ports/stm/boards/common_nvm.ld @@ -26,7 +26,7 @@ SECTIONS . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ - /* This first flash block is 16K annd the isr vectors only take up + /* This first flash block is 16K and the isr vectors only take up about 400 bytes. Micropython pads this with files, but this didn't work with the size of Circuitpython's ff object. */ diff --git a/ports/stm/boards/common_tcm.ld b/ports/stm/boards/common_tcm.ld index 9e677862d3..d7be64d667 100644 --- a/ports/stm/boards/common_tcm.ld +++ b/ports/stm/boards/common_tcm.ld @@ -26,7 +26,7 @@ SECTIONS . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ - /* This first flash block is 16K annd the isr vectors only take up + /* This first flash block is 16K and the isr vectors only take up about 400 bytes. Micropython pads this with files, but this didn't work with the size of Circuitpython's ff object. */ diff --git a/ports/stm/boards/espruino_pico/mpconfigboard.mk b/ports/stm/boards/espruino_pico/mpconfigboard.mk index 6e4da86dd7..0ed5b161a1 100644 --- a/ports/stm/boards/espruino_pico/mpconfigboard.mk +++ b/ports/stm/boards/espruino_pico/mpconfigboard.mk @@ -14,7 +14,7 @@ LD_COMMON = boards/common_default.ld LD_FILE = boards/STM32F401xd_fs.ld # Disable ulab as we're nearly out of space on this board due to -# INTERNAL_FLASH_FILESYSTEM. It can probably be reenabled if we enable +# INTERNAL_FLASH_FILESYSTEM. It can probably be re-enabled if we enable # lto for this port, and if other stuff hasn't been added in the # meantime CIRCUITPY_AESIO = 0 diff --git a/ports/stm/boards/meowbit_v121/board.c b/ports/stm/boards/meowbit_v121/board.c index e4d362bbfa..0edf3d40e4 100644 --- a/ports/stm/boards/meowbit_v121/board.c +++ b/ports/stm/boards/meowbit_v121/board.c @@ -54,7 +54,7 @@ uint8_t display_init_sequence[] = { 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x20, 0, // _INVOFF //MISMATCh 0x2a vs 0x20 0x36, 1, 0x60, // _MADCTL bottom to top refresh - // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color 0xe0, 0x10, 0x02, 0x1c, 0x07, 0x12, diff --git a/ports/stm/boards/swan_r5/tests/enable_3v3.py b/ports/stm/boards/swan_r5/tests/enable_3v3.py index ba955c4f58..c32bbc58b8 100644 --- a/ports/stm/boards/swan_r5/tests/enable_3v3.py +++ b/ports/stm/boards/swan_r5/tests/enable_3v3.py @@ -5,7 +5,7 @@ import digitalio import supervisor import time -# Scenario: Enable 3V3 pin defintiion +# Scenario: Enable 3V3 pin definition # Then the symbol "board.ENABLE_3V3" is defined assert board.ENABLE_3V3 is not None diff --git a/ports/stm/common-hal/audiobusio/MEMS_Audio.h b/ports/stm/common-hal/audiobusio/MEMS_Audio.h index 2f670c8505..77f11dc82f 100644 --- a/ports/stm/common-hal/audiobusio/MEMS_Audio.h +++ b/ports/stm/common-hal/audiobusio/MEMS_Audio.h @@ -35,7 +35,7 @@ extern "C" { /** * @brief How many milliseconds of audio can fit in the audio buffer(s). - * Interrupts for recieved data fire at half this duration / twice the frequency. + * Interrupts for received data fire at half this duration / twice the frequency. */ #ifndef MEMS_AUDIO_MS_BUFFER #define MEMS_AUDIO_MS_BUFFER (1) diff --git a/ports/stm/common-hal/neopixel_write/__init__.c b/ports/stm/common-hal/neopixel_write/__init__.c index 99529793fa..9eb30a4509 100644 --- a/ports/stm/common-hal/neopixel_write/__init__.c +++ b/ports/stm/common-hal/neopixel_write/__init__.c @@ -67,7 +67,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, uint32_t p_mask = pin_mask(digitalinout->pin->number); __disable_irq(); - // Enable DWT in debug core. Useable when interrupts disabled, as opposed to Systick->VAL + // Enable DWT in debug core. Usable when interrupts disabled, as opposed to Systick->VAL CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; DWT->CYCCNT = 0; diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 0e4c6dbd48..b04bc2158c 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -456,7 +456,7 @@ STATIC mp_obj_t extra_coverage(void) { { mp_printf(&mp_plat_print, "# VM\n"); - // call mp_execute_bytecode with invalide bytecode (should raise NotImplementedError) + // call mp_execute_bytecode with invalid bytecode (should raise NotImplementedError) mp_obj_fun_bc_t fun_bc; fun_bc.bytecode = (const byte *)"\x01"; // just needed for n_state mp_code_state_t *code_state = m_new_obj_var(mp_code_state_t, mp_obj_t, 1); diff --git a/ports/unix/modos.c b/ports/unix/modos.c index a6365aa6a3..8373c07a5c 100644 --- a/ports/unix/modos.c +++ b/ports/unix/modos.c @@ -147,7 +147,7 @@ STATIC mp_obj_t mod_os_remove(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); // Note that POSIX requires remove() to be able to delete a directory - // too (act as rmdir()). This is POSIX extenstion to ANSI C semantics + // too (act as rmdir()). This is POSIX extension to ANSI C semantics // of that function. But Python remove() follows ANSI C, and explicitly // required to raise exception on attempt to remove a directory. Thus, // call POSIX unlink() here. diff --git a/ports/unix/modtermios.c b/ports/unix/modtermios.c index 7a578becb9..4adef8a380 100644 --- a/ports/unix/modtermios.c +++ b/ports/unix/modtermios.c @@ -73,7 +73,7 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t // We don't export TCSANOW and friends to save on code space. Then // common lazy sense says that passing 0 should be godo enough, and // it is e.g. for glibc. But for other libc's it's not, so set just - // treat 0 as defauling to TCSANOW. + // treat 0 as defaulting to TCSANOW. when = TCSANOW; } diff --git a/py/asmthumb.c b/py/asmthumb.c index 547e5bedc1..1b1923370b 100644 --- a/py/asmthumb.c +++ b/py/asmthumb.c @@ -281,7 +281,7 @@ bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) { #define OP_BCC_N(cond, byte_offset) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff)) -// all these bit arithmetics need coverage testing! +// all these bit arithmetic need coverage testing! #define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f)) #define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff)) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 641da7814f..b4cbe83b95 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -393,7 +393,7 @@ extern const struct _mp_obj_module_t nvm_module; // Native modules that are weak links can be accessed directly // by prepending their name with an underscore. This list should correspond to // MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS, assuming you want the native modules -// to be accessible when overriden. +// to be accessible when overridden. #define MICROPY_PORT_BUILTIN_MODULE_ALT_NAMES diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c849a12851..046957751a 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -526,7 +526,7 @@ CFLAGS += -DUSB_NUM_ENDPOINT_PAIRS=$(USB_NUM_ENDPOINT_PAIRS) CIRCUITPY_USTACK ?= 0 CFLAGS += -DCIRCUITPY_USTACK=$(CIRCUITPY_USTACK) -# for decompressing utlities +# for decompressing utilities CIRCUITPY_ZLIB ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_ZLIB=$(CIRCUITPY_ZLIB) diff --git a/py/compile.c b/py/compile.c index 432aeca561..3668bee320 100644 --- a/py/compile.c +++ b/py/compile.c @@ -3477,7 +3477,7 @@ mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_f } } - // update maximim number of labels needed + // update maximum number of labels needed if (comp->next_label > max_num_labels) { max_num_labels = comp->next_label; } diff --git a/py/formatfloat.c b/py/formatfloat.c index d75cfc6658..4671f3348b 100644 --- a/py/formatfloat.c +++ b/py/formatfloat.c @@ -39,7 +39,7 @@ Routine for converting a arbitrary floating point number into a string. - The code in this funcion was inspired from Fred Bayer's pdouble.c. + The code in this function was inspired from Fred Bayer's pdouble.c. Since pdouble.c was released as Public Domain, I'm releasing this code as public domain as well. @@ -390,7 +390,7 @@ int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, ch --dec; --num_digits_left; if (digit_index <= 0) { - // Once we get below 1.0, we scale up f instead of calculting + // Once we get below 1.0, we scale up f instead of calculating // negative powers of 10 in u_base. This provides better // renditions of exact decimals like 1/16 etc. f *= FPCONST(10.0); diff --git a/py/makecompresseddata.py b/py/makecompresseddata.py index 9603de8713..1bce3e8e83 100644 --- a/py/makecompresseddata.py +++ b/py/makecompresseddata.py @@ -24,7 +24,7 @@ def check_non_ascii(msg): # Replace with . -# Trival scheme to demo/test. +# Trivial scheme to demo/test. def space_compression(error_strings): for line in error_strings: check_non_ascii(line) diff --git a/py/mkrules.mk b/py/mkrules.mk index ef0f66117d..09ed82ac5b 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -13,7 +13,7 @@ OBJ_EXTRA_ORDER_DEPS = # tree. # # So for example, py/map.c would have an object file name py/map.o -# The object files will go into the build directory and mantain the same +# The object files will go into the build directory and maintain the same # directory structure as the source tree. So the final dependency will look # like this: # @@ -142,7 +142,7 @@ endif ifneq ($(PROG),) # Build a standalone executable (unix does this) -# The executable should have an .exe extension for builds targetting 'pure' +# The executable should have an .exe extension for builds targeting 'pure' # Windows, i.e. msvc or mingw builds, but not when using msys or cygwin's gcc. COMPILER_TARGET := $(shell $(CC) -dumpmachine) ifneq (,$(findstring mingw,$(COMPILER_TARGET))) diff --git a/py/objexcept.c b/py/objexcept.c index 24fb564e23..e05c3ca8d7 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -176,7 +176,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz mp_obj_tuple_t *o_tuple; if (n_args == 0) { - // No args, can use the empty tuple straightaway + // No args, can use the empty tuple straight away o_tuple = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj; } else { // Try to allocate memory for the tuple containing the args diff --git a/py/objtype.c b/py/objtype.c index 76b9551be8..5b04c361e1 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -649,7 +649,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des mp_obj_t member = dest[0]; if (member != MP_OBJ_NULL) { if (!(self->base.type->flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS)) { - // Class doesn't have any special accessors to check so return straightaway + // Class doesn't have any special accessors to check so return straight away return; } diff --git a/py/runtime.c b/py/runtime.c index 9227594d83..5d8be5672f 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -414,7 +414,7 @@ mp_obj_t MICROPY_WRAP_MP_BINARY_OP(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs } else { // standard precision is enough for right-shift if (rhs_val >= (mp_int_t)(sizeof(lhs_val) * MP_BITS_PER_BYTE)) { - // Shifting to big amounts is underfined behavior + // Shifting to big amounts is undefined behavior // in C and is CPU-dependent; propagate sign bit. rhs_val = sizeof(lhs_val) * MP_BITS_PER_BYTE - 1; } diff --git a/py/sequence.c b/py/sequence.c index 7befc85763..42a9a4a0ae 100644 --- a/py/sequence.c +++ b/py/sequence.c @@ -171,7 +171,7 @@ bool mp_seq_cmp_objs(mp_uint_t op, const mp_obj_t *items1, size_t len1, const mp continue; } - // Othewise, if they are not equal, we can have final decision based on them + // Otherwise, if they are not equal, we can have final decision based on them if (op == MP_BINARY_OP_EQUAL) { // In particular, if we are checking for equality, here're the answer return false; diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 29c9b49d3f..94879e14d4 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -71,7 +71,7 @@ //| wake_alarm: Optional[circuitpython_typing.Alarm] //| """The most recently triggered alarm. If CircuitPython was sleeping, the alarm that woke it from sleep. -//| If no alarm occured since the last hard reset or soft restart, value is ``None``. +//| If no alarm occurred since the last hard reset or soft restart, value is ``None``. //| """ //| diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 82bfae4286..c47f482e74 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -33,7 +33,7 @@ #include "common-hal/digitalio/DigitalInOut.h" // Light sleep fully self-contained and does not exit user code. It will return -// the same alarm object that was orignally passed in, unlike deep sleep, which +// the same alarm object that was originally passed in, unlike deep sleep, which // must create an identical copy due to the VM reset extern mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c index 948910c45e..9fe525dfe2 100644 --- a/shared-bindings/audiomp3/__init__.c +++ b/shared-bindings/audiomp3/__init__.c @@ -33,7 +33,7 @@ //| """Support for MP3-compressed audio files //| -//| For more infomration about working with MP3 files in CircuitPython, +//| For more information about working with MP3 files in CircuitPython, //| see `this CircuitPython Essentials Learn guide page //| `_. //| """ diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 1195e1811d..f965e504f2 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -530,14 +530,14 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_line_obj, 0, bitmaptools_obj_draw_li //| value: int, //| close: Optional[bool] = True, //| ) -> None: -//| """Draw a polygon conecting points on provided bitmap with provided value +//| """Draw a polygon connecting points on provided bitmap with provided value //| //| :param bitmap dest_bitmap: Destination bitmap that will be written into //| :param ReadableBuffer xs: x-pixel position of the polygon's vertices //| :param ReadableBuffer ys: y-pixel position of the polygon's vertices //| :param int value: Bitmap palette index that will be written into the //| line in the destination bitmap -//| :param bool close: (Optional) Wether to connect first and last point. (True) +//| :param bool close: (Optional) Whether to connect first and last point. (True) //| //| .. code-block:: Python //| @@ -630,7 +630,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_polygon_obj, 0, bitmaptools_obj_draw //| """Inserts pixels from ``data`` into the rectangle of width×height pixels with the upper left corner at ``(x,y)`` //| //| The values from ``data`` are taken modulo the number of color values -//| avalable in the destination bitmap. +//| available in the destination bitmap. //| //| If x1 or y1 are not specified, they are taken as 0. If x2 or y2 //| are not specified, or are given as -1, they are taken as the width @@ -722,7 +722,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_arrayblit_obj, 0, bitmaptools_arrayblit); //| :param typing.BinaryIO file: A file opened in binary mode //| :param int bits_per_pixel: Number of bits per pixel. Values 1, 2, 4, 8, 16, 24, and 32 are supported; //| :param int element_size: Number of bytes per element. Values of 1, 2, and 4 are supported, except that 24 ``bits_per_pixel`` requires 1 byte per element. -//| :param bool reverse_pixels_in_element: If set, the first pixel in a word is taken from the Most Signficant Bits; otherwise, it is taken from the Least Significant Bits. +//| :param bool reverse_pixels_in_element: If set, the first pixel in a word is taken from the Most Significant Bits; otherwise, it is taken from the Least Significant Bits. //| :param bool swap_bytes_in_element: If the ``element_size`` is not 1, then reverse the byte order of each element read. //| :param bool reverse_rows: Reverse the direction of the row loading (required for some bitmap images). //| """ @@ -782,7 +782,7 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_readinto_obj, 0, bitmaptools_readinto); //| class DitherAlgorithm: -//| """Identifies the algorith for dither to use""" +//| """Identifies the algorithm for dither to use""" //| //| Atkinson: "DitherAlgorithm" //| """The classic Atkinson dither, often associated with the Hypercard esthetic""" diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 971ed2f676..99b99b37ea 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -43,7 +43,7 @@ //| Common container for board base pin names. These will vary from board to //| board so don't expect portability when using this module. //| -//| Another common use of this module is to use serial communciation buses with +//| Another common use of this module is to use serial communication buses with //| the default pins and settings. For more information about serial communcication //| in CircuitPython, see the :mod:`busio`. //| diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 77d7036c2e..a10dc8efad 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -157,7 +157,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si // Always initially allocate the UART object within the long-lived heap. // This is needed to avoid crashes with certain UART implementations which - // cannot accomodate being moved after creation. (See + // cannot accommodate being moved after creation. (See // https://github.com/adafruit/circuitpython/issues/1056) busio_uart_obj_t *self = m_new_ll_obj_with_finaliser(busio_uart_obj_t); self->base.type = &busio_uart_type; diff --git a/shared-bindings/countio/__init__.c b/shared-bindings/countio/__init__.c index 25e9c7d630..0d412cc17f 100644 --- a/shared-bindings/countio/__init__.c +++ b/shared-bindings/countio/__init__.c @@ -11,7 +11,7 @@ //| """Support for edge counting //| -//| The `countio` module contains logic to read and count edge transistions +//| The `countio` module contains logic to read and count edge transitions //| //| For more information on the applications of counting edges, see //| `this Learn Guide on sequential circuits diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 3fcd1d082b..77dc8aecee 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -61,7 +61,7 @@ //| //| def release_displays() -> None: -//| """Releases any actively used displays so their busses and pins can be used again. This will also +//| """Releases any actively used displays so their buses and pins can be used again. This will also //| release the builtin display on boards that have one. You will need to reinitialize it yourself //| afterwards. This may take seconds to complete if an active EPaperDisplay is refreshing. //| diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index c8d24294f8..8264ebe612 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -64,7 +64,7 @@ STATIC mp_obj_t keypad_event_make_new(const mp_obj_type_t *type, size_t n_args, timestamp = supervisor_ticks_ms(); } - (void)mp_obj_get_int_truncated(timestamp); // ensure that timesamp is an integer + (void)mp_obj_get_int_truncated(timestamp); // ensure that timestamp is an integer common_hal_keypad_event_construct(self, key_number, args[ARG_pressed].u_bool, timestamp); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/keypad/KeyMatrix.c b/shared-bindings/keypad/KeyMatrix.c index 49723dbb9e..1c623f4bed 100644 --- a/shared-bindings/keypad/KeyMatrix.c +++ b/shared-bindings/keypad/KeyMatrix.c @@ -56,7 +56,7 @@ //| An `EventQueue` is created when this object is created and is available in the `events` attribute. //| //| :param Sequence[microcontroller.Pin] row_pins: The pins attached to the rows. -//| :param Sequence[microcontroller.Pin] column_pins: The pins attached to the colums. +//| :param Sequence[microcontroller.Pin] column_pins: The pins attached to the columns. //| :param bool columns_to_anodes: Default ``True``. //| If the matrix uses diodes, the diode anodes are typically connected to the column pins, //| and the cathodes should be connected to the row pins. If your diodes are reversed, diff --git a/shared-bindings/microcontroller/ResetReason.c b/shared-bindings/microcontroller/ResetReason.c index 13a8f25e6d..6f8ac8f42b 100644 --- a/shared-bindings/microcontroller/ResetReason.c +++ b/shared-bindings/microcontroller/ResetReason.c @@ -39,31 +39,31 @@ MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, UNKNOWN, RESET_REASON_UNKNO MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, RESCUE_DEBUG, RESET_REASON_RESCUE_DEBUG); //| class ResetReason: -//| """The reason the microntroller was last reset""" +//| """The reason the microcontroller was last reset""" //| //| POWER_ON: object //| """The microcontroller was started from power off.""" //| //| BROWNOUT: object -//| """The microntroller was reset due to too low a voltage.""" +//| """The microcontroller was reset due to too low a voltage.""" //| //| SOFTWARE: object -//| """The microntroller was reset from software.""" +//| """The microcontroller was reset from software.""" //| //| DEEP_SLEEP_ALARM: object -//| """The microntroller was reset for deep sleep and restarted by an alarm.""" +//| """The microcontroller was reset for deep sleep and restarted by an alarm.""" //| //| RESET_PIN: object -//| """The microntroller was reset by a signal on its reset pin. The pin might be connected to a reset button.""" +//| """The microcontroller was reset by a signal on its reset pin. The pin might be connected to a reset button.""" //| //| WATCHDOG: object //| """The microcontroller was reset by its watchdog timer.""" //| //| UNKNOWN: object -//| """The microntroller restarted for an unknown reason.""" +//| """The microcontroller restarted for an unknown reason.""" //| //| RESCUE_DEBUG: object -//| """The microntroller was reset by the rescue debug port.""" +//| """The microcontroller was reset by the rescue debug port.""" //| MAKE_ENUM_MAP(mcu_reset_reason) { MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON), diff --git a/shared-bindings/paralleldisplay/ParallelBus.c b/shared-bindings/paralleldisplay/ParallelBus.c index 42b4c788c7..ad9a1efdce 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.c +++ b/shared-bindings/paralleldisplay/ParallelBus.c @@ -39,7 +39,7 @@ //| class ParallelBus: //| """Manage updating a display over 8-bit parallel bus in the background while Python code runs. This -//| protocol may be refered to as 8080-I Series Parallel Interface in datasheets. It doesn't handle +//| protocol may be referred to as 8080-I Series Parallel Interface in datasheets. It doesn't handle //| display initialization.""" //| //| def __init__( diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index fae55db317..09a48f01aa 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -42,7 +42,7 @@ //| ) -> None: //| """Create an IncrementalEncoder object associated with the given pins. It tracks the positional //| state of an incremental rotary encoder (also known as a quadrature encoder.) Position is -//| relative to the position when the object is contructed. +//| relative to the position when the object is constructed. //| //| :param ~microcontroller.Pin pin_a: First pin to read pulses from. //| :param ~microcontroller.Pin pin_b: Second pin to read pulses from. diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 6818316768..08b4138202 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -776,7 +776,7 @@ void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bi bitmaptools_dither_algorithm_info_t *info = algorithms[algorithm]; // rowdata holds 3 rows of data. Each one is larger than the input - // bitmap's width, beacuse `mx` extra pixels are allocated at the start and + // bitmap's width, because `mx` extra pixels are allocated at the start and // end of the row so that no conditionals are needed when storing the error data. int16_t rowdata[(width + 2 * info->mx) * 3]; int16_t *rows[3] = { diff --git a/shared/netutils/dhcpserver.c b/shared/netutils/dhcpserver.c index d396a2ba56..3f90a06e46 100644 --- a/shared/netutils/dhcpserver.c +++ b/shared/netutils/dhcpserver.c @@ -277,8 +277,8 @@ static void dhcp_server_process(void *arg, struct udp_pcb *upcb, struct pbuf *p, opt_write_n(&opt, DHCP_OPT_SERVER_ID, 4, &d->ip.addr); opt_write_n(&opt, DHCP_OPT_SUBNET_MASK, 4, &d->nm.addr); - opt_write_n(&opt, DHCP_OPT_ROUTER, 4, &d->ip.addr); // aka gateway; can have mulitple addresses - opt_write_u32(&opt, DHCP_OPT_DNS, DEFAULT_DNS); // can have mulitple addresses + opt_write_n(&opt, DHCP_OPT_ROUTER, 4, &d->ip.addr); // aka gateway; can have multiple addresses + opt_write_u32(&opt, DHCP_OPT_DNS, DEFAULT_DNS); // can have multiple addresses opt_write_u32(&opt, DHCP_OPT_IP_LEASE_TIME, DEFAULT_LEASE_TIME_S); *opt++ = DHCP_OPT_END; dhcp_socket_sendto(&d->udp, &dhcp_msg, opt - (uint8_t *)&dhcp_msg, 0xffffffff, PORT_DHCP_CLIENT); diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c index 87219d18f5..aeb92f59d3 100644 --- a/shared/runtime/pyexec.c +++ b/shared/runtime/pyexec.c @@ -643,7 +643,7 @@ friendly_repl_reset: // If the user gets to here and interrupts are disabled then // they'll never see the prompt, traceback etc. The USB REPL needs // interrupts to be enabled or no transfers occur. So we try to - // do the user a favor and reenable interrupts. + // do the user a favor and re-enable interrupts. if (query_irq() == IRQ_STATE_DISABLED) { enable_irq(IRQ_STATE_ENABLED); mp_hal_stdout_tx_str("MPY: enabling IRQs\r\n"); diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 141ad7e5f8..f72518ac50 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -97,7 +97,7 @@ static bool write_flash(uint32_t address, const uint8_t *data, uint32_t data_len if (flash_device == NULL) { return false; } - // Don't bother writing if the data is all 1s. Thats equivalent to the flash + // Don't bother writing if the data is all 1s. That's equivalent to the flash // state after an erase. if (!flash_device->no_erase_cmd) { // Only do this if the device has an erase command diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 5112b17ebf..8709d3c356 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -116,7 +116,7 @@ safe_mode_t wait_for_safe_mode_reset(void) { if (boot_in_safe_mode) { return SAFE_MODE_USER; } - // Restore the original state of the saved word if no reset occured during our wait period. + // Restore the original state of the saved word if no reset occurred during our wait period. port_set_saved_word(reset_state); return SAFE_MODE_NONE; } diff --git a/supervisor/shared/translate/compressed_string.h b/supervisor/shared/translate/compressed_string.h index e331a5866f..f524010db5 100644 --- a/supervisor/shared/translate/compressed_string.h +++ b/supervisor/shared/translate/compressed_string.h @@ -62,7 +62,7 @@ // // The "data" / "tail" construct is so that the struct's last member is a // "flexible array". However, the _only_ member is not permitted to be -// a flexible member, so we have to declare the first byte as a separte +// a flexible member, so we have to declare the first byte as a separate // member of the structure. // // For translations where length needs 8 bits, this saves about 1.5 diff --git a/tests/basics/annotate_var.py b/tests/basics/annotate_var.py index 3f767e4a73..a359b229b1 100644 --- a/tests/basics/annotate_var.py +++ b/tests/basics/annotate_var.py @@ -1,4 +1,4 @@ -# test PEP 526, varible annotations +# test PEP 526, variable annotations x: int print("x" in globals()) diff --git a/tests/basics/deque2.py b/tests/basics/deque2.py index 22d370e943..1b6f072da5 100644 --- a/tests/basics/deque2.py +++ b/tests/basics/deque2.py @@ -1,4 +1,4 @@ -# Tests for deques with "check overflow" flag and other extensions +# Tests for dequeues with "check overflow" flag and other extensions # wrt to CPython. try: try: @@ -22,7 +22,7 @@ try: except ValueError: print("ValueError") -# Only fixed-size deques are supported, so length arg is mandatory +# Only fixed-size dequeues are supported, so length arg is mandatory try: deque(()) except TypeError: diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py index ec29ea9080..2ac900bbc7 100644 --- a/tests/basics/struct1.py +++ b/tests/basics/struct1.py @@ -79,7 +79,7 @@ try: except: print("Unknown type") -# Initially repitition counters were supported only for strings, +# Initially repetition counters were supported only for strings, # but later were implemented for all. print(struct.unpack("<3B2h", b"foo\x12\x34\xff\xff")) print(struct.pack("<3B", 1, 2, 3)) diff --git a/tests/cpydiff/core_fstring_repr.py b/tests/cpydiff/core_fstring_repr.py index fcadcbf1b9..df80abf795 100644 --- a/tests/cpydiff/core_fstring_repr.py +++ b/tests/cpydiff/core_fstring_repr.py @@ -2,7 +2,7 @@ categories: Core description: f-strings don't support the !r, !s, and !a conversions cause: MicroPython is optimised for code space. -workaround: Use repr(), str(), and ascii() explictly. +workaround: Use repr(), str(), and ascii() explicitly. """ diff --git a/tests/cpydiff/core_import_path.py b/tests/cpydiff/core_import_path.py index 04fc4bd5bb..959fd571f5 100644 --- a/tests/cpydiff/core_import_path.py +++ b/tests/cpydiff/core_import_path.py @@ -1,7 +1,7 @@ """ categories: Core,import description: __path__ attribute of a package has a different type (single string instead of list of strings) in MicroPython -cause: MicroPython does't support namespace packages split across filesystem. Beyond that, MicroPython's import system is highly optimized for minimal memory usage. +cause: MicroPython doesn't support namespace packages split across filesystem. Beyond that, MicroPython's import system is highly optimized for minimal memory usage. workaround: Details of import handling is inherently implementation dependent. Don't rely on such details in portable applications. """ import modules diff --git a/tests/cpydiff/core_import_split_ns_pkgs.py b/tests/cpydiff/core_import_split_ns_pkgs.py index 62bf337a22..5c92b63124 100644 --- a/tests/cpydiff/core_import_split_ns_pkgs.py +++ b/tests/cpydiff/core_import_split_ns_pkgs.py @@ -1,6 +1,6 @@ """ categories: Core,import -description: MicroPython does't support namespace packages split across filesystem. +description: MicroPython doesn't support namespace packages split across filesystem. cause: MicroPython's import system is highly optimized for simplicity, minimal memory usage, and minimal filesystem search overhead. workaround: Don't install modules belonging to the same namespace package in different directories. For MicroPython, it's recommended to have at most 3-component module search paths: for your current application, per-user (writable), system-wide (non-writable). """ diff --git a/tests/extmod/framebuf_palette.py b/tests/extmod/framebuf_palette.py index 84db834c15..f5b15fda73 100644 --- a/tests/extmod/framebuf_palette.py +++ b/tests/extmod/framebuf_palette.py @@ -30,6 +30,6 @@ fbd.blit(fbc, 0, 0, -1, palette) print(fbd.pixel(0, 0) == fg) print(fbd.pixel(7, 7) == fg) -print(fbd.pixel(8, 8) == 0) # Ouside blit +print(fbd.pixel(8, 8) == 0) # Outside blit print(fbd.pixel(0, 1) == bg) print(fbd.pixel(1, 0) == bg) diff --git a/tests/extmod/uctypes_sizeof_layout.py b/tests/extmod/uctypes_sizeof_layout.py index 2108e81502..c710ecde95 100644 --- a/tests/extmod/uctypes_sizeof_layout.py +++ b/tests/extmod/uctypes_sizeof_layout.py @@ -13,7 +13,7 @@ desc = { # uctypes.NATIVE is default print(uctypes.sizeof(desc) == uctypes.sizeof(desc, uctypes.NATIVE)) -# Here we assume that that we run on a platform with convential ABI +# Here we assume that that we run on a platform with conventional ABI # (which rounds up structure size based on max alignment). For platforms # where that doesn't hold, this tests should be just disabled in the runner. print(uctypes.sizeof(desc, uctypes.NATIVE) > uctypes.sizeof(desc, uctypes.LITTLE_ENDIAN)) diff --git a/tests/extmod/utimeq1.py b/tests/extmod/utimeq1.py index ddbc969afb..688e5b834f 100644 --- a/tests/extmod/utimeq1.py +++ b/tests/extmod/utimeq1.py @@ -125,7 +125,7 @@ assert edge_case(MODULO_HALF - 1, -100) == diff # We expect diff to be always positive, per the definition of heappop() which should return # the smallest value. -# This is the edge case where this invariant breaks, due to assymetry of two's-complement +# This is the edge case where this invariant breaks, due to asymmetry of two's-complement # range - there's one more negative integer than positive, so heappushing values like below # will then make ticks_diff() return the minimum negative value. We could make heappop # return them in a different order, but ticks_diff() result would be the same. Conclusion: diff --git a/tests/thread/thread_lock1.py b/tests/thread/thread_lock1.py index e7066402ca..f49f57ce83 100644 --- a/tests/thread/thread_lock1.py +++ b/tests/thread/thread_lock1.py @@ -32,7 +32,7 @@ print(lock.locked()) with lock: print(lock.locked()) -# test that lock is unlocked if an error is rasied +# test that lock is unlocked if an error is raised try: with lock: print(lock.locked()) diff --git a/tools/analyze_heap_dump.py b/tools/analyze_heap_dump.py index d9b3dda599..ede990929d 100755 --- a/tools/analyze_heap_dump.py +++ b/tools/analyze_heap_dump.py @@ -446,7 +446,7 @@ def do_all_the_things( current_allocation = 1 elif block_state == AT_TAIL and current_allocation > 0: # In gc_free the logging happens before the tail is freed. So checking - # current_allocation > 0 ensures we only extend an allocation thats started. + # current_allocation > 0 ensures we only extend an allocation that's started. current_allocation += 1 longest_free = max(longest_free, current_free) # if current_free > 0: diff --git a/tools/cpboard.py b/tools/cpboard.py index 1f399d1dfc..46ae659d34 100644 --- a/tools/cpboard.py +++ b/tools/cpboard.py @@ -357,7 +357,7 @@ class CPboard: else: serials = [serial for serial in os.listdir("/dev/serial/by-path") if portstr in serial] if len(serials) != 1: - raise RuntimeError("Can't find excatly one matching usb serial device") + raise RuntimeError("Can't find exactly one matching usb serial device") self.device = os.path.realpath("/dev/serial/by-path/" + serials[0]) self.usb_dev = device diff --git a/tools/gendoc.py b/tools/gendoc.py index f3df853e49..e7eb011b7c 100644 --- a/tools/gendoc.py +++ b/tools/gendoc.py @@ -523,7 +523,7 @@ def main(): description="Generate documentation for pyboard API from C files." ) cmd_parser.add_argument( - "--outdir", metavar="", default="gendoc-out", help="ouput directory" + "--outdir", metavar="", default="gendoc-out", help="output directory" ) cmd_parser.add_argument("--format", default="html", help="output format: html or rst") cmd_parser.add_argument("files", nargs="+", help="input files") diff --git a/tools/makemanifest.py b/tools/makemanifest.py index 8cdc3eb774..b2856889b9 100644 --- a/tools/makemanifest.py +++ b/tools/makemanifest.py @@ -164,7 +164,7 @@ def system(cmd): def convert_path(path): - # Perform variable substituion. + # Perform variable substitution. for name, value in VARS.items(): path = path.replace("$({})".format(name), value) # Convert to absolute path (so that future operations don't rely on diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py index 6c41c4cd43..80ab547f3b 100755 --- a/tools/preprocess_frozen_modules.py +++ b/tools/preprocess_frozen_modules.py @@ -21,10 +21,10 @@ def version_string(path=None, *, valid_semver=False): version = tag.strip().decode("utf-8", "strict") except subprocess.CalledProcessError: describe = subprocess.check_output("git describe --tags", shell=True, cwd=path) - tag, additional_commits, commitish = ( + tag, additional_commits, committish = ( describe.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2) ) - commitish = commitish[1:] + committish = committish[1:] if valid_semver: version_info = semver.parse_version_info(tag) if not version_info.prerelease: @@ -33,12 +33,12 @@ def version_string(path=None, *, valid_semver=False): + "-alpha.0.plus." + additional_commits + "+" - + commitish + + committish ) else: - version = tag + ".plus." + additional_commits + "+" + commitish + version = tag + ".plus." + additional_commits + "+" + committish else: - version = commitish + version = committish return version diff --git a/tools/pydfu.py b/tools/pydfu.py index ce34b08a58..57a8708e5d 100755 --- a/tools/pydfu.py +++ b/tools/pydfu.py @@ -483,7 +483,7 @@ def get_memory_layout(device): def list_dfu_devices(*args, **kwargs): - """Prints a lits of devices detected in DFU mode.""" + """Prints a list of devices detected in DFU mode.""" devices = get_dfu_devices(*args, **kwargs) if not devices: raise SystemExit("No DFU capable devices found") diff --git a/tools/uncrustify.cfg b/tools/uncrustify.cfg index 88127112e8..a92530fd93 100644 --- a/tools/uncrustify.cfg +++ b/tools/uncrustify.cfg @@ -1323,7 +1323,7 @@ indent_using_block = true # true/false # 2: When the `:` is a continuation, indent it under `?` indent_ternary_operator = 0 # unsigned number -# Whether to indent the statments inside ternary operator. +# Whether to indent the statements inside ternary operator. indent_inside_ternary_operator = false # true/false # If true, the indentation of the chunks after a `return` sequence will be set at return indentation column. @@ -1779,7 +1779,7 @@ nl_func_call_args_multi_line = false # true/false # different lines. nl_func_call_end_multi_line = false # true/false -# Whether to respect nl_func_call_XXX option incase of closure args. +# Whether to respect nl_func_call_XXX option in case of closure args. nl_func_call_args_multi_line_ignore_closures = false # true/false # Whether to add a newline after '<' of a template parameter list. @@ -2570,7 +2570,7 @@ align_oc_decl_colon = false # true/false # (OC) Whether to not align parameters in an Objectve-C message call if first # colon is not on next line of the message call (the same way Xcode does -# aligment) +# alignment) align_oc_msg_colon_xcode_like = false # true/false # @@ -2916,28 +2916,28 @@ pp_define_at_level = false # true/false pp_ignore_define_body = false # true/false # Whether to indent case statements between #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the case statements +# Only applies to the indent of the preprocessor that the case statements # directly inside of. # # Default: true pp_indent_case = true # true/false # Whether to indent whole function definitions between #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the function definition +# Only applies to the indent of the preprocessor that the function definition # is directly inside of. # # Default: true pp_indent_func_def = true # true/false # Whether to indent extern C blocks between #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the extern block is +# Only applies to the indent of the preprocessor that the extern block is # directly inside of. # # Default: true pp_indent_extern = true # true/false # Whether to indent braces directly inside #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the braces are directly +# Only applies to the indent of the preprocessor that the braces are directly # inside of. # # Default: true diff --git a/tools/verifygitlog.py b/tools/verifygitlog.py index cc4b80f4a9..24171f9c68 100755 --- a/tools/verifygitlog.py +++ b/tools/verifygitlog.py @@ -101,7 +101,7 @@ def run(args): def show_help(): print("usage: verifygitlog.py [-v -n -h] ...") - print("-v : increase verbosity, can be speficied multiple times") + print("-v : increase verbosity, can be specified multiple times") print("-n : do not print multi-line suggestions") print("-h : print this help message and exit") print("... : arguments passed to git log to retrieve commits to verify") From c2d506b1fa931744a6ff4ca0a54c60aaac68f095 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 18 Mar 2023 19:38:40 -0400 Subject: [PATCH 054/225] add 'deque` to known words. --- .codespell/ignore-words.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.codespell/ignore-words.txt b/.codespell/ignore-words.txt index 76849278a0..39eb42e0df 100644 --- a/.codespell/ignore-words.txt +++ b/.codespell/ignore-words.txt @@ -14,4 +14,5 @@ astroid busses cyphertext dum +deque extint From b88e76d3a48c0d1e3e00e35255b68621d286b07d Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 14 Mar 2023 19:02:41 +0100 Subject: [PATCH 055/225] Add builtin display support with shared board.I2C to Lolin S2 Pico --- ports/espressif/boards/lolin_s2_pico/board.c | 68 ++++++++++++++++++++ ports/espressif/boards/lolin_s2_pico/pins.c | 3 + 2 files changed, 71 insertions(+) diff --git a/ports/espressif/boards/lolin_s2_pico/board.c b/ports/espressif/boards/lolin_s2_pico/board.c index b3c8cb4191..e2c24bb22a 100644 --- a/ports/espressif/boards/lolin_s2_pico/board.c +++ b/ports/espressif/boards/lolin_s2_pico/board.c @@ -27,8 +27,76 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/board/__init__.h" +#include "shared-bindings/displayio/I2CDisplay.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/busio/I2C.h" +#include "supervisor/shared/board.h" +#include "shared-bindings/board/__init__.h" + +uint8_t display_init_sequence[] = { // SSD1306 + 0xAE, 0, // DISPLAY_OFF + 0x20, 1, 0x00, // Set memory addressing to horizontal mode. + 0x81, 1, 0xcf, // set contrast control + 0xA1, 0, // Column 127 is segment 0 + 0xA6, 0, // Normal display + 0xc8, 0, // Normal display + 0xA8, 1, 0x1f, // Mux ratio is height-1 + 0xd5, 1, 0x80, // Set divide ratio + 0xd9, 1, 0xf1, // Set pre-charge period + 0xda, 1, 0x02, // Set com configuration to 2 if height is 32 and width not 64 + 0xdb, 1, 0x40, // Set vcom configuration + 0x8d, 1, 0x14, // Enable charge pump + 0xAF, 0, // DISPLAY_ON +}; + +static void display_init(void) { + busio_i2c_obj_t *i2c = common_hal_board_create_i2c(0); + + displayio_i2cdisplay_obj_t *bus = &displays[0].i2cdisplay_bus; + bus->base.type = &displayio_i2cdisplay_type; + common_hal_displayio_i2cdisplay_construct(bus, + i2c, + 0x3c, + &pin_GPIO18 // reset + ); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct(display, + bus, + 128, // Width + 32, // Height + 0, // column start + 0, // row start + 0, // rotation + 1, // Color depth + true, // grayscale + false, // pixels in byte share row. Only used with depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + 0x21, // Set column command + 0x22, // Set row command + 44, // Write ram command + display_init_sequence, + sizeof(display_init_sequence), + NULL, // no backlight pin + 0x81, // brightness command + 1.0f, // brightness + true, // single_byte_bounds + true, // data as commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false, // SH1107_addressing + 0); // backlight pwm frequency +} void board_init(void) { + // init display + display_init(); // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/lolin_s2_pico/pins.c b/ports/espressif/boards/lolin_s2_pico/pins.c index 5c3f1f4db5..1afd508f03 100644 --- a/ports/espressif/boards/lolin_s2_pico/pins.c +++ b/ports/espressif/boards/lolin_s2_pico/pins.c @@ -1,4 +1,5 @@ #include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -52,5 +53,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, // Not labelled on booard, on schematic { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },// Not labelled on booard, on schematic { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 9e630a565ed9d8b2259596d3ea526498baf94f67 Mon Sep 17 00:00:00 2001 From: Isaac Benitez Date: Sun, 19 Mar 2023 15:08:29 -0700 Subject: [PATCH 056/225] Updated block_device type annotation --- shared-bindings/storage/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 9e82654bc9..3f0dc5f6f3 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -252,7 +252,7 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_enable_usb_drive), MP_ROM_PTR(&storage_enable_usb_drive_obj) }, //| class VfsFat: -//| def __init__(self, block_device: str) -> None: +//| def __init__(self, block_device: BlockDevice) -> None: //| """Create a new VfsFat filesystem around the given block device. //| //| :param block_device: Block device the the filesystem lives on""" @@ -267,7 +267,7 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { //| ... //| //| @staticmethod -//| def mkfs(self) -> None: +//| def mkfs(self, block_device: BlockDevice) -> None: //| """Format the block device, deleting any data that may have been there. //| //| **Limitations**: On SAMD21 builds, `mkfs()` will raise ``OSError(22)`` when From ce2c3d7dc5d5824ff2f6df302ffde229214915f2 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 20 Mar 2023 12:12:30 +0700 Subject: [PATCH 057/225] revert deque(s) --- .codespell/ignore-words.txt | 1 + docs/library/collections.rst | 4 ++-- tests/basics/deque2.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.codespell/ignore-words.txt b/.codespell/ignore-words.txt index 39eb42e0df..5a54e22f0d 100644 --- a/.codespell/ignore-words.txt +++ b/.codespell/ignore-words.txt @@ -15,4 +15,5 @@ busses cyphertext dum deque +deques extint diff --git a/docs/library/collections.rst b/docs/library/collections.rst index 01882ba244..2cc1a215d1 100644 --- a/docs/library/collections.rst +++ b/docs/library/collections.rst @@ -16,8 +16,8 @@ Classes .. function:: deque(iterable, maxlen[, flags]) - Dequeues (double-ended queues) are a list-like container that support O(1) - appends and pops from either side of the deque. New dequeues are created + Deques (double-ended queues) are a list-like container that support O(1) + appends and pops from either side of the deque. New deques are created using the following arguments: - *iterable* must be the empty tuple, and the new deque is created empty. diff --git a/tests/basics/deque2.py b/tests/basics/deque2.py index 1b6f072da5..22d370e943 100644 --- a/tests/basics/deque2.py +++ b/tests/basics/deque2.py @@ -1,4 +1,4 @@ -# Tests for dequeues with "check overflow" flag and other extensions +# Tests for deques with "check overflow" flag and other extensions # wrt to CPython. try: try: @@ -22,7 +22,7 @@ try: except ValueError: print("ValueError") -# Only fixed-size dequeues are supported, so length arg is mandatory +# Only fixed-size deques are supported, so length arg is mandatory try: deque(()) except TypeError: From ace25e83ce66c4f800cdbf3f2cd8f28996ef8e2b Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Mon, 20 Mar 2023 15:44:49 -0400 Subject: [PATCH 058/225] correcting vectorshape location property --- shared-module/vectorio/VectorShape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index 35131faa4f..fab12c664e 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -278,7 +278,7 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self mp_arg_validate_length(tuple_len, 2, MP_QSTR_location); mp_int_t x = mp_arg_validate_type_int(tuple_items[0], MP_QSTR_x); - mp_int_t y = mp_arg_validate_type_int(tuple_items[0], MP_QSTR_y); + mp_int_t y = mp_arg_validate_type_int(tuple_items[1], MP_QSTR_y); bool dirty = false; if (self->x != x) { check_bounds_and_set_x(self, x); From bdf592089ae461434a03ba0f185dfce3d09953fb Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 17 Mar 2023 08:49:47 -0700 Subject: [PATCH 059/225] Fix .bin, .hex and .uf2 with new linker sections Also, format perfbench output in table with reference timing from the host. --- ports/mimxrt10xx/Makefile | 10 ++-- ports/mimxrt10xx/linking/common.ld | 29 +++++----- supervisor/linker.h | 2 +- tests/perf_bench/benchrun.py | 2 +- tests/run-perfbench.py | 90 ++++++++++++++++++++++-------- tools/cpboard.py | 25 +++++++-- 6 files changed, 110 insertions(+), 48 deletions(-) diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index c561b894d3..d3db4c44e3 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -182,18 +182,20 @@ $(BUILD)/firmware.elf: $(OBJ) $(LD_FILES) $(STEPECHO) "LINK $@" $(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out %.ld, $^) -Wl,--print-memory-usage -Wl,--start-group $(LIBS) -Wl,--end-group +# -R excludes sections from the output files. $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" - $(Q)$(OBJCOPY) -O binary -j .flash_config -j .ivt -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@ + $(Q)$(OBJCOPY) -O binary -R .stack -R .dtcm_bss $^ $@ $(BUILD)/firmware.uf2: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" - $(Q)$(OBJCOPY) -O binary -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@-binpart + $(Q)$(OBJCOPY) -O binary -R .stack -R .dtcm_bss -R .ivt -R .flash_config $^ $@-binpart $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $@-binpart - $(Q)rm $@-binpart + +# $(Q)rm $@-binpart $(BUILD)/firmware.hex: $(BUILD)/firmware.elf - $(Q)$(OBJCOPY) -O ihex -j .flash_config -j .ivt -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $< $@ + $(Q)$(OBJCOPY) -O ihex -R .stack -R .dtcm_bss $< $@ include $(TOP)/py/mkrules.mk diff --git a/ports/mimxrt10xx/linking/common.ld b/ports/mimxrt10xx/linking/common.ld index 61a9a2299f..461a9d89eb 100644 --- a/ports/mimxrt10xx/linking/common.ld +++ b/ports/mimxrt10xx/linking/common.ld @@ -6,7 +6,7 @@ Boards can setup reserved flash with _ld_reserved_flash_size in board.ld. */ ENTRY(Reset_Handler) -code_size = 2M; +code_size = _ld_flash_size >= 4M ? 2M : 1M; _ld_default_stack_size = 20K; /* Default reserved flash to nothing. */ @@ -52,6 +52,20 @@ SECTIONS . = ALIGN(4); } > FLASH_IVT + /* Align for 256 ISR entries and place first in flash. Otherwise the UF2 + bootloader can't find it because it uses its own flash_config and ivt. */ + .isr_vector : ALIGN(4 * 256) + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } > ITCM AT> FLASH_FIRMWARE + _ld_isr_destination = ADDR(.isr_vector); + _ld_isr_flash_copy = LOADADDR(.isr_vector); + _ld_isr_size = SIZEOF(.isr_vector); + /* Used by the bootloader to start user code. */ + __VECTOR_TABLE = LOADADDR(.isr_vector); + .text : { . = ALIGN(4); @@ -146,19 +160,6 @@ SECTIONS _ld_itcm_flash_copy = LOADADDR(.itcm); _ld_itcm_size = SIZEOF(.itcm); - /* Align for 256 ISR entries */ - .isr_vector : ALIGN(4 * 256) - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } > ITCM AT> FLASH_FIRMWARE - _ld_isr_destination = ADDR(.isr_vector); - _ld_isr_flash_copy = LOADADDR(.isr_vector); - _ld_isr_size = SIZEOF(.isr_vector); - /* Used by the bootloader to start user code. */ - __VECTOR_TABLE = LOADADDR(.isr_vector); - .dtcm_data : { . = ALIGN(4); diff --git a/supervisor/linker.h b/supervisor/linker.h index c6ee8b4218..9666c4ca12 100644 --- a/supervisor/linker.h +++ b/supervisor/linker.h @@ -33,7 +33,7 @@ #define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name))) #define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name))) // Don't inline ITCM functions because that may pull them out of ITCM into other sections. -#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name),noinline)) name +#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name),noinline,aligned(4))) name #else #define PLACE_IN_DTCM_DATA(name) name #define PLACE_IN_DTCM_BSS(name) name diff --git a/tests/perf_bench/benchrun.py b/tests/perf_bench/benchrun.py index 0092ecaa33..87b6489d07 100644 --- a/tests/perf_bench/benchrun.py +++ b/tests/perf_bench/benchrun.py @@ -4,7 +4,7 @@ def bm_run(N, M): except ImportError: import time - ticks_us = lambda: int(time.monotonic_ns() / 1000) + ticks_us = lambda: int(time.monotonic_ns() // 1000) ticks_diff = lambda a, b: a - b # Pick sensible parameters given N, M diff --git a/tests/run-perfbench.py b/tests/run-perfbench.py index 5f299281fd..3d3639e057 100755 --- a/tests/run-perfbench.py +++ b/tests/run-perfbench.py @@ -7,8 +7,12 @@ import os import subprocess import sys +import time import argparse from glob import glob +from rich.live import Live +from rich.console import Console +from rich.table import Table sys.path.append("../tools") import pyboard @@ -37,7 +41,7 @@ def compute_stats(lst): return avg, var**0.5 -def run_script_on_target(target, script): +def run_script_on_target(target, script, run_command=None): output = b"" err = None @@ -45,50 +49,72 @@ def run_script_on_target(target, script): # Run via pyboard interface try: target.enter_raw_repl() + start_ts = time.monotonic_ns() output = target.exec_(script) + if run_command: + start_ts = time.monotonic_ns() + output = target.exec_(run_command) + end_ts = time.monotonic_ns() except pyboard.PyboardError as er: + end_ts = time.monotonic_ns() err = er + finally: + target.exit_raw_repl() else: # Run local executable try: + if run_command: + script += run_command + start_ts = time.monotonic_ns() p = subprocess.run( target, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, input=script ) + end_ts = time.monotonic_ns() output = p.stdout except subprocess.CalledProcessError as er: + end_ts = time.monotonic_ns() err = er - return str(output.strip(), "ascii"), err + return str(output.strip(), "ascii"), err, (end_ts - start_ts) // 1000 def run_feature_test(target, test): with open("feature_check/" + test + ".py", "rb") as f: script = f.read() - output, err = run_script_on_target(target, script) + output, err, _ = run_script_on_target(target, script) if err is None: return output else: return "CRASH: %r" % err -def run_benchmark_on_target(target, script): - output, err = run_script_on_target(target, script) +def run_benchmark_on_target(target, script, run_command=None): + output, err, runtime_us = run_script_on_target(target, script, run_command) if err is None: time, norm, result = output.split(None, 2) try: - return int(time), int(norm), result + return int(time), int(norm), result, runtime_us except ValueError: - return -1, -1, "CRASH: %r" % output + return -1, -1, "CRASH: %r" % output, runtime_us else: - return -1, -1, "CRASH: %r" % err + return -1, -1, "CRASH: %r" % err, runtime_us -def run_benchmarks(target, param_n, param_m, n_average, test_list): +def run_benchmarks(console, target, param_n, param_m, n_average, test_list): skip_complex = run_feature_test(target, "complex") != "complex" skip_native = run_feature_test(target, "native_check") != "native" + table = Table(show_header=True) + table.add_column("Test") + table.add_column("Time", justify="right") + table.add_column("Score", justify="right") + table.add_column("Ref Time", justify="right") + + live = Live(table, console=console) + live.start() + for test_file in sorted(test_list): - print(test_file + ": ", end="") + # print(test_file + ": ", end="") # Check if test should be skipped skip = ( @@ -99,6 +125,7 @@ def run_benchmarks(target, param_n, param_m, n_average, test_list): ) if skip: print("skip") + table.add_row(test_file, *(["skip"] * 6)) continue # Create test script @@ -106,7 +133,7 @@ def run_benchmarks(target, param_n, param_m, n_average, test_list): test_script = f.read() with open(BENCH_SCRIPT_DIR + "benchrun.py", "rb") as f: test_script += f.read() - test_script += b"bm_run(%u, %u)\n" % (param_n, param_m) + bm_run = b"bm_run(%u, %u)\n" % (param_n, param_m) # Write full test script if needed if 0: @@ -115,12 +142,15 @@ def run_benchmarks(target, param_n, param_m, n_average, test_list): # Run MicroPython a given number of times times = [] + runtimes = [] scores = [] error = None result_out = None for _ in range(n_average): - time, norm, result = run_benchmark_on_target(target, test_script) - if time < 0 or norm < 0: + self_time, norm, result, runtime_us = run_benchmark_on_target( + target, test_script, bm_run + ) + if self_time < 0 or norm < 0: error = result break if result_out is None: @@ -128,30 +158,43 @@ def run_benchmarks(target, param_n, param_m, n_average, test_list): elif result != result_out: error = "FAIL self" break - times.append(time) - scores.append(1e6 * norm / time) + times.append(self_time) + runtimes.append(runtime_us) + scores.append(1e6 * norm / self_time) # Check result against truth if needed if error is None and result_out != "None": - _, _, result_exp = run_benchmark_on_target(PYTHON_TRUTH, test_script) + _, _, result_exp, _ = run_benchmark_on_target(PYTHON_TRUTH, test_script, bm_run) if result_out != result_exp: error = "FAIL truth" if error is not None: - print(error) + print(test_file, error) + if error == "no matching params": + table.add_row(test_file, *([None] * 3)) + else: + table.add_row(test_file, *(["error"] * 3)) else: t_avg, t_sd = compute_stats(times) + r_avg, r_sd = compute_stats(runtimes) s_avg, s_sd = compute_stats(scores) - print( - "{:.2f} {:.4f} {:.2f} {:.4f}".format( - t_avg, 100 * t_sd / t_avg, s_avg, 100 * s_sd / s_avg - ) + # print( + # "{:.2f} {:.4f} {:.2f} {:.4f} {:.2f} {:.4f}".format( + # t_avg, 100 * t_sd / t_avg, s_avg, 100 * s_sd / s_avg, r_avg, 100 * r_sd / r_avg + # ) + # ) + table.add_row( + test_file, + f"{t_avg:.2f}±{100 * t_sd / t_avg:.1f}%", + f"{s_avg:.2f}±{100 * s_sd / s_avg:.1f}%", + f"{r_avg:.2f}±{100 * r_sd / r_avg:.1f}%", ) if 0: print(" times: ", times) print(" scores:", scores) - sys.stdout.flush() + live.update(table, refresh=True) + live.stop() def parse_output(filename): @@ -268,9 +311,10 @@ def main(): else: tests = sorted(args.files) + console = Console() print("N={} M={} n_average={}".format(N, M, n_average)) - run_benchmarks(target, N, M, n_average, tests) + run_benchmarks(console, target, N, M, n_average, tests) if isinstance(target, pyboard.Pyboard): target.exit_raw_repl() diff --git a/tools/cpboard.py b/tools/cpboard.py index 658cf512a2..12d7d374a3 100644 --- a/tools/cpboard.py +++ b/tools/cpboard.py @@ -81,6 +81,7 @@ class REPL: else: timeout_count += 1 if timeout is not None and timeout_count >= 100 * timeout: + print("timeout") raise TimeoutError(110, "timeout waiting for", ending) time.sleep(0.01) return data @@ -164,7 +165,10 @@ class Disk: self._path = mount[0][1] else: name = os.path.basename(dev) - sh.pmount("-tvfat", dev, name, _timeout=10) + try: + sh.pmount("-tvfat", dev, name, _timeout=10) + except sh.CommandNotFound: + raise ValueError() self.mountpoint = "/media/" + name self._path = self.mountpoint @@ -516,7 +520,10 @@ class CPboard: if not part: return None - return Disk(part[0]) + try: + return Disk(part[0]) + except ValueError: + return None @property def firmware(self): @@ -555,14 +562,17 @@ PyboardError = CPboardError class Pyboard: def __init__(self, device, baudrate=115200, user="micro", password="python", wait=0): self.board = CPboard.from_try_all(device, baudrate=baudrate, wait=wait) - with self.board.disk as disk: - disk.copy("skip_if.py") + disk = self.board.disk + if disk: + with disk as open_disk: + open_disk.copy("skip_if.py") def close(self): self.board.close() def enter_raw_repl(self): self.board.open() + self.board.repl.reset() def exit_raw_repl(self): self.close() @@ -571,7 +581,12 @@ class Pyboard: return self.board.execfile(filename) def exec_(self, command, data_consumer=None): - output = self.board.exec(command, timeout=20000) + try: + output, error = self.board.repl.execute(command, timeout=20000, wait_for_response=True) + except OSError as e: + raise CPboardError("timeout", e) + if error: + raise CPboardError("exception", output, error) return output From f56c221a501da028bcfedffab65a0858e68221d2 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Mon, 20 Mar 2023 17:23:49 -0400 Subject: [PATCH 060/225] removing need to use print format option. --- docs/design_guide.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 784284892c..40ce285177 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -742,14 +742,7 @@ You could other examples if needed featuring different functionalities of the library. If you add additional examples, be sure to include them in the ``examples.rst``. Naming of the examples files should use the name of the library followed by a description, using underscore to separate them. -When using print statements you should use the ``" ".format()`` format, as there are particular boards -that are not capable to use f-strings. -.. code-block:: python - - text_to_display = "World!" - - print("Hello {}".format(text_to_display)) Sensor properties and units -------------------------------------------------------------------------------- From 0773a2bd6d741d791734a96a3cf5ca3e7fd3e167 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 20 Mar 2023 17:32:00 -0500 Subject: [PATCH 061/225] increment web_api_version --- supervisor/shared/web_workflow/web_workflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index c006a9e7cb..2caacbd39b 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -805,7 +805,7 @@ static void _reply_with_version_json(socketpool_socket_obj_t *socket, _request * _update_encoded_ip(); // Note: this leverages the fact that C concats consecutive string literals together. mp_printf(&_socket_print, - "{\"web_api_version\": 1, " + "{\"web_api_version\": 2, " "\"version\": \"" MICROPY_GIT_TAG "\", " "\"build_date\": \"" MICROPY_BUILD_DATE "\", " "\"board_name\": \"" MICROPY_HW_BOARD_NAME "\", " From 7ee3f30c174fd7143c1dcccb5ec3c9e1bdd4ede2 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Tue, 21 Mar 2023 07:06:46 +0530 Subject: [PATCH 062/225] rewrite `allocate_pystack` logic --- locale/circuitpython.pot | 12 ++++-------- main.c | 22 +++++++--------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 560dffe6a4..0c7f823b5a 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -28,14 +28,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1252,6 +1244,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/main.c b/main.c index 002c97c167..7b805b57b0 100644 --- a/main.c +++ b/main.c @@ -134,26 +134,18 @@ static void reset_devices(void) { #if MICROPY_ENABLE_PYSTACK STATIC supervisor_allocation *allocate_pystack(safe_mode_t safe_mode) { - mp_int_t pystack_size = CIRCUITPY_PYSTACK_SIZE; #if CIRCUITPY_OS_GETENV && CIRCUITPY_SETTABLE_PYSTACK - // Fetch value if exists from settings.toml - // Leaves size to build default on any failure - if (safe_mode == SAFE_MODE_NONE || safe_mode == SAFE_MODE_USER) { + if (safe_mode == SAFE_MODE_NONE) { + mp_int_t pystack_size = CIRCUITPY_PYSTACK_SIZE; (void)common_hal_os_getenv_int("CIRCUITPY_PYSTACK_SIZE", &pystack_size); - // Check if value is valid - pystack_size = pystack_size - pystack_size % sizeof(size_t); // Round down to multiple of 4. - if ((pystack_size < 384) || (pystack_size > 900000)) { - serial_write_compressed(translate("\nInvalid CIRCUITPY_PYSTACK_SIZE\n\n\r")); - pystack_size = CIRCUITPY_PYSTACK_SIZE; // Reset + supervisor_allocation *pystack = allocate_memory(pystack_size >= 384 ? pystack_size : 0, false, false); + if (pystack) { + return pystack; } + serial_write_compressed(translate("Invalid CIRCUITPY_PYSTACK_SIZE\n")); } #endif - supervisor_allocation *pystack = allocate_memory(pystack_size, false, false); - if (pystack == NULL) { - serial_write_compressed(translate("\nInvalid CIRCUITPY_PYSTACK_SIZE\n\n\r")); - pystack = allocate_memory(CIRCUITPY_PYSTACK_SIZE, false, false); - } - return pystack; + return allocate_memory(CIRCUITPY_PYSTACK_SIZE, false, false); } #endif From 36e4dc2588f705f6d0010aff33b8f618b2310355 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Fri, 17 Mar 2023 19:11:51 +0100 Subject: [PATCH 063/225] Adding 01space OLED 0.42 C3 --- .../boards/01space_lcd042_esp32c3/board.c | 102 ++++++++++++++++++ .../01space_lcd042_esp32c3/mpconfigboard.h | 40 +++++++ .../01space_lcd042_esp32c3/mpconfigboard.mk | 8 ++ .../boards/01space_lcd042_esp32c3/pins.c | 68 ++++++++++++ .../boards/01space_lcd042_esp32c3/sdkconfig | 6 ++ 5 files changed, 224 insertions(+) create mode 100644 ports/espressif/boards/01space_lcd042_esp32c3/board.c create mode 100644 ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.h create mode 100644 ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.mk create mode 100644 ports/espressif/boards/01space_lcd042_esp32c3/pins.c create mode 100644 ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig diff --git a/ports/espressif/boards/01space_lcd042_esp32c3/board.c b/ports/espressif/boards/01space_lcd042_esp32c3/board.c new file mode 100644 index 0000000000..56df21ab57 --- /dev/null +++ b/ports/espressif/boards/01space_lcd042_esp32c3/board.c @@ -0,0 +1,102 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" +#include "shared-bindings/displayio/I2CDisplay.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/busio/I2C.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" +#include "supervisor/shared/board.h" +#include "shared-bindings/board/__init__.h" + +uint8_t display_init_sequence[] = { // SSD1306 + 0xAE, 0, // DISPLAY_OFF + 0x20, 1, 0x00, // Set memory addressing to horizontal mode. + 0x81, 1, 0xcf, // set contrast control + 0xA1, 0, // Column 127 is segment 0 + 0xA6, 0, // Normal display + 0xc8, 0, // Normal display + 0xA8, 1, 0x3f, // Mux ratio is 1/64 + 0xd5, 1, 0x80, // Set divide ratio + 0xd9, 1, 0xf1, // Set pre-charge period + 0xda, 1, 0x12, // Set com configuration + 0xdb, 1, 0x40, // Set vcom configuration + 0x8d, 1, 0x14, // Enable charge pump + 0xAF, 0, // DISPLAY_ON +}; + +void board_init(void) { + busio_i2c_obj_t *i2c = common_hal_board_create_i2c(0); + + // What we would do if it wasn't the shared board I2C: (for reference) + // busio_i2c_obj_t *i2c = &displays[0].i2cdisplay_bus.inline_bus; + // common_hal_busio_i2c_construct(i2c, &pin_GPIO23, &pin_GPIO22, 100000, 0); + // common_hal_busio_i2c_never_reset(i2c); + + displayio_i2cdisplay_obj_t *bus = &displays[0].i2cdisplay_bus; + bus->base.type = &displayio_i2cdisplay_type; + common_hal_displayio_i2cdisplay_construct(bus, + i2c, + 0x3c, + NULL + ); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct(display, + bus, + 72, // Width + 40, // Height + 28, // column start + 28, // row start + 0, // rotation + 1, // Color depth + true, // grayscale + false, // pixels in byte share row. Only used with depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + 0x21, // Set column command + 0x22, // Set row command + 44, // Write ram command + display_init_sequence, + sizeof(display_init_sequence), + NULL, // no backlight pin + 0x81, // brightness command + 1.0f, // brightness + true, // single_byte_bounds + true, // data as commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false, // SH1107_addressing + 0); // backlight pwm frequency +} + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.h b/ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.h new file mode 100644 index 0000000000..cae80fa78c --- /dev/null +++ b/ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 Neradoc + * + * 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. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "01Space 0.42 OLED ESP32C3" +#define MICROPY_HW_MCU_NAME "ESP32-C3FH4" + +// Status LED +#define MICROPY_HW_NEOPIXEL (&pin_GPIO2) + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO5}} + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) + +#define CIRCUITPY_ESP_USB_SERIAL_JTAG (1) diff --git a/ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.mk b/ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.mk new file mode 100644 index 0000000000..e4467a3bbf --- /dev/null +++ b/ports/espressif/boards/01space_lcd042_esp32c3/mpconfigboard.mk @@ -0,0 +1,8 @@ +CIRCUITPY_CREATOR_ID = 0x01011ACE +CIRCUITPY_CREATION_ID = 0x00C30042 + +IDF_TARGET = esp32c3 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/01space_lcd042_esp32c3/pins.c b/ports/espressif/boards/01space_lcd042_esp32c3/pins.c new file mode 100644 index 0000000000..a28ffca6d2 --- /dev/null +++ b/ports/espressif/boards/01space_lcd042_esp32c3/pins.c @@ -0,0 +1,68 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 Neradoc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { 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_NEOPIXEL), MP_ROM_PTR(&pin_GPIO2) }, + { 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_SDA), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO6) }, + { 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_BUTTON), MP_ROM_PTR(&pin_GPIO9) }, + { 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_IO20), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig b/ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig new file mode 100644 index 0000000000..b75eaee69f --- /dev/null +++ b/ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig @@ -0,0 +1,6 @@ +# chip is ESP32-C3 FH4 +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="Adafruit-QTPy-ESP32C3" +# end of LWIP From ccd417cd8b6c31e787f7b7835d9ce1ca765490db Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Tue, 21 Mar 2023 16:01:13 +0530 Subject: [PATCH 064/225] add esp specific modules to src patterns --- py/circuitpy_defns.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 79769e000e..94377238a0 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -182,6 +182,18 @@ endif ifeq ($(CIRCUITPY__EVE),1) SRC_PATTERNS += _eve/% endif +ifeq ($(CIRCUITPY_ESPCAMERA),1) +SRC_PATTERNS += espcamera/% +endif +ifeq ($(CIRCUITPY_ESPIDF),1) +SRC_PATTERNS += espidf/% +endif +ifeq ($(CIRCUITPY_ESPNOW),1) +SRC_PATTERNS += espnow/% +endif +ifeq ($(CIRCUITPY_ESPULP),1) +SRC_PATTERNS += espulp/% +endif ifeq ($(CIRCUITPY_FLOPPYIO),1) SRC_PATTERNS += floppyio/% endif From 395bc0aac71941b25536b7ed82344200cefe1f54 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Tue, 21 Mar 2023 16:01:21 +0530 Subject: [PATCH 065/225] don't run all jobs if changed files is empty --- tools/ci_set_matrix.py | 204 +++++++++++++++++++---------------------- 1 file changed, 95 insertions(+), 109 deletions(-) diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index fa53c81829..f89b2133ac 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -116,26 +116,24 @@ def set_output(name: str, value): print(f"Would set GitHub actions output {name} to '{value}'") -def set_boards(build_all: bool): - # Get boards in json format - boards_info_json = build_board_info.get_board_mapping() +def set_boards(build_all=False): all_board_ids = set() - port_to_boards = {} + boards_to_build = all_board_ids if build_all else set() + board_to_port = {} - board_settings = {} - for board_id in boards_info_json: - info = boards_info_json[board_id] - if info.get("alias", False): + port_to_board = {} + board_setting = {} + + for id, info in build_board_info.get_board_mapping().items(): + if info.get("alias"): continue - all_board_ids.add(board_id) port = info["port"] - if port not in port_to_boards: - port_to_boards[port] = set() - port_to_boards[port].add(board_id) - board_to_port[board_id] = port + all_board_ids.add(id) + board_to_port[id] = port + port_to_board.setdefault(port, set()).add(id) def compute_board_settings(boards): - need = set(boards) - set(board_settings.keys()) + need = set(boards) - set(board_setting.keys()) if not need: return @@ -146,78 +144,76 @@ def set_boards(build_all: bool): ) with ThreadPoolExecutor(max_workers=os.cpu_count()) as ex: - board_settings.update(ex.map(get_settings, need)) - - boards_to_build = all_board_ids + board_setting.update(ex.map(get_settings, need)) if not build_all: - boards_to_build = set() - board_pattern = re.compile(r"^ports/[^/]+/boards/([^/]+)/") - port_pattern = re.compile(r"^ports/([^/]+)/") - module_pattern = re.compile( + pattern_port = re.compile(r"^ports/([^/]+)/") + pattern_board = re.compile(r"^ports/[^/]+/boards/([^/]+)/") + pattern_module = re.compile( r"^(ports/[^/]+/(?:common-hal|bindings)|shared-bindings|shared-module)/([^/]+)/" ) - for p in changed_files: + + for file in changed_files: + if len(all_board_ids) == len(boards_to_build): + break + + if any([file.startswith(path) for path in IGNORE_BOARD]): + continue + # See if it is board specific - board_matches = board_pattern.search(p) + board_matches = pattern_board.search(file) if board_matches: - board = board_matches.group(1) - boards_to_build.add(board) + boards_to_build.add(board_matches.group(1)) continue # See if it is port specific - port_matches = port_pattern.search(p) + port_matches = pattern_port.search(file) + module_matches = pattern_module.search(file) port = port_matches.group(1) if port_matches else None - module_matches = module_pattern.search(p) if port and not module_matches: if port != "unix": - boards_to_build.update(port_to_boards[port]) - continue - - if any([p.startswith(d) for d in IGNORE_BOARD]): + boards_to_build.update(port_to_board[port]) continue # As a (nearly) last resort, for some certain files, we compute the settings from the - # makefile for each board and determine whether to build them that way. - if p.startswith("frozen") or p.startswith("supervisor") or module_matches: - if port: - board_ids = port_to_boards[port] - else: - board_ids = all_board_ids - compute_board_settings(board_ids) - for board in board_ids: - settings = board_settings[board] + # makefile for each board and determine whether to build them that way + if file.startswith("frozen") or file.startswith("supervisor") or module_matches: + boards = port_to_board[port] if port else all_board_ids + compute_board_settings(boards) - # Check frozen files to see if they are in each board. - frozen = settings.get("FROZEN_MPY_DIRS", "") - if frozen and p.startswith("frozen") and p in frozen: - boards_to_build.add(board) - continue + for board in boards: + settings = board_setting[board] - # Check supervisor files. This is useful for limiting workflow changes to the - # relevant boards. - supervisor = settings["SRC_SUPERVISOR"] - if p.startswith("supervisor"): - if p in supervisor: + # Check frozen files to see if they are in each board + if file.startswith("frozen"): + if file in settings.get("FROZEN_MPY_DIRS", ""): boards_to_build.add(board) continue - web_workflow = settings["CIRCUITPY_WEB_WORKFLOW"] - while web_workflow.startswith("$("): - web_workflow = settings[web_workflow[2:-1]] - if ( - p.startswith("supervisor/shared/web_workflow/static/") - and web_workflow != "0" - ): + # Check supervisor files + # This is useful for limiting workflow changes to the relevant boards + if file.startswith("supervisor"): + if file in settings["SRC_SUPERVISOR"]: boards_to_build.add(board) continue + if file.startswith("supervisor/shared/web_workflow/static/"): + web_workflow = settings["CIRCUITPY_WEB_WORKFLOW"] + + while web_workflow.startswith("$("): + web_workflow = settings[web_workflow[2:-1]] + + if web_workflow != "0": + boards_to_build.add(board) + continue + # Check module matches if module_matches: module = module_matches.group(2) + "/" if module in settings["SRC_PATTERNS"]: boards_to_build.add(board) continue + continue # Otherwise build it all @@ -225,7 +221,7 @@ def set_boards(build_all: bool): break # Append previously failed boards - boards_to_build.update(last_failed_jobs.get("ports") or []) + boards_to_build.update(last_failed_jobs.get("ports", [])) print("Building boards:", bool(boards_to_build)) @@ -249,64 +245,54 @@ def set_boards(build_all: bool): set_output("ports", json.dumps(port_to_boards_to_build)) -def set_docs(build_doc: bool): - if not build_doc: - if last_failed_jobs.get("docs"): - build_doc = True - else: - doc_pattern = re.compile(PATTERN_DOCS) - github_workspace = os.environ.get("GITHUB_WORKSPACE") or "" - github_workspace = github_workspace and github_workspace + "/" - for file in changed_files: - if doc_pattern.search(file) and ( - ( - subprocess.run( - f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + file} | grep -o -m 1 '^[+-]\/\/|'", - capture_output=True, - shell=True, - ).stdout - ) - if file.endswith(".c") - else True - ): - build_doc = True - break - - # Set the step outputs - print("Building docs:", build_doc) - set_output("docs", build_doc) - - -def set_windows(build_windows: bool): - if not build_windows: - if last_failed_jobs.get("windows"): - build_windows = True - else: - for file in changed_files: - for pattern in PATTERN_WINDOWS: - if file.startswith(pattern) and not any( - [file.startswith(d) for d in IGNORE_BOARD] - ): - build_windows = True - break - else: - continue +def set_docs(run=bool(last_failed_jobs.get("docs"))): + if not run: + pattern_doc = re.compile(PATTERN_DOCS) + github_workspace = os.environ.get("GITHUB_WORKSPACE") or "" + github_workspace = github_workspace and github_workspace + "/" + for file in changed_files: + if pattern_doc.search(file) and ( + ( + subprocess.run( + f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + file} | grep -o -m 1 '^[+-]\/\/|'", + capture_output=True, + shell=True, + ).stdout + ) + if file.endswith(".c") + else True + ): + run = True break # Set the step outputs - print("Building windows:", build_windows) - set_output("windows", build_windows) + print("Building docs:", run) + set_output("docs", run) + + +def set_windows(run=bool(last_failed_jobs.get("windows"))): + if not run: + for file in changed_files: + for pattern in PATTERN_WINDOWS: + if file.startswith(pattern) and not any( + [file.startswith(path) for path in IGNORE_BOARD] + ): + run = True + break + else: + continue + break + + # Set the step outputs + print("Building windows:", run) + set_output("windows", run) def main(): - # Build all if no changed files - build_all = not changed_files - print("Running: " + ("all" if build_all else "conditionally")) - # Set jobs - set_docs(build_all) - set_windows(build_all) - set_boards(build_all) + set_docs() + set_windows() + set_boards() if __name__ == "__main__": From d9d27a3e315531622bf78f4b19280a022973b3c2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 21 Mar 2023 10:30:03 -0400 Subject: [PATCH 066/225] Fix signature of `mkfs()` --- shared-bindings/storage/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 3f0dc5f6f3..c4bd728f67 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -267,7 +267,7 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { //| ... //| //| @staticmethod -//| def mkfs(self, block_device: BlockDevice) -> None: +//| def mkfs(block_device: BlockDevice) -> None: //| """Format the block device, deleting any data that may have been there. //| //| **Limitations**: On SAMD21 builds, `mkfs()` will raise ``OSError(22)`` when From c0384b57f11838164b98f45d127686af3997408f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 21 Mar 2023 11:01:40 -0400 Subject: [PATCH 067/225] remove unused submodule tools/usb_descriptor --- .gitmodules | 3 --- tools/usb_descriptor | 1 - 2 files changed, 4 deletions(-) delete mode 160000 tools/usb_descriptor diff --git a/.gitmodules b/.gitmodules index 2ba84b4305..023892218a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,9 +33,6 @@ path = ports/atmel-samd/asf4 url = https://github.com/adafruit/asf4.git branch = circuitpython -[submodule "tools/usb_descriptor"] - path = tools/usb_descriptor - url = https://github.com/adafruit/usb_descriptor.git [submodule "lib/nrfutil"] path = lib/nrfutil url = https://github.com/adafruit/nRF52_nrfutil diff --git a/tools/usb_descriptor b/tools/usb_descriptor deleted file mode 160000 index 2eaa6114b2..0000000000 --- a/tools/usb_descriptor +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2eaa6114b209fe7f0a795eda8d6a7b3b93d76d2e From 98bff96d3c1245efe76262eee4709f015f0d2b22 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 21 Mar 2023 11:01:58 -0400 Subject: [PATCH 068/225] update tinyusb: fixes + no more submodules --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index ea8ecea59a..ec9c666107 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit ea8ecea59aa60a1028cce16b0f15bb33918b11af +Subproject commit ec9c666107c0be0f8dc7c2a15e3bdea8c44a50b4 From ae95274b66cb3bf72b5ff14421bd02137abee31c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 21 Mar 2023 11:43:33 -0400 Subject: [PATCH 069/225] use blobless partial clone for make fetch-submodules --- Makefile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 91d842231f..50c86fc128 100644 --- a/Makefile +++ b/Makefile @@ -324,10 +324,9 @@ clean-stm: $(MAKE) -C ports/stm BOARD=feather_stm32f405_express clean -# This update will fail because the commits we need aren't the latest on the -# branch. We can ignore that though because we fix it with the second command. -# (Only works for git servers that allow sha fetches.) +# Do blobless partial clones of submodules to save time and space. +# A blobless partial clone lazily fetches data as needed, but has all the metadata available (tags, etc.) +# so it does not have the idiosyncrasies of a shallow clone. .PHONY: fetch-submodules fetch-submodules: - git submodule update --init -N --depth 1 || true - git submodule foreach 'git fetch --tags --depth 1 origin $$sha1 && git checkout -q $$sha1' + git submodule update --init --filter=blob:none From b45d1287263a94d1f4f415d07b8a6dd1d5188dc7 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 21 Mar 2023 16:45:38 +0100 Subject: [PATCH 070/225] fix lwip name in 01space_lcd042_esp32c3 --- ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig b/ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig index b75eaee69f..24f7d625ea 100644 --- a/ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig +++ b/ports/espressif/boards/01space_lcd042_esp32c3/sdkconfig @@ -2,5 +2,5 @@ # # LWIP # -CONFIG_LWIP_LOCAL_HOSTNAME="Adafruit-QTPy-ESP32C3" +CONFIG_LWIP_LOCAL_HOSTNAME="01Space-LCD042-ESP32C3" # end of LWIP From e4b5b20ebec60557af3c0c5ab35b9c4616e1dd31 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Tue, 21 Mar 2023 21:34:30 +0530 Subject: [PATCH 071/225] don't call `reload_initiate` if already initiated --- supervisor/shared/reload.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/supervisor/shared/reload.c b/supervisor/shared/reload.c index 4e351704f8..da2ffc26e1 100644 --- a/supervisor/shared/reload.c +++ b/supervisor/shared/reload.c @@ -82,15 +82,19 @@ inline bool autoreload_is_enabled() { } void autoreload_trigger() { - if (autoreload_enabled & !autoreload_suspended) { - last_autoreload_trigger = supervisor_ticks_ms32(); - // Guard against the rare time that ticks is 0; - if (last_autoreload_trigger == 0) { - last_autoreload_trigger += 1; - } - // Initiate a reload of the VM immediately. Later code will pause to - // wait for the autoreload to become ready. Doing the VM exit - // immediately is clearer for the user. + if (!autoreload_enabled || autoreload_suspended != 0) { + return; + } + bool reload_initiated = autoreload_pending(); + last_autoreload_trigger = supervisor_ticks_ms32(); + // Guard against the rare time that ticks is 0; + if (last_autoreload_trigger == 0) { + last_autoreload_trigger += 1; + } + // Initiate a reload of the VM immediately. Later code will pause to + // wait for the autoreload to become ready. Doing the VM exit + // immediately is clearer for the user. + if (!reload_initiated) { reload_initiate(RUN_REASON_AUTO_RELOAD); } } @@ -111,5 +115,5 @@ bool autoreload_ready() { } bool autoreload_pending(void) { - return last_autoreload_trigger != 0; + return last_autoreload_trigger > 0; } From 4a6965ee769767223e138c9c4a1747722864abd3 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Tue, 21 Mar 2023 22:32:40 +0530 Subject: [PATCH 072/225] change condition to run all jobs --- tools/ci_set_matrix.py | 78 ++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index f89b2133ac..f549b6f6f1 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -82,10 +82,12 @@ def git_diff(pattern: str): ) +compute_diff = bool(os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA")) + if len(sys.argv) > 1: print("Using files list on commandline") changed_files = set(sys.argv[1:]) -elif os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA"): +elif compute_diff: print("Using files list by computing diff") changed_files = git_diff("$BASE_SHA...$HEAD_SHA") if os.environ.get("GITHUB_EVENT_NAME") == "pull_request": @@ -116,7 +118,7 @@ def set_output(name: str, value): print(f"Would set GitHub actions output {name} to '{value}'") -def set_boards(build_all=False): +def set_boards(build_all: bool): all_board_ids = set() boards_to_build = all_board_ids if build_all else set() @@ -245,43 +247,49 @@ def set_boards(build_all=False): set_output("ports", json.dumps(port_to_boards_to_build)) -def set_docs(run=bool(last_failed_jobs.get("docs"))): +def set_docs(run: bool): if not run: - pattern_doc = re.compile(PATTERN_DOCS) - github_workspace = os.environ.get("GITHUB_WORKSPACE") or "" - github_workspace = github_workspace and github_workspace + "/" - for file in changed_files: - if pattern_doc.search(file) and ( - ( - subprocess.run( - f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + file} | grep -o -m 1 '^[+-]\/\/|'", - capture_output=True, - shell=True, - ).stdout - ) - if file.endswith(".c") - else True - ): - run = True - break + if last_failed_jobs.get("docs"): + run = True + else: + pattern_doc = re.compile(PATTERN_DOCS) + github_workspace = os.environ.get("GITHUB_WORKSPACE") or "" + github_workspace = github_workspace and github_workspace + "/" + for file in changed_files: + if pattern_doc.search(file) and ( + ( + subprocess.run( + f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + file} | grep -o -m 1 '^[+-]\/\/|'", + capture_output=True, + shell=True, + ).stdout + ) + if file.endswith(".c") + else True + ): + run = True + break # Set the step outputs print("Building docs:", run) set_output("docs", run) -def set_windows(run=bool(last_failed_jobs.get("windows"))): +def set_windows(run: bool): if not run: - for file in changed_files: - for pattern in PATTERN_WINDOWS: - if file.startswith(pattern) and not any( - [file.startswith(path) for path in IGNORE_BOARD] - ): - run = True - break - else: - continue - break + if last_failed_jobs.get("windows"): + run = True + else: + for file in changed_files: + for pattern in PATTERN_WINDOWS: + if file.startswith(pattern) and not any( + [file.startswith(path) for path in IGNORE_BOARD] + ): + run = True + break + else: + continue + break # Set the step outputs print("Building windows:", run) @@ -289,10 +297,12 @@ def set_windows(run=bool(last_failed_jobs.get("windows"))): def main(): + run_all = not changed_files and not compute_diff + print("Running: " + ("all" if run_all else "conditionally")) # Set jobs - set_docs() - set_windows() - set_boards() + set_docs(run_all) + set_windows(run_all) + set_boards(run_all) if __name__ == "__main__": From 9c3c0555ddfcfc3bca779d5fb779f35cdc86e9a2 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 21 Mar 2023 16:21:57 -0700 Subject: [PATCH 073/225] Switch iMX RT sdk to NXP repo Fixes #7645 --- .gitmodules | 2 +- ports/mimxrt10xx/Makefile | 45 ++++++------- ports/mimxrt10xx/board.h | 1 - ports/mimxrt10xx/boards/board.h | 29 ++++++++ .../boards/feather_m7_1011/flash_config.c | 62 +++++------------ .../boards/feather_mimxrt1011/flash_config.c | 62 +++++------------ .../boards/feather_mimxrt1062/flash_config.c | 63 +++++------------ ports/mimxrt10xx/boards/flash_config.h | 36 +++++++++- .../boards/imxrt1010_evk/flash_config.c | 63 +++++------------ .../boards/imxrt1020_evk/flash_config.c | 63 +++++------------ .../boards/imxrt1060_evk/flash_config.c | 63 +++++------------ .../boards/metro_m7_1011/flash_config.c | 65 ++++++------------ .../sparkfun_teensy_micromod/flash_config.c | 65 +++++------------- .../mimxrt10xx/boards/teensy40/flash_config.c | 67 ++++++------------- .../mimxrt10xx/boards/teensy41/flash_config.c | 65 +++++------------- .../mimxrt10xx/common-hal/analogio/AnalogIn.c | 2 +- ports/mimxrt10xx/common-hal/busio/I2C.c | 4 +- ports/mimxrt10xx/common-hal/busio/SPI.c | 2 +- ports/mimxrt10xx/common-hal/busio/UART.c | 4 +- ports/mimxrt10xx/common-hal/busio/UART.h | 2 +- .../common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/microcontroller/Processor.c | 4 +- ports/mimxrt10xx/common-hal/os/__init__.c | 2 +- ports/mimxrt10xx/common-hal/pwmio/PWMOut.c | 3 +- ports/mimxrt10xx/common-hal/rtc/RTC.c | 4 +- ports/mimxrt10xx/linking/common.ld | 2 + ports/mimxrt10xx/mphalport.c | 4 -- .../mimxrt10xx/peripherals/mimxrt10xx/pins.h | 2 +- ports/mimxrt10xx/sdk | 2 +- .../supervisor/flexspi_nor_flash_ops.c | 2 +- ports/mimxrt10xx/supervisor/internal_flash.c | 4 +- ports/mimxrt10xx/supervisor/port.c | 34 +++++++++- 32 files changed, 322 insertions(+), 508 deletions(-) delete mode 100644 ports/mimxrt10xx/board.h create mode 100644 ports/mimxrt10xx/boards/board.h diff --git a/.gitmodules b/.gitmodules index 023892218a..9c8d3b4b68 100644 --- a/.gitmodules +++ b/.gitmodules @@ -100,7 +100,7 @@ url = https://github.com/adafruit/Adafruit_MP3 [submodule "ports/mimxrt10xx/sdk"] path = ports/mimxrt10xx/sdk - url = https://github.com/adafruit/MIMXRT10xx_SDK + url = https://github.com/nxp-mcuxpresso/mcux-sdk.git [submodule "frozen/Adafruit_CircuitPython_Register"] path = frozen/Adafruit_CircuitPython_Register url = https://github.com/adafruit/Adafruit_CircuitPython_Register.git diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index d3db4c44e3..d8d12b74da 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -30,8 +30,7 @@ CROSS_COMPILE = arm-none-eabi- INC += \ -I. \ -I../.. \ - -I../lib/mp-readline \ - -I../shared/timeutils \ + -I../../lib/cmsis/inc \ -I../../lib/tinyusb/src \ -I../../supervisor/shared/usb \ -I$(BUILD) \ @@ -42,7 +41,7 @@ INC += \ -Isdk/CMSIS/Include \ -Isdk/devices/$(CHIP_FAMILY) \ -Isdk/devices/$(CHIP_FAMILY)/drivers \ - -Isdk/devices/$(CHIP_FAMILY)/xip \ + -Isdk/drivers/common # NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt. @@ -106,25 +105,26 @@ LDFLAGS += -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mthumb -mapcs BOOTLOADER_SIZE := 0x6000C000 SRC_SDK := \ - drivers/fsl_adc.c \ - drivers/fsl_cache.c \ - drivers/fsl_clock.c \ - drivers/fsl_common.c \ - drivers/fsl_flexspi.c \ - drivers/fsl_gpio.c \ - drivers/fsl_lpi2c.c \ - drivers/fsl_lpspi.c \ - drivers/fsl_lpuart.c \ - drivers/fsl_ocotp.c \ - drivers/fsl_pwm.c \ - drivers/fsl_snvs_hp.c \ - drivers/fsl_snvs_lp.c \ - drivers/fsl_tempmon.c \ - drivers/fsl_trng.c \ - system_$(CHIP_FAMILY).c \ + devices/$(CHIP_FAMILY)/drivers/fsl_clock.c \ + devices/$(CHIP_FAMILY)/system_$(CHIP_FAMILY).c \ + devices/$(CHIP_FAMILY)/xip/fsl_flexspi_nor_boot.c \ + drivers/adc_12b1msps_sar/fsl_adc.c \ + drivers/cache/armv7-m7/fsl_cache.c \ + drivers/common/fsl_common_arm.c \ + drivers/common/fsl_common.c \ + drivers/flexspi/fsl_flexspi.c \ + drivers/igpio/fsl_gpio.c \ + drivers/lpi2c/fsl_lpi2c.c \ + drivers/lpspi/fsl_lpspi.c \ + drivers/lpuart/fsl_lpuart.c \ + drivers/ocotp/fsl_ocotp.c \ + drivers/pwm/fsl_pwm.c \ + drivers/snvs_hp/fsl_snvs_hp.c \ + drivers/snvs_lp/fsl_snvs_lp.c \ + drivers/tempmon/fsl_tempmon.c \ + drivers/trng/fsl_trng.c \ -SRC_SDK := $(addprefix sdk/devices/$(CHIP_FAMILY)/, $(SRC_SDK)) -$(addprefix $(BUILD)/, $(SRC_SDK:.c=.o)): CFLAGS += -Wno-undef -Wno-missing-prototypes -Wno-cast-align +SRC_SDK := $(addprefix sdk/, $(SRC_SDK)) SRC_C += \ background.c \ @@ -191,8 +191,7 @@ $(BUILD)/firmware.uf2: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" $(Q)$(OBJCOPY) -O binary -R .stack -R .dtcm_bss -R .ivt -R .flash_config $^ $@-binpart $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $@-binpart - -# $(Q)rm $@-binpart + $(Q)rm $@-binpart $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(Q)$(OBJCOPY) -O ihex -R .stack -R .dtcm_bss $< $@ diff --git a/ports/mimxrt10xx/board.h b/ports/mimxrt10xx/board.h deleted file mode 100644 index 1c9596e7d2..0000000000 --- a/ports/mimxrt10xx/board.h +++ /dev/null @@ -1 +0,0 @@ -// Empty but needed for the SDK diff --git a/ports/mimxrt10xx/boards/board.h b/ports/mimxrt10xx/boards/board.h new file mode 100644 index 0000000000..e6736806ed --- /dev/null +++ b/ports/mimxrt10xx/boards/board.h @@ -0,0 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 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 "mpconfigboard.h" + +#define XIP_BOOT_HEADER_ENABLE (1) diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c index 5871dda963..4e189590d0 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c @@ -7,47 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for W25Q32JV with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -61,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x02, // Bit pattern for setting Quad Enable. - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_133MHz, + .serialClkFreq = kFLEXSPISerialClk_133MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -78,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x02), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -101,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status -2 - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01 /* number of bytes to write */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -128,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -147,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c index 7460615c4c..2c6fa962aa 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c @@ -7,47 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for W25Q64JV with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -61,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x02, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_133MHz, + .serialClkFreq = kFLEXSPISerialClk_133MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -78,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -101,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -128,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -147,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c index d6cfc07e62..2c6fa962aa 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c @@ -7,48 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for W25Q64JV with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -62,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x02, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_133MHz, + .serialClkFreq = kFLEXSPISerialClk_133MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -79,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -102,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -129,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -148,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/flash_config.h b/ports/mimxrt10xx/boards/flash_config.h index 25f1550ae8..b0be0a93c0 100644 --- a/ports/mimxrt10xx/boards/flash_config.h +++ b/ports/mimxrt10xx/boards/flash_config.h @@ -34,7 +34,41 @@ #include "mpconfigboard.h" // For flash size settings #include "fsl_common.h" -#include "fsl_flexspi_nor_config.h" +#ifdef CPU_MIMXRT1011DAE5A +// TODO: Remove this when the 1011 has a romapi header that matches the others. +#include "sdk/boards/evkmimxrt1010/xip/evkmimxrt1010_flexspi_nor_config.h" +typedef enum _flexspi_serial_clk_freq_caps +{ + kFLEXSPISerialClk_NoChange = 0U, + kFLEXSPISerialClk_30MHz = 1U, + kFLEXSPISerialClk_50MHz = 2U, + kFLEXSPISerialClk_60MHz = 3U, + kFLEXSPISerialClk_75MHz = 4U, + kFLEXSPISerialClk_80MHz = 5U, + kFLEXSPISerialClk_100MHz = 6U, + kFLEXSPISerialClk_133MHz = 7U, + kFLEXSPISerialClk_166MHz = 8U, + kFLEXSPISerialClk_200MHz = 9U, +} caps_flexspi_serial_clk_freq_t; + +/*! @brief FLEXSPI Read Sample Clock Source definition */ +typedef enum _flexspi_read_sample_clk_caps +{ + kFLEXSPIReadSampleClk_LoopbackInternally = 0U, + kFLEXSPIReadSampleClk_LoopbackFromDqsPad = 1U, + kFLEXSPIReadSampleClk_LoopbackFromSckPad = 2U, + kFLEXSPIReadSampleClk_ExternalInputFromDqsPad = 3U, +} caps_flexspi_read_sample_clk_t; + +enum +{ + kFLEXSPIDeviceType_SerialNOR = 1U, /*!< Flash device is Serial NOR */ +}; + +#define FSL_ROM_FLEXSPI_LUT_SEQ FLEXSPI_LUT_SEQ +#else +#include "fsl_romapi.h" +#endif #define SEQUENCE(first, second, third, fourth) first, second, third, fourth #define TWO_EMPTY_STEPS 0x00000000 diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c index 9c88f689d8..f15a3f3459 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c @@ -7,48 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for AT25SF128A with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -62,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x02, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_60MHz, + .serialClkFreq = kFLEXSPISerialClk_60MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -79,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x02), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -102,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -129,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -148,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c index 6589ad9c48..2ae8ae9b76 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c @@ -7,48 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for IS25LP064A with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -62,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x40, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_30MHz, + .serialClkFreq = kFLEXSPISerialClk_30MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -79,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - // SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + // SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, // RADDR_SDR, FLEXSPI_4PAD, 24 bits to transmit ), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, // READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -102,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -129,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -148,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c index 40db33444f..c75174d1c4 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c @@ -7,48 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for IS25WP064A with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -62,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x40, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_60MHz, + .serialClkFreq = kFLEXSPISerialClk_60MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -79,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x02), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -102,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -129,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -148,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c index 3477de9e34..e4562c1965 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c @@ -7,48 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"),used)) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -__attribute__((section(".boot_hdr.boot_data"),used)) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for W25Q32JV with QSPI routed. (compatible with GD25Q32) __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -68,13 +41,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqId = 2u, .seqNum = 1u, }, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_60MHz, + .serialClkFreq = kFLEXSPISerialClk_60MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -85,48 +58,48 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x02), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 2: Empty - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x35 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x35 /* the command to send */, DUMMY_SDR, FLEXSPI_1PAD, 8), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x02), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -139,17 +112,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -158,7 +131,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c b/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c index e0f5a5bd7d..abc26a2bcd 100644 --- a/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c +++ b/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c @@ -7,50 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - 0x432000D1, /* Teensy bootloader looks for this value*/ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -extern unsigned long _flashimagelen; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - (uint32_t)&_flashimagelen, /* actual size of image */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for W25Q64JV with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -64,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x02, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_60MHz, + .serialClkFreq = kFLEXSPISerialClk_60MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -81,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -104,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -131,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -150,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/teensy40/flash_config.c b/ports/mimxrt10xx/boards/teensy40/flash_config.c index d878124b40..30d40d7c84 100644 --- a/ports/mimxrt10xx/boards/teensy40/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy40/flash_config.c @@ -7,50 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - 0x432000D1, /* Teensy bootloader looks for this value*/ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -extern unsigned long _flashimagelen; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - (uint32_t)&_flashimagelen, /* actual size of image */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for W25Q16JV with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -70,13 +41,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqId = 2u, .seqNum = 1u, }, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_60MHz, + .serialClkFreq = kFLEXSPISerialClk_60MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -87,48 +58,48 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x02), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 2: Empty - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x35 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x35 /* the command to send */, DUMMY_SDR, FLEXSPI_1PAD, 8), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x02), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -141,17 +112,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -160,7 +131,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/boards/teensy41/flash_config.c b/ports/mimxrt10xx/boards/teensy41/flash_config.c index e0f5a5bd7d..abc26a2bcd 100644 --- a/ports/mimxrt10xx/boards/teensy41/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy41/flash_config.c @@ -7,50 +7,21 @@ #include "boards/flash_config.h" -#include "fsl_flexspi_nor_boot.h" - - -__attribute__((section(".boot_hdr.ivt"))) -/************************************* - * IVT Data - *************************************/ -const ivt image_vector_table = { - 0x432000D1, /* Teensy bootloader looks for this value*/ - IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ - IVT_RSVD, /* Reserved = 0 */ - (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ - (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ - (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ - (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ - IVT_RSVD /* Reserved = 0 */ -}; - -extern unsigned long _flashimagelen; - -__attribute__((section(".boot_hdr.boot_data"))) -/************************************* - * Boot Data - *************************************/ -const BOOT_DATA_T boot_data = { - FLASH_BASE, /* boot start location */ - (uint32_t)&_flashimagelen, /* actual size of image */ - PLUGIN_FLAG, /* Plugin flag*/ - 0xFFFFFFFF /* empty - extra data word */ -}; +#include "xip/fsl_flexspi_nor_boot.h" // Config for W25Q64JV with QSPI routed. __attribute__((section(".boot_hdr.conf"))) const flexspi_nor_config_t qspiflash_config = { .pageSize = 256u, .sectorSize = 4u * 1024u, - .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .ipcmdSerialClkFreq = kFLEXSPISerialClk_30MHz, .blockSize = 0x00010000, .isUniformBlockSize = false, .memConfig = { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .readSampleClkSrc = kFLEXSPIReadSampleClk_LoopbackFromDqsPad, .csHoldTime = 3u, .csSetupTime = 3u, @@ -64,13 +35,13 @@ const flexspi_nor_config_t qspiflash_config = { .seqNum = 1u, }, .deviceModeArg = 0x02, - .deviceType = kFlexSpiDeviceType_SerialNOR, + .deviceType = kFLEXSPIDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, - .serialClkFreq = kFlexSpiSerialClk_60MHz, + .serialClkFreq = kFLEXSPISerialClk_60MHz, .sflashA1Size = FLASH_SIZE, .lookupTable = { - // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // FSL_ROM_FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) // The high 16 bits is command 1 and the low are command 0. // Within a command, the top 6 bits are the opcode, the next two are the number // of pads and then last byte is the operand. The operand's meaning changes @@ -81,20 +52,20 @@ const flexspi_nor_config_t qspiflash_config = { // 0: ROM: Read LUTs // Quad version - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB /* the command to send */, RADDR_SDR, FLEXSPI_4PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, + FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 6 /* 6 dummy cycles, 2 for M7-0 and 4 dummy */, READ_SDR, FLEXSPI_4PAD, 0x04), // Single fast read version, good for debugging. - // FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, + // FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x0B /* the command to send */, // RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - // FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, + // FSL_ROM_FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_1PAD, 8 /* 8 dummy clocks */, // READ_SDR, FLEXSPI_1PAD, 0x04), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 1: ROM: Read status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05 /* the command to send */, READ_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -104,21 +75,21 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 3: ROM: Write Enable - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06 /* the command to send */, STOP, FLEXSPI_1PAD, 0x00), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 4: Config: Write Status - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x31 /* the command to send */, WRITE_SDR, FLEXSPI_1PAD, 0x01), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 5: ROM: Erase Sector - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, @@ -131,17 +102,17 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 8: Block Erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), // 9: ROM: Page program - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02 /* the command to send */, RADDR_SDR, FLEXSPI_1PAD, 24 /* bits to transmit */), - FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, + FSL_ROM_FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04 /* data out */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS), @@ -150,7 +121,7 @@ const flexspi_nor_config_t qspiflash_config = { EMPTY_SEQUENCE, // 11: ROM: Chip erase - SEQUENCE(FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, + SEQUENCE(FSL_ROM_FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60 /* the command to send */, STOP, FLEXSPI_1PAD, 0), TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogIn.c b/ports/mimxrt10xx/common-hal/analogio/AnalogIn.c index f5d2e7f42e..237566b1f0 100644 --- a/ports/mimxrt10xx/common-hal/analogio/AnalogIn.c +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogIn.c @@ -33,7 +33,7 @@ #include "py/runtime.h" -#include "fsl_adc.h" +#include "sdk/drivers/adc_12b1msps_sar/fsl_adc.h" #define ADC_CHANNEL_GROUP 0 diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.c b/ports/mimxrt10xx/common-hal/busio/I2C.c index 50aae54aba..6c5bbea416 100644 --- a/ports/mimxrt10xx/common-hal/busio/I2C.c +++ b/ports/mimxrt10xx/common-hal/busio/I2C.c @@ -34,8 +34,8 @@ #include "py/runtime.h" #include "periph.h" -#include "fsl_lpi2c.h" -#include "fsl_gpio.h" +#include "sdk/drivers/lpi2c/fsl_lpi2c.h" +#include "sdk/drivers/igpio/fsl_gpio.h" #define I2C_CLOCK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8 / (1 + CLOCK_GetDiv(kCLOCK_Lpi2cDiv))) #define IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5 5U diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c index 0048c2aeb2..d88b71a403 100644 --- a/ports/mimxrt10xx/common-hal/busio/SPI.c +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "periph.h" -#include "fsl_lpspi.h" +#include "sdk/drivers/lpspi/fsl_lpspi.h" #include diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index 086b8dee87..088b2aefc6 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -38,8 +38,8 @@ #include "py/stream.h" #include "periph.h" -#include "fsl_lpuart.h" -#include "fsl_gpio.h" +#include "sdk/drivers/lpuart/fsl_lpuart.h" +#include "sdk/drivers/igpio/fsl_gpio.h" // ========================================================== // Debug code // ========================================================== diff --git a/ports/mimxrt10xx/common-hal/busio/UART.h b/ports/mimxrt10xx/common-hal/busio/UART.h index bc8374aabb..f09de935c2 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.h +++ b/ports/mimxrt10xx/common-hal/busio/UART.h @@ -34,7 +34,7 @@ #include "py/obj.h" #include "periph.h" -#include "fsl_lpuart.h" +#include "sdk/drivers/lpuart/fsl_lpuart.h" typedef struct { mp_obj_base_t base; diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c index d800de15de..3445cf42a0 100644 --- a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "py/mphal.h" -#include "fsl_gpio.h" +#include "sdk/drivers/igpio/fsl_gpio.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index 17ced78910..9277f81d47 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -33,8 +33,8 @@ #include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" -#include "fsl_tempmon.h" -#include "fsl_ocotp.h" +#include "sdk/drivers/tempmon/fsl_tempmon.h" +#include "sdk/drivers/ocotp/fsl_ocotp.h" #include "clocks.h" float common_hal_mcu_processor_get_temperature(void) { diff --git a/ports/mimxrt10xx/common-hal/os/__init__.c b/ports/mimxrt10xx/common-hal/os/__init__.c index e2c43e43fa..9219242685 100644 --- a/ports/mimxrt10xx/common-hal/os/__init__.c +++ b/ports/mimxrt10xx/common-hal/os/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/os/__init__.h" -#include "fsl_trng.h" +#include "sdk/drivers/trng/fsl_trng.h" STATIC const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, diff --git a/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c index c2afb38664..0bf11403d2 100644 --- a/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c +++ b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -33,7 +33,7 @@ #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/microcontroller/Pin.h" -#include "fsl_pwm.h" +#include "sdk/drivers/pwm/fsl_pwm.h" #include "supervisor/shared/translate/translate.h" #include "periph.h" @@ -240,7 +240,6 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self, // Disable all fault inputs flexpwm->SM[submodule].DISMAP[0] = 0; - flexpwm->SM[submodule].DISMAP[1] = 0; PWM_SetPwmLdok(flexpwm, sm_mask, false); flexpwm->SM[submodule].CTRL = PWM_CTRL_FULL_MASK | PWM_CTRL_PRSC(self->prescaler); diff --git a/ports/mimxrt10xx/common-hal/rtc/RTC.c b/ports/mimxrt10xx/common-hal/rtc/RTC.c index 0cf5fe7713..386b6a3ac5 100644 --- a/ports/mimxrt10xx/common-hal/rtc/RTC.c +++ b/ports/mimxrt10xx/common-hal/rtc/RTC.c @@ -35,8 +35,8 @@ #include "common-hal/rtc/RTC.h" #include "supervisor/shared/translate/translate.h" -#include "fsl_snvs_hp.h" -#include "fsl_snvs_lp.h" +#include "sdk/drivers/snvs_hp/fsl_snvs_hp.h" +#include "sdk/drivers/snvs_lp/fsl_snvs_lp.h" void rtc_init(void) { snvs_hp_rtc_config_t hpconfig; diff --git a/ports/mimxrt10xx/linking/common.ld b/ports/mimxrt10xx/linking/common.ld index 461a9d89eb..76c11c8d6f 100644 --- a/ports/mimxrt10xx/linking/common.ld +++ b/ports/mimxrt10xx/linking/common.ld @@ -195,6 +195,8 @@ SECTIONS . += _ld_default_stack_size; } > DTCM _ld_stack_top = ORIGIN(DTCM) + LENGTH(DTCM); + /* For the SDK's isr vector table */ + __StackTop = ORIGIN(DTCM) + LENGTH(DTCM); .ARM.attributes 0 : { *(.ARM.attributes) } } diff --git a/ports/mimxrt10xx/mphalport.c b/ports/mimxrt10xx/mphalport.c index ad0fb4d9ba..f160cf1365 100644 --- a/ports/mimxrt10xx/mphalport.c +++ b/ports/mimxrt10xx/mphalport.c @@ -35,11 +35,7 @@ #include "fsl_common.h" void mp_hal_delay_us(mp_uint_t delay) { - #if defined(MIMXRT1011_SERIES) || defined(MIMXRT1021_SERIES) SDK_DelayAtLeastUs(delay, SystemCoreClock); - #else - SDK_DelayAtLeastUs(delay); - #endif } void mp_hal_disable_all_interrupts(void) { diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h index d6d12771c5..82cb0dc69e 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h @@ -35,7 +35,7 @@ #include #include "fsl_iomuxc.h" -#include "fsl_pwm.h" +#include "sdk/drivers/pwm/fsl_pwm.h" #include "py/obj.h" extern const mp_obj_type_t mcu_pin_type; diff --git a/ports/mimxrt10xx/sdk b/ports/mimxrt10xx/sdk index 8363ff7bed..2b9354539e 160000 --- a/ports/mimxrt10xx/sdk +++ b/ports/mimxrt10xx/sdk @@ -1 +1 @@ -Subproject commit 8363ff7bed7533b9e7e6a6239aace3d6da14f349 +Subproject commit 2b9354539e6e4f722749e87b0bdc22966dc080d9 diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c index 7563f386f9..e32eaf8832 100644 --- a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -7,7 +7,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "fsl_flexspi.h" +#include "sdk/drivers/flexspi/fsl_flexspi.h" #include "internal_flash.h" #include "boards/flash_config.h" #include "supervisor/internal_flash.h" diff --git a/ports/mimxrt10xx/supervisor/internal_flash.c b/ports/mimxrt10xx/supervisor/internal_flash.c index 30a033a183..bacb62854a 100644 --- a/ports/mimxrt10xx/supervisor/internal_flash.c +++ b/ports/mimxrt10xx/supervisor/internal_flash.c @@ -38,8 +38,8 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" -#include "fsl_cache.h" -#include "fsl_flexspi.h" +#include "sdk/drivers/cache/armv7-m7/fsl_cache.h" +#include "sdk/drivers/flexspi/fsl_flexspi.h" #include "fsl_iomuxc.h" // defined in linker diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index a27ab3ea58..55bf72352d 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -54,8 +54,8 @@ #include "clocks.h" -#include "fsl_gpio.h" -#include "fsl_lpuart.h" +#include "sdk/drivers/igpio/fsl_gpio.h" +#include "sdk/drivers/lpuart/fsl_lpuart.h" // Device memories must be accessed in order. #define DEVICE 2 @@ -102,6 +102,36 @@ extern uint32_t _ld_isr_destination; extern uint32_t _ld_isr_size; extern uint32_t _ld_isr_flash_copy; +// Remove these once the SDK re-includes them. +// https://github.com/nxp-mcuxpresso/mcux-sdk/issues/110 +/*! @name GPR14 - GPR14 General Purpose Register */ +/*! @{ */ +#define IOMUXC_GPR_GPR14_CM7_CFGITCMSZ_MASK (0xF0000U) +#define IOMUXC_GPR_GPR14_CM7_CFGITCMSZ_SHIFT (16U) +/*! CM7_CFGITCMSZ + * 0b0000..0 KB (No ITCM) + * 0b0011..4 KB + * 0b0100..8 KB + * 0b0101..16 KB + * 0b0110..32 KB + * 0b0111..64 KB + * 0b1000..128 KB + */ +#define IOMUXC_GPR_GPR14_CM7_CFGITCMSZ(x) (((uint32_t)(((uint32_t)(x)) << IOMUXC_GPR_GPR14_CM7_CFGITCMSZ_SHIFT)) & IOMUXC_GPR_GPR14_CM7_CFGITCMSZ_MASK) +#define IOMUXC_GPR_GPR14_CM7_CFGDTCMSZ_MASK (0xF00000U) +#define IOMUXC_GPR_GPR14_CM7_CFGDTCMSZ_SHIFT (20U) +/*! CM7_CFGDTCMSZ + * 0b0000..0 KB (No DTCM) + * 0b0011..4 KB + * 0b0100..8 KB + * 0b0101..16 KB + * 0b0110..32 KB + * 0b0111..64 KB + * 0b1000..128 KB + */ +#define IOMUXC_GPR_GPR14_CM7_CFGDTCMSZ(x) (((uint32_t)(((uint32_t)(x)) << IOMUXC_GPR_GPR14_CM7_CFGDTCMSZ_SHIFT)) & IOMUXC_GPR_GPR14_CM7_CFGDTCMSZ_MASK) +/*! @} */ + extern void main(void); // This replaces the Reset_Handler in startup_*.S and SystemInit in system_*.c. From 0eb08509f0f9e6aa353782b9d20c69714dd77034 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 21 Mar 2023 16:42:49 -0700 Subject: [PATCH 074/225] Make set_stack_limit respect fixed stack Fixes #2830 --- shared-bindings/supervisor/Runtime.c | 6 +++++- supervisor/shared/stack.c | 12 ++++++++++-- supervisor/shared/stack.h | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index db3d8d1e4d..ecdd914a8f 100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -197,7 +197,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_next_stack_limit_obj, superviso STATIC mp_obj_t supervisor_runtime_set_next_stack_limit(mp_obj_t self, mp_obj_t size_obj) { mp_int_t size = mp_obj_get_int(size_obj); mp_arg_validate_int_min(size, 256, MP_QSTR_size); - set_next_stack_size(size); + if (!set_next_stack_size(size)) { + mp_raise_msg_varg(&mp_type_AttributeError, + MP_ERROR_TEXT("can't set attribute '%q'"), + MP_QSTR_next_stack_limit); + } return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(supervisor_runtime_set_next_stack_limit_obj, supervisor_runtime_set_next_stack_limit); diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index be97cee234..148bb0bbd5 100644 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -35,7 +35,7 @@ extern uint32_t _estack; // Requested size. -static uint32_t next_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE; +static uint32_t next_stack_size = 0; static uint32_t current_stack_size = 0; // Actual location and size, may be larger than requested. static uint32_t *stack_limit = NULL; @@ -49,11 +49,15 @@ static void allocate_stack(void) { stack_limit = port_stack_get_limit(); stack_length = (port_stack_get_top() - stack_limit) * sizeof(uint32_t); current_stack_size = stack_length; + next_stack_size = stack_length; } else { mp_uint_t regs[10]; mp_uint_t sp = cpu_get_regs_and_sp(regs); mp_uint_t c_size = (mp_uint_t)port_stack_get_top() - sp; + if (next_stack_size == 0) { + next_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE; + } supervisor_allocation *stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true, false); if (stack_alloc == NULL) { stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true, false); @@ -103,8 +107,12 @@ size_t stack_get_length(void) { return stack_length; } -void set_next_stack_size(uint32_t size) { +bool set_next_stack_size(uint32_t size) { + if (port_has_fixed_stack()) { + return false; + } next_stack_size = size; + return true; } uint32_t get_next_stack_size(void) { diff --git a/supervisor/shared/stack.h b/supervisor/shared/stack.h index 4acda57354..4a03fcf275 100644 --- a/supervisor/shared/stack.h +++ b/supervisor/shared/stack.h @@ -37,7 +37,7 @@ void stack_resize(void); uint32_t *stack_get_bottom(void); size_t stack_get_length(void); // Next/current requested stack size. -void set_next_stack_size(uint32_t size); +bool set_next_stack_size(uint32_t size); uint32_t get_next_stack_size(void); uint32_t get_current_stack_size(void); bool stack_ok(void); From 349dedca5416d22ac9934d5357adbb0641e0cce3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 22 Mar 2023 09:35:01 -0500 Subject: [PATCH 075/225] struct: Check that argument counts match, similar to cpython3 .. and test our struct module during the build-time tests Closes #7771 --- .../unix/variants/coverage/mpconfigvariant.h | 1 + .../unix/variants/coverage/mpconfigvariant.mk | 3 ++ shared-module/struct/__init__.c | 32 +++++++++------- tests/circuitpython/struct_nargs.py | 38 +++++++++++++++++++ tests/unix/extra_coverage.py.exp | 18 ++++----- 5 files changed, 69 insertions(+), 23 deletions(-) create mode 100644 tests/circuitpython/struct_nargs.py diff --git a/ports/unix/variants/coverage/mpconfigvariant.h b/ports/unix/variants/coverage/mpconfigvariant.h index ba9e941c28..0c6e10aeae 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.h +++ b/ports/unix/variants/coverage/mpconfigvariant.h @@ -62,6 +62,7 @@ #define MICROPY_PY_FRAMEBUF (1) #define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (1) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) +#define MICROPY_PY_STRUCT (0) // uses shared-bindings struct #define MICROPY_PY_UCRYPTOLIB (1) #define MICROPY_PY_UCRYPTOLIB_CTR (1) #define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (1) diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index fd12bbd8b5..20320916bc 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -33,6 +33,7 @@ SRC_BITMAP := \ shared-bindings/bitmaptools/__init__.c \ shared-bindings/displayio/Bitmap.c \ shared-bindings/rainbowio/__init__.c \ + shared-bindings/struct/__init__.c \ shared-bindings/traceback/__init__.c \ shared-bindings/util.c \ shared-bindings/zlib/__init__.c \ @@ -45,6 +46,7 @@ SRC_BITMAP := \ shared-module/displayio/ColorConverter.c \ shared-module/os/getenv.c \ shared-module/rainbowio/__init__.c \ + shared-module/struct/__init__.c \ shared-module/traceback/__init__.c \ shared-module/zlib/__init__.c \ @@ -57,6 +59,7 @@ CFLAGS += \ -DCIRCUITPY_OS_GETENV=1 \ -DCIRCUITPY_GIFIO=1 \ -DCIRCUITPY_RAINBOWIO=1 \ + -DCIRCUITPY_STRUCT=1 \ -DCIRCUITPY_TRACEBACK=1 \ -DCIRCUITPY_ZLIB=1 diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index e87321ae79..dedaf93afa 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -129,14 +129,10 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size mp_raise_RuntimeError(translate("buffer too small")); } - size_t i; + size_t i = 0; byte *p_base = p; - for (i = 0; i < n_args;) { + while (*fmt) { mp_uint_t sz = 1; - if (*fmt == '\0') { - // more arguments given than used by format string; CPython raises struct.error here - mp_raise_RuntimeError(translate("too many arguments provided with the given format")); - } struct_validate_format(*fmt); if (unichar_isdigit(*fmt)) { @@ -144,14 +140,17 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size } if (*fmt == 's') { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[i++], &bufinfo, MP_BUFFER_READ); - mp_uint_t to_copy = sz; - if (bufinfo.len < to_copy) { - to_copy = bufinfo.len; + if (i < n_args) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[i], &bufinfo, MP_BUFFER_READ); + mp_uint_t to_copy = sz; + if (bufinfo.len < to_copy) { + to_copy = bufinfo.len; + } + memcpy(p, bufinfo.buf, to_copy); + memset(p + to_copy, 0, sz - to_copy); } - memcpy(p, bufinfo.buf, to_copy); - memset(p + to_copy, 0, sz - to_copy); + i++; p += sz; } else { while (sz--) { @@ -159,13 +158,18 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size if (*fmt == 'x') { mp_binary_set_val(fmt_type, *fmt, MP_OBJ_NEW_SMALL_INT(0), p_base, &p); } else { - mp_binary_set_val(fmt_type, *fmt, args[i], p_base, &p); + if (i < n_args) { + mp_binary_set_val(fmt_type, *fmt, args[i], p_base, &p); + } i++; } } } fmt++; } + if (i != n_args) { + mp_raise_ValueError_varg(translate("%q length must be %d"), MP_QSTR_args, i); + } } mp_obj_tuple_t *shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p, bool exact_size) { diff --git a/tests/circuitpython/struct_nargs.py b/tests/circuitpython/struct_nargs.py new file mode 100644 index 0000000000..0a0cb140c3 --- /dev/null +++ b/tests/circuitpython/struct_nargs.py @@ -0,0 +1,38 @@ +import struct + + +def do_pack(*args): + try: + print(struct.pack(*args)) + except Exception as e: + print("ERROR") + + +do_pack("H") +do_pack("H", 1) +do_pack("H", 1, 2) + +do_pack("2H") +do_pack("2H", 1) +do_pack("2H", 1, 2) + +do_pack("3H") +do_pack("3H", 1) +do_pack("3H", 1, 2) +do_pack("3H", 1, 2, 3) +do_pack("3H", 1, 2, 3, 4) + +do_pack("4sH", b"x") +do_pack("4sH", b"x", 1) +do_pack("4sH", b"x", 1, 2) + +do_pack("4s2H", b"x") +do_pack("4s2H", b"x", 1) +do_pack("4s2H", b"x", 1, 2) +do_pack("4s2H", b"x", 1, 2, 3) + +do_pack("4s3H", b"x") +do_pack("4s3H", b"x", 1) +do_pack("4s3H", b"x", 1, 2) +do_pack("4s3H", b"x", 1, 2, 3) +do_pack("4s3H", b"x", 1, 2, 3, 4) diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 65f67f0727..8014dd3010 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -35,15 +35,15 @@ bitmaptools btree cexample cmath collections cppexample displayio errno ffi framebuf gc hashlib json math qrio rainbowio -re sys termios traceback -ubinascii uctypes uerrno uheapq -uio ujson ulab ulab.numpy -ulab.numpy.fft ulab.numpy.linalg ulab.scipy -ulab.scipy.linalg ulab.scipy.optimize -ulab.scipy.signal ulab.scipy.special -ulab.utils uos urandom ure -uselect ustruct utime utimeq -uzlib zlib +re struct sys termios +traceback ubinascii uctypes uerrno +uheapq uio ujson ulab +ulab.numpy ulab.numpy.fft ulab.numpy.linalg +ulab.scipy ulab.scipy.linalg +ulab.scipy.optimize ulab.scipy.signal +ulab.scipy.special ulab.utils uos +urandom ure uselect utime +utimeq uzlib zlib ime utime utimeq From 98c546bf57977c73eddf923475b7bb23db0ec600 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 22 Mar 2023 10:16:48 -0500 Subject: [PATCH 076/225] call common validation function Co-authored-by: MicroDev <70126934+microdev1@users.noreply.github.com> --- shared-module/struct/__init__.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index dedaf93afa..b595504969 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -167,9 +167,7 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size } fmt++; } - if (i != n_args) { - mp_raise_ValueError_varg(translate("%q length must be %d"), MP_QSTR_args, i); - } + (void)mp_arg_validate_length(n_args, i, MP_QSTR_args); } mp_obj_tuple_t *shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p, bool exact_size) { From b5834886521a16419af25c512472029f97234cd6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 22 Mar 2023 09:24:03 -0700 Subject: [PATCH 077/225] Fix stub --- supervisor/stub/stack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/supervisor/stub/stack.c b/supervisor/stub/stack.c index 2abc197878..bb6e0d4cb0 100644 --- a/supervisor/stub/stack.c +++ b/supervisor/stub/stack.c @@ -39,8 +39,9 @@ void stack_init(void) { void stack_resize(void) { } -void set_next_stack_size(uint32_t size) { +bool set_next_stack_size(uint32_t size) { (void)size; + return true; } uint32_t get_current_stack_size(void) { From 32973423046b1804648e95c6891d3a7798cdb03e Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 22 Mar 2023 17:39:25 +0100 Subject: [PATCH 078/225] 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 | 12 ++++-------- locale/cs.po | 12 ++++-------- locale/de_DE.po | 27 +++++++++++++++------------ locale/el.po | 12 ++++-------- locale/en_GB.po | 12 ++++-------- locale/es.po | 27 +++++++++++++++------------ locale/fil.po | 12 ++++-------- locale/fr.po | 27 +++++++++++++++------------ locale/hi.po | 12 ++++-------- locale/it_IT.po | 12 ++++-------- locale/ja.po | 12 ++++-------- locale/ko.po | 12 ++++-------- locale/nl.po | 12 ++++-------- locale/pl.po | 12 ++++-------- locale/pt_BR.po | 27 +++++++++++++++------------ locale/ru.po | 12 ++++-------- locale/sv.po | 27 +++++++++++++++------------ locale/tr.po | 12 ++++-------- locale/zh_Latn_pinyin.po | 27 +++++++++++++++------------ 19 files changed, 142 insertions(+), 176 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index f6960665b4..a136f6e498 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -30,14 +30,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1264,6 +1256,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index 0ffdbdcc67..1d666730ec 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -32,14 +32,6 @@ msgstr "" "\n" "Kód byl zastaven kvůli automatickému načtení. K načtení dojde brzy.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1264,6 +1256,10 @@ msgstr "Chybný BLE parametr" msgid "Invalid BSSID" msgstr "Chybné BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Chybná MAC adresa" diff --git a/locale/de_DE.po b/locale/de_DE.po index 9f2c83e8cc..f6bc0b789e 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -31,18 +31,6 @@ msgstr "" "\n" "Code wurde durch automatisches Neuladen gestoppt. Wird bald neu geladen.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" -"\n" -"Ungültige CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\n" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1287,6 +1275,10 @@ msgstr "Ungültiges BLE Parameter" msgid "Invalid BSSID" msgstr "Ungültige BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Ungültige MAC-Adresse" @@ -4473,6 +4465,17 @@ msgstr "zi muss eine Gleitkommazahl sein" msgid "zi must be of shape (n_section, 2)" msgstr "zi muss die Form (n_section, 2) haben" +#~ msgid "" +#~ "\n" +#~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\r" +#~ msgstr "" +#~ "\n" +#~ "Ungültige CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\n" + #~ msgid "Supply at least one UART pin" #~ msgstr "Gib mindestens einen UART-Pin an" diff --git a/locale/el.po b/locale/el.po index 81118aa8fd..f2382feb94 100644 --- a/locale/el.po +++ b/locale/el.po @@ -35,14 +35,6 @@ msgstr "" "Ο κώδικας σταμάτησε λόγω της αυτόματης επαναφόρτωσης. Η επαναφόρτωση θα " "γίνει σύντομα.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1273,6 +1265,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index 9ced3137b9..45131d1dcb 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -34,14 +34,6 @@ msgstr "" "\n" "Code stopped by auto-reload. Reloading soon.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1265,6 +1257,10 @@ msgstr "Invalid BLE parameter" msgid "Invalid BSSID" msgstr "Invalid BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/es.po b/locale/es.po index ee2af9d603..cf81206c3d 100644 --- a/locale/es.po +++ b/locale/es.po @@ -34,18 +34,6 @@ msgstr "" "\n" "Código detenido por la auto-recarga. Recargando pronto.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" -"\n" -"CIRCUITPY_PYSTACK_SIZE inválido\n" -"\n" -"\n" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1302,6 +1290,10 @@ msgstr "Parámetro BLE invalido" msgid "Invalid BSSID" msgstr "BSSID inválido" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Dirección MAC inválida" @@ -4481,6 +4473,17 @@ 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 "" +#~ "\n" +#~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\r" +#~ msgstr "" +#~ "\n" +#~ "CIRCUITPY_PYSTACK_SIZE inválido\n" +#~ "\n" +#~ "\n" + #~ msgid "Supply at least one UART pin" #~ msgstr "Suministre al menos un pin UART" diff --git a/locale/fil.po b/locale/fil.po index f943746a34..591620e6c4 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -29,14 +29,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1264,6 +1256,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 424e16a1b5..4ebcc918bf 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -34,18 +34,6 @@ msgstr "" "Le code a été arrêté par l'actualisation automatique. Rechargement " "prochain.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" -"\n" -"CIRCUITPY_PYSTACK_SIZE invalide\n" -"\n" -"\n" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1308,6 +1296,10 @@ msgstr "Paramètre BLE invalide" msgid "Invalid BSSID" msgstr "BSSID invalide" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Adresse MAC invalide" @@ -4500,6 +4492,17 @@ 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 "" +#~ "\n" +#~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\r" +#~ msgstr "" +#~ "\n" +#~ "CIRCUITPY_PYSTACK_SIZE invalide\n" +#~ "\n" +#~ "\n" + #~ msgid "Supply at least one UART pin" #~ msgstr "Fournissez au moins une broche UART" diff --git a/locale/hi.po b/locale/hi.po index 94a42e19f8..2b9825e4b8 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -28,14 +28,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1252,6 +1244,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 5fb7e50d6b..84bc790df4 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -31,14 +31,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1266,6 +1258,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 7e63cb55c3..081dd57e9f 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -34,14 +34,6 @@ msgstr "" "\n" "オートリロードでコード実行は中止された。まもなくリロードする。\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1265,6 +1257,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "不正なBSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 129c9b4bcd..7668d8c8a3 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -29,14 +29,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1255,6 +1247,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 87fdb61c60..61c96a877d 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -28,14 +28,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1260,6 +1252,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "Ongeldig BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 1348c0f321..642e5f99de 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -30,14 +30,6 @@ msgid "" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1260,6 +1252,10 @@ msgstr "" msgid "Invalid BSSID" msgstr "" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index fdf2eaaf31..bef3ea8849 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -32,18 +32,6 @@ msgstr "" "\n" "O código parou pela recarga automática. Recarregando em breve.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" -"\n" -"CIRCUITPY_PYSTACK_SIZE inválido\n" -"\n" -"\n" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1298,6 +1286,10 @@ msgstr "Parâmetro BLE inválido" msgid "Invalid BSSID" msgstr "BSSID Inválido" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Endereço MAC inválido" @@ -4481,6 +4473,17 @@ 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 "" +#~ "\n" +#~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\r" +#~ msgstr "" +#~ "\n" +#~ "CIRCUITPY_PYSTACK_SIZE inválido\n" +#~ "\n" +#~ "\n" + #~ msgid "Supply at least one UART pin" #~ msgstr "Forneça pelo menos um pino UART" diff --git a/locale/ru.po b/locale/ru.po index 0fe6cfac97..2ad4b094a2 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -34,14 +34,6 @@ msgstr "" "\n" "Программа остановлена автоматической перезагрузкой. Скоро перезагрузка.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1297,6 +1289,10 @@ msgstr "Недопустимый параметр BLE" msgid "Invalid BSSID" msgstr "Неверный BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Неверный MAC-адрес" diff --git a/locale/sv.po b/locale/sv.po index 84ce4b6ecb..3c2c9f6520 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -32,18 +32,6 @@ msgstr "" "\n" "Koden stoppades av automatisk laddning. Omladdning sker strax.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" -"\n" -"Ogiltig CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\n" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1283,6 +1271,10 @@ msgstr "Ogiltig BLE-parameter" msgid "Invalid BSSID" msgstr "Ogiltig BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Ogiltig MAC-adress" @@ -4443,6 +4435,17 @@ 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 "" +#~ "\n" +#~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\r" +#~ msgstr "" +#~ "\n" +#~ "Ogiltig CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\n" + #~ msgid "Supply at least one UART pin" #~ msgstr "Ange minst en UART-pinne" diff --git a/locale/tr.po b/locale/tr.po index 67a73375ea..bd9d746940 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -34,14 +34,6 @@ msgstr "" "Program otomatik yeniden yükleme tarafından durduruldu. Birazdan tekrar " "yüklenecek.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1270,6 +1262,10 @@ msgstr "Geçersiz BLE parametresi" msgid "Invalid BSSID" msgstr "Geçersiz BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "Geçersiz MAC adresi" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 485c30353d..72df0f5aed 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -34,18 +34,6 @@ msgstr "" "dài mǎ yīn zì dòng chóng xīn jiā zǎi ér tíng zhǐ. jí jiāng chóng xīn jiā " "zǎi.\n" -#: main.c -msgid "" -"\n" -"Invalid CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\r" -msgstr "" -"\n" -"wú xiào CIRCUITPY_PYSTACK_SIZE\n" -"\n" -"\n" - #: supervisor/shared/safe_mode.c msgid "" "\n" @@ -1290,6 +1278,10 @@ msgstr "wú xiào BLE cān shù" msgid "Invalid BSSID" msgstr "Wúxiào de BSSID" +#: main.c +msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" msgstr "wú xiào de MAC dì zhǐ" @@ -4449,6 +4441,17 @@ 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 "" +#~ "\n" +#~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\r" +#~ msgstr "" +#~ "\n" +#~ "wú xiào CIRCUITPY_PYSTACK_SIZE\n" +#~ "\n" +#~ "\n" + #~ msgid "Supply at least one UART pin" #~ msgstr "Dìngyì zhìshǎo yīgè UART yǐn jiǎo" From 08358ecd5004fe14169d0851dcae8635a13befe3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 20 Mar 2023 10:28:46 -0500 Subject: [PATCH 079/225] constify spi, i2c, uart bank data --- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c | 6 +++--- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h | 6 +++--- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c | 6 +++--- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h | 6 +++--- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c | 6 +++--- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h | 6 +++--- ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c index bdf3299217..0c2b5893bc 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c @@ -29,7 +29,7 @@ #include "py/mphal.h" #include "mimxrt10xx/periph.h" -LPI2C_Type *mcu_i2c_banks[2] = { LPI2C1, LPI2C2 }; +LPI2C_Type *const mcu_i2c_banks[2] = { LPI2C1, LPI2C2 }; const mcu_periph_obj_t mcu_i2c_sda_list[8] = { PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_13), @@ -55,7 +55,7 @@ const mcu_periph_obj_t mcu_i2c_scl_list[8] = { PERIPH_PIN(2, 3, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 3, &pin_GPIO_10), }; -LPSPI_Type *mcu_spi_banks[2] = { LPSPI1, LPSPI2 }; +LPSPI_Type *const mcu_spi_banks[2] = { LPSPI1, LPSPI2 }; const mcu_periph_obj_t mcu_spi_sck_list[4] = { PERIPH_PIN(1, 0, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_06), @@ -81,7 +81,7 @@ const mcu_periph_obj_t mcu_spi_miso_list[4] = { PERIPH_PIN(2, 1, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_SD_09), }; -LPUART_Type *mcu_uart_banks[4] = { LPUART1, LPUART2, LPUART3, LPUART4 }; +LPUART_Type *const mcu_uart_banks[4] = { LPUART1, LPUART2, LPUART3, LPUART4 }; const mcu_periph_obj_t mcu_uart_rx_list[9] = { PERIPH_PIN(1, 2, kIOMUXC_LPUART1_RXD_SELECT_INPUT, 0, &pin_GPIO_SD_11), diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h index c50d73294b..b3bddcb76b 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h @@ -27,18 +27,18 @@ #ifndef MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1011_PERIPHERALS_MIMXRT1011_PERIPH_H #define MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1011_PERIPHERALS_MIMXRT1011_PERIPH_H -extern LPI2C_Type *mcu_i2c_banks[2]; +extern LPI2C_Type *const mcu_i2c_banks[2]; extern const mcu_periph_obj_t mcu_i2c_sda_list[8]; extern const mcu_periph_obj_t mcu_i2c_scl_list[8]; -extern LPSPI_Type *mcu_spi_banks[2]; +extern LPSPI_Type *const mcu_spi_banks[2]; extern const mcu_periph_obj_t mcu_spi_sck_list[4]; extern const mcu_periph_obj_t mcu_spi_mosi_list[4]; extern const mcu_periph_obj_t mcu_spi_miso_list[4]; -extern LPUART_Type *mcu_uart_banks[4]; +extern LPUART_Type *const mcu_uart_banks[4]; extern const mcu_periph_obj_t mcu_uart_rx_list[9]; extern const mcu_periph_obj_t mcu_uart_tx_list[9]; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c index 5b21c12c2a..ffcadbb696 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c @@ -30,7 +30,7 @@ #include "py/mphal.h" #include "mimxrt10xx/periph.h" -LPI2C_Type *mcu_i2c_banks[4] = { LPI2C1, LPI2C2, LPI2C3, LPI2C4 }; +LPI2C_Type *const mcu_i2c_banks[4] = { LPI2C1, LPI2C2, LPI2C3, LPI2C4 }; const mcu_periph_obj_t mcu_i2c_sda_list[8] = { PERIPH_PIN(1, 6, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 0, &pin_GPIO_EMC_03), @@ -60,7 +60,7 @@ const mcu_periph_obj_t mcu_i2c_scl_list[8] = { PERIPH_PIN(4, 3, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 1, &pin_GPIO_SD_B1_02), }; -LPSPI_Type *mcu_spi_banks[4] = { LPSPI1, LPSPI2, LPSPI3, LPSPI4 }; +LPSPI_Type *const mcu_spi_banks[4] = { LPSPI1, LPSPI2, LPSPI3, LPSPI4 }; const mcu_periph_obj_t mcu_spi_sck_list[8] = { PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 0, &pin_GPIO_SD_B0_02), @@ -104,7 +104,7 @@ const mcu_periph_obj_t mcu_spi_miso_list[8] = { PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_35), }; -LPUART_Type *mcu_uart_banks[8] = { LPUART1, LPUART2, LPUART3, LPUART4, LPUART5, LPUART6, LPUART7, LPUART8 }; +LPUART_Type *const mcu_uart_banks[8] = { LPUART1, LPUART2, LPUART3, LPUART4, LPUART5, LPUART6, LPUART7, LPUART8 }; const mcu_periph_obj_t mcu_uart_rx_list[16] = { PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_07), diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h index 6c778ad525..9074987cd8 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h @@ -28,18 +28,18 @@ #ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H #define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H -extern LPI2C_Type *mcu_i2c_banks[4]; +extern LPI2C_Type *const mcu_i2c_banks[4]; extern const mcu_periph_obj_t mcu_i2c_sda_list[8]; extern const mcu_periph_obj_t mcu_i2c_scl_list[8]; -extern LPSPI_Type *mcu_spi_banks[4]; +extern LPSPI_Type *const mcu_spi_banks[4]; extern const mcu_periph_obj_t mcu_spi_sck_list[8]; extern const mcu_periph_obj_t mcu_spi_mosi_list[8]; extern const mcu_periph_obj_t mcu_spi_miso_list[8]; -extern LPUART_Type *mcu_uart_banks[8]; +extern LPUART_Type *const mcu_uart_banks[8]; extern const mcu_periph_obj_t mcu_uart_rx_list[16]; extern const mcu_periph_obj_t mcu_uart_tx_list[16]; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c index 19ce48f288..b6efe5e6a9 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c @@ -29,7 +29,7 @@ #include "py/mphal.h" #include "mimxrt10xx/periph.h" -LPI2C_Type *mcu_i2c_banks[4] = { LPI2C1, LPI2C2, LPI2C3, LPI2C4 }; +LPI2C_Type *const mcu_i2c_banks[4] = { LPI2C1, LPI2C2, LPI2C3, LPI2C4 }; const mcu_periph_obj_t mcu_i2c_sda_list[9] = { PERIPH_PIN(1, 2, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 0, &pin_GPIO_SD_B1_05), @@ -61,7 +61,7 @@ const mcu_periph_obj_t mcu_i2c_scl_list[9] = { PERIPH_PIN(4, 0, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 1, &pin_GPIO_AD_B0_12), }; -LPSPI_Type *mcu_spi_banks[4] = { LPSPI1, LPSPI2, LPSPI3, LPSPI4 }; +LPSPI_Type *const mcu_spi_banks[4] = { LPSPI1, LPSPI2, LPSPI3, LPSPI4 }; const mcu_periph_obj_t mcu_spi_sck_list[8] = { PERIPH_PIN(1, 3, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 0, &pin_GPIO_EMC_27), @@ -105,7 +105,7 @@ const mcu_periph_obj_t mcu_spi_miso_list[8] = { PERIPH_PIN(4, 1, kIOMUXC_LPSPI4_SDI_SELECT_INPUT, 1, &pin_GPIO_B1_05), }; -LPUART_Type *mcu_uart_banks[8] = { LPUART1, LPUART2, LPUART3, LPUART4, LPUART5, LPUART6, LPUART7, LPUART8 }; +LPUART_Type *const mcu_uart_banks[8] = { LPUART1, LPUART2, LPUART3, LPUART4, LPUART5, LPUART6, LPUART7, LPUART8 }; const mcu_periph_obj_t mcu_uart_rx_list[18] = { PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_13), diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h index 067c05d0d0..9a06a491f9 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h @@ -27,18 +27,18 @@ #ifndef MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1062_PERIPHERALS_MIMXRT1011_PERIPH_H #define MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1062_PERIPHERALS_MIMXRT1011_PERIPH_H -extern LPI2C_Type *mcu_i2c_banks[4]; +extern LPI2C_Type *const mcu_i2c_banks[4]; extern const mcu_periph_obj_t mcu_i2c_sda_list[9]; extern const mcu_periph_obj_t mcu_i2c_scl_list[9]; -extern LPSPI_Type *mcu_spi_banks[4]; +extern LPSPI_Type *const mcu_spi_banks[4]; extern const mcu_periph_obj_t mcu_spi_sck_list[8]; extern const mcu_periph_obj_t mcu_spi_mosi_list[8]; extern const mcu_periph_obj_t mcu_spi_miso_list[8]; -extern LPUART_Type *mcu_uart_banks[8]; +extern LPUART_Type *const mcu_uart_banks[8]; extern const mcu_periph_obj_t mcu_uart_rx_list[18]; extern const mcu_periph_obj_t mcu_uart_tx_list[18]; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h index c77497a775..818b203da4 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h @@ -72,9 +72,9 @@ typedef struct { .pin = p_pin, \ } -extern LPI2C_Type *mcu_i2c_banks[]; -extern LPSPI_Type *mcu_spi_banks[]; -extern LPUART_Type *mcu_uart_banks[]; +extern LPI2C_Type *const mcu_i2c_banks[]; +extern LPSPI_Type *const mcu_spi_banks[]; +extern LPUART_Type *const mcu_uart_banks[]; #ifdef MIMXRT1011_SERIES #include "MIMXRT1011/periph.h" From 1e1172bc246d325d342d48a35663116bafdfc631 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 21 Mar 2023 12:07:03 -0500 Subject: [PATCH 080/225] fix sorting of block --- ports/mimxrt10xx/mpconfigport.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 236d5b9966..7eaac85b34 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -11,8 +11,8 @@ CIRCUITPY_TUSB_MEM_ALIGN = 32 INTERNAL_FLASH_FILESYSTEM = 1 -CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_AUDIOIO = 0 CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 From 36dbaf4ccc51c61c11b90954ddbbed90927fb7ef Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 22 Mar 2023 10:14:34 -0700 Subject: [PATCH 081/225] Add more checks for read-only Bitmaps Fixes #7768 --- shared-module/displayio/Bitmap.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index dc82d04e05..8cb80a661d 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -128,6 +128,9 @@ void displayio_bitmap_set_dirty_area(displayio_bitmap_t *self, const displayio_a } void displayio_bitmap_write_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) { + if (self->read_only) { + mp_raise_RuntimeError(translate("Read-only")); + } // Writes the color index value into a pixel position // Must update the dirty area separately @@ -160,6 +163,9 @@ void displayio_bitmap_write_pixel(displayio_bitmap_t *self, int16_t x, int16_t y void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16_t y, displayio_bitmap_t *source, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t skip_index, bool skip_index_none) { + if (self->read_only) { + mp_raise_RuntimeError(translate("Read-only")); + } // Copy region of "source" bitmap into "self" bitmap at location x,y in the "self" // If skip_value is encountered in the source bitmap, it will not be copied. // If skip_value is `None`, then all pixels are copied. @@ -213,6 +219,9 @@ void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16 } void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) { + if (self->read_only) { + mp_raise_RuntimeError(translate("Read-only")); + } // update the dirty region displayio_area_t a = {x, y, x + 1, y + 1, NULL}; displayio_bitmap_set_dirty_area(self, &a); @@ -223,7 +232,7 @@ void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x, } displayio_area_t *displayio_bitmap_get_refresh_areas(displayio_bitmap_t *self, displayio_area_t *tail) { - if (self->dirty_area.x1 == self->dirty_area.x2) { + if (self->dirty_area.x1 == self->dirty_area.x2 || self->read_only) { return tail; } self->dirty_area.next = tail; @@ -231,11 +240,17 @@ displayio_area_t *displayio_bitmap_get_refresh_areas(displayio_bitmap_t *self, d } void displayio_bitmap_finish_refresh(displayio_bitmap_t *self) { + if (self->read_only) { + return; + } self->dirty_area.x1 = 0; self->dirty_area.x2 = 0; } void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value) { + if (self->read_only) { + mp_raise_RuntimeError(translate("Read-only")); + } displayio_area_t a = {0, 0, self->width, self->height, NULL}; displayio_bitmap_set_dirty_area(self, &a); From c6bc9c48c9958947c5e65e712bda953a024bfef0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 22 Mar 2023 12:14:00 -0500 Subject: [PATCH 082/225] mimxrt10xx: implement i2sout tested on metro m7 (green prototype version) with max98357a i2s amplifier and the following test code: ```py import board import time import digitalio from audiobusio import I2SOut from audiocore import RawSample from microcontroller import pin from ulab import numpy as np n = np.array(np.sin(np.linspace(0, np.pi*2, 218, endpoint=False)) * 200, dtype=np.int16) print(n) r = RawSample(n, sample_rate=8000, channel_count=2) def main(): with digitalio.DigitalInOut(board.LED) as l: l.switch_to_output(True) value = False while True: with I2SOut(pin.GPIO_06, pin.GPIO_07, pin.GPIO_04) as i: time.sleep(.01) l.value = value = not value i.play(r, loop=True) print(i.playing) time.sleep(.5) i.stop() print("STOPPED") print(i.playing) time.sleep(.5) i.play(r, loop=True) print(i.playing) print("PLAY AGAIN") time.sleep(.5) time.sleep(1) ``` Only stereo, 16-bit, raw samples were tested; the sample rate is actually fixed at 48kHz in the core right now. There is more to do, but the basics work. # Conflicts: # ports/mimxrt10xx/Makefile # ports/mimxrt10xx/mpconfigport.mk --- ports/mimxrt10xx/Makefile | 6 +- ports/mimxrt10xx/background.c | 3 - ports/mimxrt10xx/boards/metro_m7_1011/pins.c | 4 + .../mimxrt10xx/common-hal/audiobusio/I2SOut.c | 154 +++++++ .../mimxrt10xx/common-hal/audiobusio/I2SOut.h | 47 ++ .../mimxrt10xx/common-hal/audiobusio/PDMIn.c | 0 .../mimxrt10xx/common-hal/audiobusio/PDMIn.h | 0 .../common-hal/audiobusio/__init__.c | 422 ++++++++++++++++++ .../common-hal/audiobusio/__init__.h | 59 +++ .../common-hal/microcontroller/Pin.c | 19 +- .../common-hal/microcontroller/Pin.h | 12 +- ports/mimxrt10xx/mpconfigport.mk | 4 +- .../mimxrt10xx/MIMXRT1011/periph.c | 25 ++ .../mimxrt10xx/MIMXRT1011/periph.h | 7 + .../mimxrt10xx/MIMXRT1021/periph.c | 55 +++ .../mimxrt10xx/MIMXRT1021/periph.h | 10 +- .../mimxrt10xx/MIMXRT1062/periph.c | 56 +++ .../mimxrt10xx/MIMXRT1062/periph.h | 7 + .../peripherals/mimxrt10xx/periph.h | 2 +- ports/mimxrt10xx/supervisor/port.c | 7 +- 20 files changed, 878 insertions(+), 21 deletions(-) create mode 100644 ports/mimxrt10xx/common-hal/audiobusio/I2SOut.c create mode 100644 ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h create mode 100644 ports/mimxrt10xx/common-hal/audiobusio/PDMIn.c create mode 100644 ports/mimxrt10xx/common-hal/audiobusio/PDMIn.h create mode 100644 ports/mimxrt10xx/common-hal/audiobusio/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/audiobusio/__init__.h diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index d8d12b74da..27f3b0e304 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -119,6 +119,7 @@ SRC_SDK := \ drivers/lpuart/fsl_lpuart.c \ drivers/ocotp/fsl_ocotp.c \ drivers/pwm/fsl_pwm.c \ + drivers/sai/fsl_sai.c \ drivers/snvs_hp/fsl_snvs_hp.c \ drivers/snvs_lp/fsl_snvs_lp.c \ drivers/tempmon/fsl_tempmon.c \ @@ -146,11 +147,6 @@ SRC_C += \ endif -# TODO -#ifeq ($(CIRCUITPY_AUDIOBUSIO),1) -#SRC_C += peripherals/samd/i2s.c peripherals/samd/$(CHIP_FAMILY)/i2s.c -#endif -# SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \ $(addprefix common-hal/, $(SRC_COMMON_HAL)) diff --git a/ports/mimxrt10xx/background.c b/ports/mimxrt10xx/background.c index 529f791a39..faa2bda3f8 100644 --- a/ports/mimxrt10xx/background.c +++ b/ports/mimxrt10xx/background.c @@ -35,9 +35,6 @@ void PLACE_IN_ITCM(port_background_task)(void) { } void port_background_tick(void) { - #if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO - audio_dma_background(); - #endif } void port_start_background_task(void) { diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c index 886909e1dd..f48066dae1 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c @@ -56,5 +56,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_STEMMA_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_ROM_QSTR(MP_QSTR_I2S_WSEL), MP_ROM_PTR(&pin_GPIO_06) }, // D10 + { MP_ROM_QSTR(MP_QSTR_I2S_BCLK), MP_ROM_PTR(&pin_GPIO_07) }, // D9 + { MP_ROM_QSTR(MP_QSTR_I2S_DOUT), MP_ROM_PTR(&pin_GPIO_04) }, // D12 }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.c b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.c new file mode 100644 index 0000000000..06765afe02 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.c @@ -0,0 +1,154 @@ +/* + * This file is part of the MicroPython 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. + */ + +#include +#include + +#include "mpconfigport.h" + +// Some boards don't implement I2SOut, so suppress any routines from here. +#if CIRCUITPY_AUDIOBUSIO_I2SOUT + +#include "py/gc.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "common-hal/audiobusio/I2SOut.h" +#include "shared-bindings/audiobusio/I2SOut.h" +#include "shared-bindings/audiocore/RawSample.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate/translate.h" +#include "supervisor/shared/tick.h" + +// Where required we use identifier names that are required by NXP's +// API, even though they do not conform to the naming standards that Adafruit +// strives to adhere to. https://www.adafruit.com/blacklivesmatter +#include "sdk/drivers/sai/fsl_sai.h" + +STATIC void config_periph_pin(const mcu_periph_obj_t *periph) { + if (!periph) { + return; + } + if (periph->pin->mux_reg) { + IOMUXC_SetPinMux( + periph->pin->mux_reg, periph->mux_mode, + periph->input_reg, periph->input_idx, + 0, + 1); + } + + IOMUXC_SetPinConfig(0, 0, 0, 0, + periph->pin->cfg_reg, + IOMUXC_SW_PAD_CTL_PAD_HYS(0) + | IOMUXC_SW_PAD_CTL_PAD_PUS(0) + | IOMUXC_SW_PAD_CTL_PAD_PUE(0) + | IOMUXC_SW_PAD_CTL_PAD_PKE(1) + | IOMUXC_SW_PAD_CTL_PAD_ODE(0) + | IOMUXC_SW_PAD_CTL_PAD_SPEED(2) + | IOMUXC_SW_PAD_CTL_PAD_DSE(4) + | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); +} + +// Caller validates that pins are free. +void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self, + const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select, + const mcu_pin_obj_t *data, bool left_justified) { + + int instance = -1; + const mcu_periph_obj_t *bclk_periph = find_pin_function(mcu_sai_tx_bclk_list, bit_clock, &instance, MP_QSTR_bit_clock); + const mcu_periph_obj_t *sync_periph = find_pin_function(mcu_sai_tx_sync_list, word_select, &instance, MP_QSTR_word_select); + const mcu_periph_obj_t *data_periph = find_pin_function(mcu_sai_tx_data0_list, data, &instance, MP_QSTR_data); + + sai_transceiver_t config; + SAI_GetClassicI2SConfig(&config, 16, kSAI_Stereo, 1); + config.syncMode = kSAI_ModeAsync; + config.fifo.fifoPacking = kSAI_FifoPackingDisabled; + // These identifier names are required by NXP's API, even though they do + // not conform to the naming standards that Adafruit strives to adhere to. + // https://www.adafruit.com/blacklivesmatter + config.masterSlave = kSAI_Master; + port_i2s_initialize(&self->i2s, instance, &config); + + self->bit_clock = bit_clock; + self->word_select = word_select; + self->data = data; + claim_pin(bit_clock); + claim_pin(word_select); + claim_pin(data); + config_periph_pin(data_periph); + config_periph_pin(sync_periph); + config_periph_pin(bclk_periph); +} + +bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t *self) { + return port_i2s_deinited(&self->i2s); +} + +void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t *self) { + if (common_hal_audiobusio_i2sout_deinited(self)) { + return; + } + + port_i2s_deinit(&self->i2s); + + common_hal_reset_pin(self->bit_clock); + self->bit_clock = NULL; + + common_hal_reset_pin(self->word_select); + self->word_select = NULL; + + common_hal_reset_pin(self->data); + self->data = NULL; +} + +void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, + mp_obj_t sample, bool loop) { + if (common_hal_audiobusio_i2sout_get_playing(self)) { + common_hal_audiobusio_i2sout_stop(self); + } + port_i2s_play(&self->i2s, sample, loop); +} + +void common_hal_audiobusio_i2sout_pause(audiobusio_i2sout_obj_t *self) { + port_i2s_pause(&self->i2s); +} + +void common_hal_audiobusio_i2sout_resume(audiobusio_i2sout_obj_t *self) { + port_i2s_resume(&self->i2s); +} + +bool common_hal_audiobusio_i2sout_get_paused(audiobusio_i2sout_obj_t *self) { + return port_i2s_get_paused(&self->i2s); +} + +void common_hal_audiobusio_i2sout_stop(audiobusio_i2sout_obj_t *self) { + port_i2s_stop(&self->i2s); +} + +bool common_hal_audiobusio_i2sout_get_playing(audiobusio_i2sout_obj_t *self) { + return port_i2s_get_playing(&self->i2s); +} + +#endif // CIRCUITPY_AUDIOBUSIO_I2SOUT diff --git a/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h new file mode 100644 index 0000000000..c4194402be --- /dev/null +++ b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython 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. + */ + +#pragma once + +#include "supervisor/background_callback.h" +#include "common-hal/microcontroller/Pin.h" + +#include "common-hal/audiobusio/__init__.h" + +// Some boards don't implement I2SOut, so suppress any routines from here. +#if CIRCUITPY_AUDIOBUSIO_I2SOUT + +#include "sdk/drivers/sai/fsl_sai.h" + +typedef struct { + mp_obj_base_t base; + i2s_t i2s; + const mcu_pin_obj_t *bit_clock; + const mcu_pin_obj_t *word_select; + const mcu_pin_obj_t *data; +} audiobusio_i2sout_obj_t; + +#endif diff --git a/ports/mimxrt10xx/common-hal/audiobusio/PDMIn.c b/ports/mimxrt10xx/common-hal/audiobusio/PDMIn.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/mimxrt10xx/common-hal/audiobusio/PDMIn.h b/ports/mimxrt10xx/common-hal/audiobusio/PDMIn.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c new file mode 100644 index 0000000000..2be6c6bcbb --- /dev/null +++ b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c @@ -0,0 +1,422 @@ +/* + * This file is part of the MicroPython 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. + */ + +#include + +#include "py/runtime.h" + +#include "common-hal/audiobusio/__init__.h" +#include "shared-module/audiocore/__init__.h" + +#define SAI_CLOCK_SOURCE_SELECT (2U) +#define SAI_CLOCK_SOURCE_DIVIDER (63U) +#define SAI_CLOCK_SOURCE_PRE_DIVIDER (0U) + +#define SAI_CLOCK_FREQ (CLOCK_GetFreq(kCLOCK_AudioPllClk) / (SAI_CLOCK_SOURCE_DIVIDER + 1U) / \ + (SAI_CLOCK_SOURCE_PRE_DIVIDER + 1U)) + +// must match what's in clocks.c (but that's a C file so there's no way to include it) +// This is 480MMHz * (18/17) / 8 (around 63.5MHz) and there's no partiuclar +// logic to this value that I was able to determine. +#define BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT 63529411UL + +#define AUDIO_BUFFER_FRAME_COUNT (128) // in uint32_t; there are 4, giving 2048 bytes. In all they hold 10ms @ stereo 16-bit 48kHz before all buffers drain + +/* + * AUDIO PLL setting: Frequency = Fref * (DIV_SELECT + NUM / DENOM) + * = 24 * (32 + 77/100) + * = 786.48 MHz + */ +const clock_audio_pll_config_t audioPllConfig = { + .loopDivider = 32, /* PLL loop divider. Valid range for DIV_SELECT divider value: 27~54. */ + .postDivider = 1, /* Divider after the PLL, should only be 1, 2, 4, 8, 16. */ + .numerator = 77, /* 30 bit numerator of fractional loop divider. */ + .denominator = 100, /* 30 bit denominator of fractional loop divider */ +}; + +static I2S_Type *const i2s_instances[] = I2S_BASE_PTRS; +static uint8_t i2s_in_use; + +static I2S_Type *SAI_GetPeripheral(int idx) { + if (idx < 0 || idx >= (int)MP_ARRAY_SIZE(i2s_instances)) { + return NULL; + } + return i2s_instances[idx]; +} + +static int SAI_GetInstance(I2S_Type *peripheral) { + for (size_t i = 0; i < MP_ARRAY_SIZE(i2s_instances); i++) { if (peripheral == i2s_instances[i]) { + return i; + } + } + return -1; +} + +static bool i2s_clock_off(I2S_Type *peripheral) { + int index = SAI_GetInstance(peripheral); + switch (index) { + #if defined(SAI0) + case 0: + CLOCK_DisableClock(kCLOCK_Sai0); + return true; + #endif + #if defined(SAI1) + case 1: + CLOCK_DisableClock(kCLOCK_Sai1); + return true; + #endif + #if defined(SAI2) + case 2: + CLOCK_DisableClock(kCLOCK_Sai2); + return true; + #endif + #if defined(SAI3) + case 3: + CLOCK_DisableClock(kCLOCK_Sai3); + return true; + #endif + #if defined(SAI4) + case 4: + CLOCK_DisableClock(kCLOCK_Sai4); + return true; + #endif + #if defined(SAI5) + case 5: + CLOCK_DisableClock(kCLOCK_Sai5); + return true; + #endif + #if defined(SAI6) + case 6: + CLOCK_DisableClock(kCLOCK_Sai6); + return true; + #endif + #if defined(SAI7) + case 7: + CLOCK_DisableClock(kCLOCK_Sai7); + return true; + #endif + } + return false; +} + +static bool i2s_clocking(I2S_Type *peripheral) { + int index = SAI_GetInstance(peripheral); + switch (index) { + #if defined(SAI0) + case 0: + CLOCK_SetDiv(kCLOCK_Sai0PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai0Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai0Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai0); + return true; + #endif + #if defined(SAI1) + case 1: + CLOCK_SetDiv(kCLOCK_Sai1PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai1Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai1Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai1); + return true; + #endif + #if defined(SAI2) + case 2: + CLOCK_SetDiv(kCLOCK_Sai2PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai2Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai2Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai2); + return true; + #endif + #if defined(SAI3) + case 3: + CLOCK_SetDiv(kCLOCK_Sai3PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai3Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai3Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai3); + return true; + #endif + #if defined(SAI4) + case 4: + CLOCK_SetDiv(kCLOCK_Sai4PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai4Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai4Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai4); + return true; + #endif + #if defined(SAI5) + case 5: + CLOCK_SetDiv(kCLOCK_Sai5PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai5Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai5Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai5); + return true; + #endif + #if defined(SAI6) + case 6: + CLOCK_SetDiv(kCLOCK_Sai6PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai6Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai6Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai6); + return true; + #endif + #if defined(SAI7) + case 7: + CLOCK_SetDiv(kCLOCK_Sai7PreDiv, SAI_CLOCK_SOURCE_PRE_DIVIDER); + CLOCK_SetDiv(kCLOCK_Sai7Div, SAI_CLOCK_SOURCE_DIVIDER); + CLOCK_SetMux(kCLOCK_Sai7Mux, SAI_CLOCK_SOURCE_SELECT); + CLOCK_EnableClock(kCLOCK_Sai7); + return true; + #endif + } + return false; +} + + +static bool i2s_queue_available(i2s_t *self) { + return !self->handle.saiQueue[self->handle.queueUser].data; +} + +static void i2s_fill_buffer(i2s_t *self) { + if (!self->peripheral) { + return; + } + while (i2s_queue_available(self)) { + uint32_t *buffer = self->buffers[self->buffer_idx]; + uint32_t *ptr = buffer, *end = buffer + AUDIO_BUFFER_FRAME_COUNT; + self->buffer_idx = (self->buffer_idx + 1) % SAI_XFER_QUEUE_SIZE; + + while (self->playing && !self->paused && ptr < end) { + if (self->sample_data == self->sample_end) { + if (self->stopping) { + // non-looping sample, previously returned GET_BUFFER_DONE + self->playing = false; + break; + } + uint32_t sample_buffer_length; + audioio_get_buffer_result_t get_buffer_result = + audiosample_get_buffer(self->sample, false, 0, + &self->sample_data, &sample_buffer_length); + self->sample_end = self->sample_data + sample_buffer_length; + if (get_buffer_result == GET_BUFFER_DONE) { + if (self->loop) { + audiosample_reset_buffer(self->sample, false, 0); + } else { + self->stopping = true; + } + } + if (get_buffer_result == GET_BUFFER_ERROR || sample_buffer_length == 0) { + self->stopping = true; + } + } + size_t input_bytecount = self->sample_end - self->sample_data; + size_t bytes_per_input_frame = self->channel_count * self->bytes_per_sample; + size_t framecount = MIN((size_t)(end - ptr), input_bytecount / bytes_per_input_frame); + +#define SAMPLE_TYPE(is_signed, channel_count, bytes_per_sample) ((is_signed) | ((channel_count) << 1) | ((bytes_per_sample) << 3)) + + switch (SAMPLE_TYPE(self->samples_signed, self->channel_count, self->bytes_per_sample)) { + + case SAMPLE_TYPE(true, 2, 2): + memcpy(ptr, self->sample_data, 4 * framecount); + break; + + case SAMPLE_TYPE(false, 2, 2): + audiosample_convert_u16s_s16s((int16_t *)ptr, (uint16_t *)(void *)self->sample_data, framecount); + break; + + case SAMPLE_TYPE(true, 1, 2): + audiosample_convert_s16m_s16s((int16_t *)ptr, (int16_t *)(void *)self->sample_data, framecount); + break; + + case SAMPLE_TYPE(false, 1, 2): + audiosample_convert_u16m_s16s((int16_t *)ptr, (uint16_t *)(void *)self->sample_data, framecount); + break; + + case SAMPLE_TYPE(true, 2, 1): + audiosample_convert_s8s_s16s((int16_t *)ptr, (int8_t *)(void *)self->sample_data, framecount); + memcpy(ptr, self->sample_data, 4 * framecount); + break; + + case SAMPLE_TYPE(false, 2, 1): + audiosample_convert_u8s_s16s((int16_t *)ptr, (uint8_t *)(void *)self->sample_data, framecount); + break; + + case SAMPLE_TYPE(true, 1, 1): + audiosample_convert_s8m_s16s((int16_t *)ptr, (int8_t *)(void *)self->sample_data, framecount); + break; + + case SAMPLE_TYPE(false, 1, 1): + audiosample_convert_u8m_s16s((int16_t *)ptr, (uint8_t *)(void *)self->sample_data, framecount); + break; + } + self->sample_data += bytes_per_input_frame * framecount; // in bytes + ptr += framecount; // in frames + } + // Fill any remaining portion of the buffer with 'no sound' + memset(ptr, 0, (end - ptr) * sizeof(uint32_t)); + sai_transfer_t xfer = { + .data = (uint8_t *)buffer, + .dataSize = AUDIO_BUFFER_FRAME_COUNT * sizeof(uint32_t), + }; + int r = SAI_TransferSendNonBlocking(self->peripheral, &self->handle, &xfer); + if (r != kStatus_Success) { + mp_printf(&mp_plat_print, "transfer returned %d\n", (int)r); + } + } +} + +static void i2s_callback_fun(void *self_in) { + i2s_t *self = self_in; + i2s_fill_buffer(self); +} + +static void i2s_transfer_callback(I2S_Type *base, sai_handle_t *handle, status_t status, void *self_in) { + i2s_t *self = self_in; + if (status == kStatus_SAI_TxIdle) { + // a block has been finished + background_callback_add(&self->callback, i2s_callback_fun, self_in); + } +} + + +void port_i2s_initialize(i2s_t *self, int instance, sai_transceiver_t *config) { + if (!i2s_in_use) { + // need to set audio pll up! + + /* DeInit Audio PLL. */ + CLOCK_DeinitAudioPll(); + /* Bypass Audio PLL. */ + CLOCK_SetPllBypass(CCM_ANALOG, kCLOCK_PllAudio, 1); + /* Set divider for Audio PLL. */ + CCM_ANALOG->MISC2 &= ~CCM_ANALOG_MISC2_AUDIO_DIV_LSB_MASK; + CCM_ANALOG->MISC2 &= ~CCM_ANALOG_MISC2_AUDIO_DIV_MSB_MASK; + /* Enable Audio PLL output. */ + CCM_ANALOG->PLL_AUDIO |= CCM_ANALOG_PLL_AUDIO_ENABLE_MASK; + + CLOCK_InitAudioPll(&audioPllConfig); + } + + I2S_Type *peripheral = SAI_GetPeripheral(instance); + if (!peripheral) { + mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_I2SOut); + } + if (i2s_in_use & (1 << instance)) { + mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_I2SOut); + } + if (!i2s_clocking(peripheral)) { + mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_I2SOut); + } + for (size_t i = 0; i < MP_ARRAY_SIZE(self->buffers); i++) { + self->buffers[i] = m_malloc(AUDIO_BUFFER_FRAME_COUNT * sizeof(uint32_t), false); + } + self->peripheral = peripheral; + SAI_Init(self->peripheral); + SAI_TransferTxCreateHandle(peripheral, &self->handle, i2s_transfer_callback, (void *)self); + SAI_TransferTxSetConfig(peripheral, &self->handle, config); + self->sample_rate = 0; + i2s_in_use |= (1 << instance); +} + +bool port_i2s_deinited(i2s_t *self) { + return !self->peripheral; +} + +void port_i2s_deinit(i2s_t *self) { + if (port_i2s_deinited(self)) { + return; + } + SAI_TransferAbortSend(self->peripheral, &self->handle); + i2s_clock_off(self->peripheral); + i2s_in_use &= ~(1 << SAI_GetInstance(self->peripheral)); + if (!i2s_in_use) { + CCM_ANALOG->PLL_AUDIO = CCM_ANALOG_PLL_AUDIO_BYPASS_MASK | CCM_ANALOG_PLL_AUDIO_POWERDOWN_MASK | CCM_ANALOG_PLL_AUDIO_BYPASS_CLK_SRC(kCLOCK_PllClkSrc24M); + } + self->peripheral = NULL; + for (size_t i = 0; i < MP_ARRAY_SIZE(self->buffers); i++) { + self->buffers[i] = NULL; + } +} + +void port_i2s_play(i2s_t *self, mp_obj_t sample, bool loop) { + self->sample = sample; + self->loop = loop; + self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8; + self->channel_count = audiosample_channel_count(sample); + uint32_t sample_rate = audiosample_sample_rate(sample); + if (sample_rate != self->sample_rate) { + SAI_TxSetBitClockRate(self->peripheral, SAI_CLOCK_FREQ, sample_rate, 16, 2); + self->sample_rate = sample_rate; + } + bool single_buffer; + bool samples_signed; + uint32_t max_buffer_length; + uint8_t spacing; + audiosample_get_buffer_structure(sample, false, &single_buffer, &samples_signed, + &max_buffer_length, &spacing); + self->samples_signed = samples_signed; + self->playing = true; + self->paused = false; + self->stopping = false; + self->sample_data = self->sample_end = NULL; + + audiosample_reset_buffer(self->sample, false, 0); + +// TODO + #if 0 + uint32_t sample_rate = audiosample_sample_rate(sample); + if (sample_rate != self->i2s_config.sample_rate) { + CHECK_ESP_RESULT(i2s_set_sample_rates(self->instance, audiosample_sample_rate(sample))); + self->i2s_config.sample_rate = sample_rate; + } + #endif + background_callback_add(&self->callback, i2s_callback_fun, self); +} + +bool port_i2s_get_playing(i2s_t *self) { + return self->playing; +} + +bool port_i2s_get_paused(i2s_t *self) { + return self->paused; +} + +void port_i2s_stop(i2s_t *self) { + self->sample = NULL; + self->paused = false; + self->playing = false; + self->stopping = false; +} + +void port_i2s_pause(i2s_t *self) { + self->paused = true; +} + +void port_i2s_resume(i2s_t *self) { + self->paused = false; +} + +void i2s_reset() { +// this port relies on object finalizers for reset +} diff --git a/ports/mimxrt10xx/common-hal/audiobusio/__init__.h b/ports/mimxrt10xx/common-hal/audiobusio/__init__.h new file mode 100644 index 0000000000..f0663e2897 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/audiobusio/__init__.h @@ -0,0 +1,59 @@ +/* + * This file is part of the MicroPython 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. + */ + +#pragma once + +#include "sdk/drivers/sai/fsl_sai.h" +#include "py/obj.h" + +#include "supervisor/background_callback.h" + + +typedef struct { + I2S_Type *peripheral; + sai_handle_t handle; + mp_obj_t sample; + uint32_t *buffers[SAI_XFER_QUEUE_SIZE]; + uint8_t *sample_data, *sample_end; + background_callback_t callback; + bool playing, paused, loop, stopping; + bool samples_signed; + uint8_t channel_count, bytes_per_sample; + uint8_t buffer_idx; + uint32_t sample_rate; +} i2s_t; + + +void i2s_reset(void); +void port_i2s_initialize(i2s_t *self, int instance, sai_transceiver_t *config); +void port_i2s_deinit(i2s_t *self); +bool port_i2s_deinited(i2s_t *self); +void port_i2s_play(i2s_t *self, mp_obj_t sample, bool loop); +void port_i2s_stop(i2s_t *self); +bool port_i2s_get_playing(i2s_t *self); +bool port_i2s_get_paused(i2s_t *self); +void port_i2s_pause(i2s_t *self); +void port_i2s_resume(i2s_t *self); diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index 3c8c7f2b27..a43ef2b7ab 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -25,8 +25,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "shared-bindings/microcontroller/__init__.h" +#include "py/runtime.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/microcontroller/__init__.h" STATIC bool claimed_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT]; STATIC bool never_reset_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT]; @@ -116,3 +117,19 @@ void claim_pin(const mcu_pin_obj_t *pin) { void common_hal_mcu_pin_reset_number(uint8_t pin_no) { common_hal_reset_pin((mcu_pin_obj_t *)(mcu_pin_globals.map.table[pin_no].value)); } + +const mcu_periph_obj_t *find_pin_function_sz(const mcu_periph_obj_t *list, size_t sz, const mcu_pin_obj_t *pin, int *instance, uint16_t name) { + if (!pin) { + return NULL; + } + for (size_t i = 0; i < sz; i++) { + if (*instance != -1 && *instance != list[i].bank_idx) { + continue; + } + if (pin == list[i].pin) { + *instance = list[i].bank_idx; + return &list[i]; + } + } + mp_raise_ValueError_varg(translate("Invalid %q pin"), name); +} diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h index 1bfbe41a18..4c66dd4ea5 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h @@ -25,11 +25,9 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H -#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H - -#include +#pragma once +#include "periph.h" #include "pins.h" void reset_all_pins(void); @@ -45,4 +43,8 @@ extern const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[]; // the port-default reset behavior. extern bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin); -#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H +// Find the entry in the peripheral list for this pin. If instance is (-1), any instance (bank_idx) may be used. Otherwise, the bank_idx must match the instance. +// If instance was -1, and the function succeeds, then instance is updated with the new bank_idx. +// If the pin is NULL then NULL is always returned. But if it was not NULL, and no match was found, then a ValueError is raised. +const mcu_periph_obj_t *find_pin_function_sz(const mcu_periph_obj_t *list, size_t sz, const mcu_pin_obj_t *pin, int *instance, uint16_t name); +#define find_pin_function(list, pin, instance, name) (find_pin_function_sz((list), MP_ARRAY_SIZE((list)), (pin), (instance), (name))) diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 7eaac85b34..787c3c7929 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -11,7 +11,9 @@ CIRCUITPY_TUSB_MEM_ALIGN = 32 INTERNAL_FLASH_FILESYSTEM = 1 -CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_AUDIOBUSIO = 1 +CIRCUITPY_AUDIOBUSIO_PDMIN = 0 +CIRCUITPY_AUDIOCORE = 1 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_COUNTIO = 0 diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c index 0c2b5893bc..fbbf65c8a5 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c @@ -166,3 +166,28 @@ const mcu_pwm_obj_t mcu_pwm_list[20] = { PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmX, IOMUXC_GPIO_AD_09_FLEXPWM1_PWM3_X, &pin_GPIO_AD_09), }; + +const mcu_periph_obj_t mcu_sai_rx_bclk_list[] = { + PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_08), + PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_00), +}; +const mcu_periph_obj_t mcu_sai_rx_data0_list[] = { + PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_03), + PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_03), +}; +const mcu_periph_obj_t mcu_sai_rx_sync_list[] = { + PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_02), + PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_04), +}; +const mcu_periph_obj_t mcu_sai_tx_bclk_list[] = { + PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_06), + PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_01), +}; +const mcu_periph_obj_t mcu_sai_tx_data0_list[] = { + PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_04), + PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_02), +}; +const mcu_periph_obj_t mcu_sai_tx_sync_list[] = { + PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_07), + PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_00), +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h index b3bddcb76b..109717528f 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h @@ -47,4 +47,11 @@ extern const mcu_periph_obj_t mcu_uart_cts_list[4]; extern const mcu_pwm_obj_t mcu_pwm_list[20]; +extern const mcu_periph_obj_t mcu_sai_rx_bclk_list[2]; +extern const mcu_periph_obj_t mcu_sai_rx_data0_list[2]; +extern const mcu_periph_obj_t mcu_sai_rx_sync_list[2]; +extern const mcu_periph_obj_t mcu_sai_tx_bclk_list[2]; +extern const mcu_periph_obj_t mcu_sai_tx_data0_list[2]; +extern const mcu_periph_obj_t mcu_sai_tx_sync_list[2]; + #endif // MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1011_PERIPHERALS_MIMXRT1011_PERIPH_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c index ffcadbb696..b80fcf5065 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c @@ -256,3 +256,58 @@ const mcu_pwm_obj_t mcu_pwm_list[39] = { PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmX, IOMUXC_GPIO_EMC_12_FLEXPWM2_PWMX02, &pin_GPIO_EMC_12), PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmX, IOMUXC_GPIO_EMC_13_FLEXPWM2_PWMX03, &pin_GPIO_EMC_13), }; + +const mcu_periph_obj_t mcu_sai_rx_bclk_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_14), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_19), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_06), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_09), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_SD_B0_02), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_29), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_09), +}; +const mcu_periph_obj_t mcu_sai_rx_data0_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_13), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_21), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_05), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_08), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_SD_B0_03), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_30), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_11), +}; +const mcu_periph_obj_t mcu_sai_rx_sync_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_15), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_28), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_04), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_07), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_SD_B0_01), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_30), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_10), +}; +const mcu_periph_obj_t mcu_sai_tx_bclk_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_11), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_26), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_01), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_04), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_SD_B0_04), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_33), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B0_06), +}; +const mcu_periph_obj_t mcu_sai_tx_data0_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_12), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_25), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_03), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_06), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_SD_B0_04), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_32), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_08), +}; +const mcu_periph_obj_t mcu_sai_tx_sync_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_10), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_27), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_02), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_05), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_SD_B0_06), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_34), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_07), +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h index 9074987cd8..31ac10e651 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h @@ -25,8 +25,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H -#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H +#pragma once extern LPI2C_Type *const mcu_i2c_banks[4]; @@ -48,4 +47,9 @@ extern const mcu_periph_obj_t mcu_uart_cts_list[10]; extern const mcu_pwm_obj_t mcu_pwm_list[39]; -#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIP_H +extern const mcu_periph_obj_t mcu_sai_rx_bclk_list[7]; +extern const mcu_periph_obj_t mcu_sai_rx_data0_list[7]; +extern const mcu_periph_obj_t mcu_sai_rx_sync_list[7]; +extern const mcu_periph_obj_t mcu_sai_tx_bclk_list[7]; +extern const mcu_periph_obj_t mcu_sai_tx_data0_list[7]; +extern const mcu_periph_obj_t mcu_sai_tx_sync_list[7]; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c index b6efe5e6a9..8c038bdb71 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c @@ -306,3 +306,59 @@ const mcu_pwm_obj_t mcu_pwm_list[67] = { PWM_PIN(PWM4, kPWM_Module_3, kPWM_PwmB, IOMUXC_GPIO_EMC_18_FLEXPWM4_PWMB03, &pin_GPIO_EMC_18), }; + +const mcu_periph_obj_t mcu_sai_rx_bclk_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_11), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B0_15), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_05), + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_10), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_B0_06), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_35), + PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_00), +}; + +const mcu_periph_obj_t mcu_sai_rx_data0_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B1_00), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_12), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_06), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_B0_08), + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_08), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_33), + PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_00), +}; +const mcu_periph_obj_t mcu_sai_rx_sync_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_11), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B0_15), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_05), + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_09), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_B0_06), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_34), + PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_05), +}; +const mcu_periph_obj_t mcu_sai_tx_bclk_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_08), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B1_02), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_14), + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_AD_B0_05), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_06), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_38), + PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_03), +}; +const mcu_periph_obj_t mcu_sai_tx_data0_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_13), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B1_01), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_07), + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_04), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_B0_09), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_36), + PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_01), +}; +const mcu_periph_obj_t mcu_sai_tx_sync_list[] = { + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_15), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B1_03), + PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_09), + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_AD_B0_04), + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_05), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_39), + PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_02), +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h index 9a06a491f9..ab8eb22678 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h @@ -47,4 +47,11 @@ extern const mcu_periph_obj_t mcu_uart_cts_list[9]; extern const mcu_pwm_obj_t mcu_pwm_list[67]; +extern const mcu_periph_obj_t mcu_sai_rx_bclk_list[7]; +extern const mcu_periph_obj_t mcu_sai_rx_data0_list[7]; +extern const mcu_periph_obj_t mcu_sai_rx_sync_list[7]; +extern const mcu_periph_obj_t mcu_sai_tx_bclk_list[7]; +extern const mcu_periph_obj_t mcu_sai_tx_data0_list[7]; +extern const mcu_periph_obj_t mcu_sai_tx_sync_list[7]; + #endif // MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1062_PERIPHERALS_MIMXRT1011_PERIPH_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h index 818b203da4..8184d5b135 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h @@ -31,7 +31,7 @@ #include "pins.h" typedef struct { - uint8_t bank_idx : 4; + uint8_t bank_idx : 4; // e.g. the peripheral number uint8_t mux_mode : 4; uint32_t input_reg; uint8_t input_idx; diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 55bf72352d..feb8566aad 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -36,6 +36,10 @@ #include "fsl_device_registers.h" +#if CIRCUITPY_AUDIOBUSIO +#include "common-hal/audiobusio/__init__.h" +#endif + #include "common-hal/microcontroller/Pin.h" #include "common-hal/pwmio/PWMOut.h" #include "common-hal/rtc/RTC.h" @@ -414,8 +418,7 @@ void reset_port(void) { audioout_reset(); #endif #if CIRCUITPY_AUDIOBUSIO - i2sout_reset(); - // pdmin_reset(); + i2s_reset(); #endif #if CIRCUITPY_TOUCHIO && CIRCUITPY_TOUCHIO_USE_NATIVE From 04bb0513df068ae3091bcc9c3b83a6ff9598b89a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 21 Mar 2023 11:58:51 -0500 Subject: [PATCH 083/225] enable audiomixer --- ports/mimxrt10xx/mpconfigport.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 787c3c7929..8597fc068b 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -15,6 +15,7 @@ CIRCUITPY_AUDIOBUSIO = 1 CIRCUITPY_AUDIOBUSIO_PDMIN = 0 CIRCUITPY_AUDIOCORE = 1 CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 From f40504b7bc16b538fdb2a34e3dc6b7c5e9e3b3f4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 21 Mar 2023 12:17:17 -0500 Subject: [PATCH 084/225] enable MP3 --- ports/mimxrt10xx/mpconfigport.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 8597fc068b..a952460259 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -16,6 +16,7 @@ CIRCUITPY_AUDIOBUSIO_PDMIN = 0 CIRCUITPY_AUDIOCORE = 1 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOMIXER = 1 +CIRCUITPY_AUDIOMP3 = 1 CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 From 57188885d3dc895f691956cfd2dd6e76eb889b94 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 22 Mar 2023 14:08:03 -0400 Subject: [PATCH 085/225] Swap ESP32 RX and TX pins on Metro M7 1011 --- ports/mimxrt10xx/boards/metro_m7_1011/pins.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c index 886909e1dd..675773798c 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c @@ -38,8 +38,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_GPIO0), MP_ROM_PTR(&pin_GPIO_SD_05) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_GPIO_AD_11) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_GPIO_AD_07) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_GPIO_09) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_GPIO_10) }, + // These RX and TX are from the point of view of the i.MX microcontroller. + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_GPIO_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_GPIO_10) }, // SPI { MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO_AD_06) }, From a280c010c2e5f99868ab43ef00042d7d32922a74 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 22 Mar 2023 11:14:38 -0700 Subject: [PATCH 086/225] Fix tricolor epd and add EPD feather --- .../adafruit_feather_rp2040_epd/board.c | 29 +++++++++++ .../mpconfigboard.h | 15 ++++++ .../mpconfigboard.mk | 9 ++++ .../pico-sdk-configboard.h | 4 ++ .../boards/adafruit_feather_rp2040_epd/pins.c | 51 +++++++++++++++++++ shared-module/displayio/EPaperDisplay.c | 6 ++- 6 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_epd/board.c create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pins.c diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/board.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/board.c new file mode 100644 index 0000000000..331653173e --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/board.c @@ -0,0 +1,29 @@ +/* + * 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" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.h new file mode 100644 index 0000000000..356f0f5b54 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.h @@ -0,0 +1,15 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040 EPD" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO20) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO8) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.mk new file mode 100644 index 0000000000..3b457b93cb --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x812C +USB_PRODUCT = "Feather RP2040 EPD" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pico-sdk-configboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pins.c new file mode 100644 index 0000000000..22ae43adad --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_epd/pins.c @@ -0,0 +1,51 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { 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_D24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_EPD_BUSY), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_EPD_RESET), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_EPD_DC), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_EPD_CS), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_EPD_SCK), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_EPD_MOSI), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 289fc47a68..74f828aea8 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -60,6 +60,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool chip_select, bool grayscale, bool acep, bool two_byte_sequence_length) { uint16_t color_depth = 1; + bool core_grayscale = true; if (highlight_color != 0x000000) { self->core.colorspace.tricolor = true; self->core.colorspace.tricolor_hue = displayio_colorconverter_compute_hue(highlight_color); @@ -70,9 +71,10 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t color_depth = 4; // bits. 7 colors + clean self->acep = acep; grayscale = false; + core_grayscale = false; } - displayio_display_core_construct(&self->core, bus, width, height, ram_width, ram_height, colstart, rowstart, rotation, color_depth, grayscale, true, 1, true, true); + displayio_display_core_construct(&self->core, bus, width, height, ram_width, ram_height, colstart, rowstart, rotation, color_depth, core_grayscale, true, 1, true, true); self->set_column_window_command = set_column_window_command; self->set_row_window_command = set_row_window_command; @@ -340,7 +342,7 @@ STATIC bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t * memset(mask, 0, mask_length * sizeof(mask[0])); memset(buffer, 0, buffer_size * sizeof(buffer[0])); - if (self->grayscale) { + if (!self->acep) { self->core.colorspace.grayscale = true; self->core.colorspace.grayscale_bit = 7; } From 16c8dad0784c13ad039508bba8397da5c61f377f Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 22 Mar 2023 11:54:43 -0700 Subject: [PATCH 087/225] Fix Pallete cache for grayscale and tricolor epd --- shared-module/displayio/Palette.c | 14 +++++++++++--- shared-module/displayio/Palette.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c index a2ddc285fd..c61b9ebc82 100644 --- a/shared-module/displayio/Palette.c +++ b/shared-module/displayio/Palette.c @@ -81,7 +81,13 @@ void displayio_palette_get_color(displayio_palette_t *self, const _displayio_col } // Cache results when not dithering. - if (!self->dither && self->colors[palette_index].cached_colorspace == colorspace) { + _displayio_color_t *color = &self->colors[palette_index]; + // Check the grayscale settings because EPaperDisplay will change them on + // the same object. + if (!self->dither && + color->cached_colorspace == colorspace && + color->cached_colorspace_grayscale_bit == colorspace->grayscale_bit && + color->cached_colorspace_grayscale == colorspace->grayscale) { output_color->pixel = self->colors[palette_index].cached_color; return; } @@ -90,8 +96,10 @@ void displayio_palette_get_color(displayio_palette_t *self, const _displayio_col rgb888_pixel.pixel = self->colors[palette_index].rgb888; displayio_convert_color(colorspace, self->dither, &rgb888_pixel, output_color); if (!self->dither) { - self->colors[palette_index].cached_colorspace = colorspace; - self->colors[palette_index].cached_color = output_color->pixel; + color->cached_colorspace = colorspace; + color->cached_color = output_color->pixel; + color->cached_colorspace_grayscale = colorspace->grayscale; + color->cached_colorspace_grayscale_bit = colorspace->grayscale_bit; } } diff --git a/shared-module/displayio/Palette.h b/shared-module/displayio/Palette.h index e9b449c4e7..050423d052 100644 --- a/shared-module/displayio/Palette.h +++ b/shared-module/displayio/Palette.h @@ -51,6 +51,8 @@ typedef struct { uint32_t rgb888; const _displayio_colorspace_t *cached_colorspace; uint32_t cached_color; + uint8_t cached_colorspace_grayscale_bit; + bool cached_colorspace_grayscale; bool transparent; // This may have additional bits added later for blending. } _displayio_color_t; From e05f0ba3b2eba583a88a18bf4de95ebee3125a16 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 22 Mar 2023 14:32:00 -0500 Subject: [PATCH 088/225] Revert "Correctly raise OS error in socketpool_socket_recv_into()" This reverts commit 7e6e824d5655026906b6515070aeb604d2ef3426. Fixes #7770 The change in #7623 needs to be revered; the raise-site added in #7632 is the correct one and the one in socketpool needs to be reverted. This is not affecting 8.0.x because #7623 was not back-ported to there before we realized it was not a full fix. Both #7770 and #7606 should be re-tested. I didn't test. --- ports/raspberrypi/common-hal/socketpool/Socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/common-hal/socketpool/Socket.c b/ports/raspberrypi/common-hal/socketpool/Socket.c index e2b82264ba..fe12f461fb 100644 --- a/ports/raspberrypi/common-hal/socketpool/Socket.c +++ b/ports/raspberrypi/common-hal/socketpool/Socket.c @@ -1109,7 +1109,7 @@ int socketpool_socket_recv_into(socketpool_socket_obj_t *socket, break; } if (ret == (unsigned)-1) { - mp_raise_OSError(_errno); + return -_errno; } return ret; } From 127a7092bf9927eaff84274983e72412a2faa7b5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 22 Mar 2023 16:09:56 -0500 Subject: [PATCH 089/225] use `values` in this error message ... matching the documentation of struct.pack, which has `def pack(fmt: str, *values: Any)` as the signature. --- shared-module/struct/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index b595504969..11e122915c 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -167,7 +167,7 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size } fmt++; } - (void)mp_arg_validate_length(n_args, i, MP_QSTR_args); + (void)mp_arg_validate_length(n_args, i, MP_QSTR_values); } mp_obj_tuple_t *shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p, bool exact_size) { From 0b3099a9ff935bc6d59c3db41316c262be254712 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Wed, 22 Mar 2023 18:44:45 -0400 Subject: [PATCH 090/225] adding bitmaptools circle --- shared-bindings/bitmaptools/__init__.c | 49 +++++++++++++++++++++ shared-bindings/bitmaptools/__init__.h | 5 +++ shared-module/bitmaptools/__init__.c | 61 +++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 1195e1811d..19ea952999 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -868,7 +868,55 @@ STATIC mp_obj_t bitmaptools_dither(size_t n_args, const mp_obj_t *pos_args, mp_m return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_dither_obj, 0, bitmaptools_dither); +// requires all 5 arguments +//| def draw_circle( +//| dest_bitmap: displayio.Bitmap, x0: int, y0: int, radius: int, value: int +//| ) -> None: +//| """Draws a circle into a bitmap specified using a center (x0,y0) and radius r. +//| +//| :param bitmap dest_bitmap: Destination bitmap that will be written into +//| :param int x0: x-pixel position of the circle's center +//| :param int y0: y-pixel position of the circle's center +//| :param int radius: circle's radius +//| :param int value: Bitmap palette index that will be written into the +//| circle in the destination bitmap""" +//| ... +//| +STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum {ARG_dest_bitmap, ARG_x0, ARG_y0, ARG_radius, ARG_value}; + + static const mp_arg_t allowed_args[] = { + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_x0, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_y0, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_radius, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + displayio_bitmap_t *destination = MP_OBJ_TO_PTR(args[ARG_dest_bitmap].u_obj); // the destination bitmap + + uint32_t value, color_depth; + value = args[ARG_value].u_int; + color_depth = (1 << destination->bits_per_value); + if (color_depth <= value) { + mp_raise_ValueError(translate("out of range of target")); + } + + + int16_t x0 = args[ARG_x0].u_int; + int16_t y0 = args[ARG_y0].u_int; + int16_t radius = args[ARG_radius].u_int; + + + common_hal_bitmaptools_draw_circle(destination, x0, y0, radius, value); + + return mp_const_none; +} + +MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_circle_obj, 0, bitmaptools_obj_draw_circle); STATIC const mp_rom_map_elem_t bitmaptools_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitmaptools) }, @@ -880,6 +928,7 @@ STATIC const mp_rom_map_elem_t bitmaptools_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_boundary_fill), MP_ROM_PTR(&bitmaptools_boundary_fill_obj) }, { MP_ROM_QSTR(MP_QSTR_draw_line), MP_ROM_PTR(&bitmaptools_draw_line_obj) }, { MP_ROM_QSTR(MP_QSTR_draw_polygon), MP_ROM_PTR(&bitmaptools_draw_polygon_obj) }, + { MP_ROM_QSTR(MP_QSTR_draw_circle), MP_ROM_PTR(&bitmaptools_draw_circle_obj) }, { MP_ROM_QSTR(MP_QSTR_dither), MP_ROM_PTR(&bitmaptools_dither_obj) }, { MP_ROM_QSTR(MP_QSTR_DitherAlgorithm), MP_ROM_PTR(&bitmaptools_dither_algorithm_type) }, }; diff --git a/shared-bindings/bitmaptools/__init__.h b/shared-bindings/bitmaptools/__init__.h index db72410cf6..3c356e761e 100644 --- a/shared-bindings/bitmaptools/__init__.h +++ b/shared-bindings/bitmaptools/__init__.h @@ -64,6 +64,11 @@ void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination, int16_t x1, int16_t y1, uint32_t value); +void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination, + int16_t x0, int16_t y0, + int16_t radius, + uint32_t value); + void common_hal_bitmaptools_draw_polygon(displayio_bitmap_t *destination, void *xs, void *ys, size_t points_len, int point_size, uint32_t value, bool close); void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, mp_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes, bool reverse_rows); void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index); diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 8068bbe8b6..699516f37c 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2021 Kevin Matocha + * Copyright (c) 2021 Kevin Matocha, Jose David Montoya * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,6 +40,9 @@ #include #include +#define BITMAP_DEBUG(...) (void)0 +// #define BITMAP_DEBUG(...) mp_printf(&mp_plat_print, __VA_ARGS__) + void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16_t oy, int16_t dest_clip0_x, int16_t dest_clip0_y, int16_t dest_clip1_x, int16_t dest_clip1_y, @@ -918,3 +921,59 @@ void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitma } } } + +STATIC void draw_circle(displayio_bitmap_t *destination, + int16_t x0, int16_t y0, + int16_t radius, uint32_t value) { + + int16_t d, y; + + mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x0); + mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y0); + + BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x0, y0, radius); + + y = radius; + d = 3 - 2 * radius; + + // Bresenham's circle algorithm + for (int x = 0; x <= y; x++) { + displayio_bitmap_write_pixel(destination, x + x0, y + y0, value); + displayio_bitmap_write_pixel(destination, -x + x0, -y + y0, value); + displayio_bitmap_write_pixel(destination, -x + x0, y + y0, value); + displayio_bitmap_write_pixel(destination, x + x0, -y + y0, value); + displayio_bitmap_write_pixel(destination, y + x0, x + y0, value); + displayio_bitmap_write_pixel(destination, -y + x0, x + y0, value); + displayio_bitmap_write_pixel(destination, -y + x0, -x + y0, value); + displayio_bitmap_write_pixel(destination, y + x0, -x + y0, value); + if (d <= 0) { + d = d + (4 * x) + 6; + } else { + d = d + 4 * (x - y) + 10; + y = y - 1; + } + } +} + +void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination, + int16_t x0, int16_t y0, + int16_t radius, + uint32_t value) { + + + // update the dirty area + int16_t xbb0, xbb1, ybb0, ybb1; + + xbb0 = x0 - radius; + xbb1 = x0 + radius; + ybb0 = y0 - radius; + ybb1 = y0 + radius; + + displayio_area_t area = { xbb0, ybb0, xbb1, ybb1, NULL }; + displayio_area_t bitmap_area = { 0, 0, destination->width, destination->height, NULL }; + displayio_area_compute_overlap(&area, &bitmap_area, &area); + + displayio_bitmap_set_dirty_area(destination, &area); + + draw_circle(destination, x0, y0, radius, value); +} \ No newline at end of file From 29613c73e158cfd21732f076f12d7f0223d26b97 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Wed, 22 Mar 2023 19:05:18 -0400 Subject: [PATCH 091/225] pre-commit --- shared-bindings/bitmaptools/__init__.c | 2 +- shared-module/bitmaptools/__init__.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 19ea952999..e377d40031 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -928,7 +928,7 @@ STATIC const mp_rom_map_elem_t bitmaptools_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_boundary_fill), MP_ROM_PTR(&bitmaptools_boundary_fill_obj) }, { MP_ROM_QSTR(MP_QSTR_draw_line), MP_ROM_PTR(&bitmaptools_draw_line_obj) }, { MP_ROM_QSTR(MP_QSTR_draw_polygon), MP_ROM_PTR(&bitmaptools_draw_polygon_obj) }, - { MP_ROM_QSTR(MP_QSTR_draw_circle), MP_ROM_PTR(&bitmaptools_draw_circle_obj) }, + { MP_ROM_QSTR(MP_QSTR_draw_circle), MP_ROM_PTR(&bitmaptools_draw_circle_obj) }, { MP_ROM_QSTR(MP_QSTR_dither), MP_ROM_PTR(&bitmaptools_dither_obj) }, { MP_ROM_QSTR(MP_QSTR_DitherAlgorithm), MP_ROM_PTR(&bitmaptools_dither_algorithm_type) }, }; diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 699516f37c..778d0629a7 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -976,4 +976,4 @@ void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination, displayio_bitmap_set_dirty_area(destination, &area); draw_circle(destination, x0, y0, radius, value); -} \ No newline at end of file +} From 8b9f5e7f531d8e7dbcff41723bc7c1fb3c1f1614 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 11 Mar 2023 09:44:35 -0600 Subject: [PATCH 092/225] Remove del obj and add deinited --- shared-bindings/gifio/OnDiskGif.c | 36 +++++++++++++++++++++++++++++++ shared-bindings/gifio/OnDiskGif.h | 2 ++ shared-module/gifio/OnDiskGif.c | 8 ++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index 7fb3fcf2bd..3eb56a1c32 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -30,6 +30,8 @@ #include "py/runtime.h" #include "py/objproperty.h" +#include "shared/runtime/context_manager_helpers.h" +#include "shared-bindings/util.h" #include "supervisor/shared/translate/translate.h" #include "shared-bindings/gifio/OnDiskGif.h" @@ -125,11 +127,34 @@ STATIC mp_obj_t gifio_ondiskgif_make_new(const mp_obj_type_t *type, size_t n_arg return MP_OBJ_FROM_PTR(self); } +STATIC void check_for_deinit(gifio_ondiskgif_t *self) { + if (common_hal_gifio_ondiskgif_deinited(self)) { + raise_deinited_error(); + } +} + +//| def __enter__(self) -> OnDiskGif: +//| """No-op used by Context Managers.""" +//| ... +// Provided by context manager helper. + +//| def __exit__(self) -> None: +//| """Automatically deinitializes the GIF when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +STATIC mp_obj_t gifio_ondiskgif_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_gifio_ondiskgif_deinit(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gifio_ondiskgif___exit___obj, 4, 4, gifio_ondiskgif_obj___exit__); + //| width: int //| """Width of the gif. (read only)""" STATIC mp_obj_t gifio_ondiskgif_obj_get_width(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_get_width(self)); } @@ -143,6 +168,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_width_obj, STATIC mp_obj_t gifio_ondiskgif_obj_get_height(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_get_height(self)); } @@ -155,6 +181,8 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_height_obj, //| """The bitmap used to hold the current frame.""" STATIC mp_obj_t gifio_ondiskgif_obj_get_bitmap(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + + check_for_deinit(self); return common_hal_gifio_ondiskgif_get_bitmap(self); } @@ -168,6 +196,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_bitmap_obj, STATIC mp_obj_t gifio_ondiskgif_obj_next_frame(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return mp_obj_new_float((float)common_hal_gifio_ondiskgif_next_frame(self, true) / 1000); } @@ -179,6 +208,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_next_frame_obj, gifio_ondiskgif_obj_ne STATIC mp_obj_t gifio_ondiskgif_obj_get_duration(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return mp_obj_new_float((float)common_hal_gifio_ondiskgif_get_duration(self) / 1000); } @@ -192,6 +222,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_duration_obj, STATIC mp_obj_t gifio_ondiskgif_obj_get_frame_count(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_get_frame_count(self)); } @@ -205,6 +236,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_frame_count_obj, STATIC mp_obj_t gifio_ondiskgif_obj_get_min_delay(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return mp_obj_new_float((float)common_hal_gifio_ondiskgif_get_min_delay(self) / 1000); } @@ -219,6 +251,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_min_delay_obj, STATIC mp_obj_t gifio_ondiskgif_obj_get_max_delay(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return mp_obj_new_float((float)common_hal_gifio_ondiskgif_get_max_delay(self) / 1000); } @@ -228,6 +261,9 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_max_delay_obj, (mp_obj_t)&gifio_ondiskgif_get_max_delay_obj); STATIC const mp_rom_map_elem_t gifio_ondiskgif_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&gifio_ondiskgif_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&gifio_ondiskgif___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&gifio_ondiskgif_height_obj) }, { MP_ROM_QSTR(MP_QSTR_bitmap), MP_ROM_PTR(&gifio_ondiskgif_bitmap_obj) }, { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&gifio_ondiskgif_width_obj) }, diff --git a/shared-bindings/gifio/OnDiskGif.h b/shared-bindings/gifio/OnDiskGif.h index 4ecbfca495..6776466e8d 100644 --- a/shared-bindings/gifio/OnDiskGif.h +++ b/shared-bindings/gifio/OnDiskGif.h @@ -45,4 +45,6 @@ int32_t common_hal_gifio_ondiskgif_get_duration(gifio_ondiskgif_t *self); int32_t common_hal_gifio_ondiskgif_get_frame_count(gifio_ondiskgif_t *self); int32_t common_hal_gifio_ondiskgif_get_min_delay(gifio_ondiskgif_t *self); int32_t common_hal_gifio_ondiskgif_get_max_delay(gifio_ondiskgif_t *self); +void common_hal_gifio_ondiskgif_deinit(gifio_ondiskgif_t *self); +bool common_hal_gifio_ondiskgif_deinited(gifio_ondiskgif_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_ONDISKGIF_H diff --git a/shared-module/gifio/OnDiskGif.c b/shared-module/gifio/OnDiskGif.c index 234b7f8198..eb8afb52ab 100644 --- a/shared-module/gifio/OnDiskGif.c +++ b/shared-module/gifio/OnDiskGif.c @@ -154,7 +154,13 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_ self->min_delay = info.iMinDelay; self->max_delay = info.iMaxDelay; - // mp_printf(&mp_plat_print, "GIF_init returned %d %x\n", result, bitmap->data); +void common_hal_gifio_ondiskgif_deinit(gifio_ondiskgif_t *self) { + self->file = NULL; + self->bitmap = NULL; +} + +bool common_hal_gifio_ondiskgif_deinited(gifio_ondiskgif_t *self) { + return self->bitmap == NULL; } uint16_t common_hal_gifio_ondiskgif_get_height(gifio_ondiskgif_t *self) { From 07e83674c90b28c522df7b84417db583568ef9b4 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 14 Mar 2023 18:02:53 -0500 Subject: [PATCH 093/225] Add deinit to displayio.Bitmap --- shared-bindings/displayio/Bitmap.c | 28 ++++++++++++++++++++++++++-- shared-bindings/displayio/Bitmap.h | 2 ++ shared-module/displayio/Bitmap.c | 7 +++++++ shared-module/gifio/OnDiskGif.c | 1 + 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 65551f4e0d..718e1c334c 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -84,11 +84,19 @@ STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } + +STATIC void check_for_deinit(displayio_bitmap_t *self) { + if (common_hal_displayio_bitmap_deinited(self)) { + raise_deinited_error(); + } +} + //| width: int //| """Width of the bitmap. (read only)""" STATIC mp_obj_t displayio_bitmap_obj_get_width(mp_obj_t self_in) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_bitmap_get_width(self)); } @@ -102,6 +110,7 @@ MP_PROPERTY_GETTER(displayio_bitmap_width_obj, STATIC mp_obj_t displayio_bitmap_obj_get_height(mp_obj_t self_in) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_bitmap_get_height(self)); } @@ -134,6 +143,7 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val } displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); if (mp_obj_is_type(index_obj, &mp_type_slice)) { // TODO(tannewt): Implement subscr after slices support start, stop and step tuples. @@ -214,6 +224,7 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); displayio_bitmap_t *self = MP_OBJ_TO_PTR(pos_args[0]); + check_for_deinit(self); int16_t x = args[ARG_x].u_int; int16_t y = args[ARG_y].u_int; @@ -288,6 +299,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 1, displayio_bitmap_obj_bl //| ... STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); mp_uint_t value = (mp_uint_t)mp_obj_get_int(value_obj); if ((value >> common_hal_displayio_bitmap_get_bits_per_value(self)) != 0) { @@ -318,9 +330,10 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_bitmap_fill_obj, displayio_bitmap_obj_fill); //| notified of the "dirty rectangle" that encloses all modified //| pixels.""" //| ... -//| STATIC mp_obj_t displayio_bitmap_obj_dirty(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(pos_args[0]); + check_for_deinit(self); + enum { ARG_x1, ARG_y1, ARG_x2, ARG_y2 }; static const mp_arg_t allowed_args[] = { { MP_QSTR_x1, MP_ARG_INT, {.u_int = 0} }, @@ -344,13 +357,24 @@ STATIC mp_obj_t displayio_bitmap_obj_dirty(size_t n_args, const mp_obj_t *pos_ar } MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_dirty_obj, 0, displayio_bitmap_obj_dirty); +//| def deinit(self) -> None: +//| """Release resources allocated by Bitmap.""" +//| ... +//| +STATIC mp_obj_t displayio_bitmap_obj_deinit(mp_obj_t self_in) { + displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_displayio_bitmap_deinit(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_bitmap_deinit_obj, displayio_bitmap_obj_deinit); + STATIC const mp_rom_map_elem_t displayio_bitmap_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_bitmap_height_obj) }, { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_bitmap_width_obj) }, { MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&displayio_bitmap_blit_obj) }, { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&displayio_bitmap_fill_obj) }, { MP_ROM_QSTR(MP_QSTR_dirty), MP_ROM_PTR(&displayio_bitmap_dirty_obj) }, - + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&displayio_bitmap_deinit_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_bitmap_locals_dict, displayio_bitmap_locals_dict_table); diff --git a/shared-bindings/displayio/Bitmap.h b/shared-bindings/displayio/Bitmap.h index 074f7dfa5c..b35f4eadbc 100644 --- a/shared-bindings/displayio/Bitmap.h +++ b/shared-bindings/displayio/Bitmap.h @@ -48,5 +48,7 @@ void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16 uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y); void common_hal_displayio_bitmap_fill(displayio_bitmap_t *bitmap, uint32_t value); int common_hal_displayio_bitmap_get_buffer(displayio_bitmap_t *self, mp_buffer_info_t *bufinfo, mp_uint_t flags); +void common_hal_displayio_bitmap_deinit(displayio_bitmap_t *self); +bool common_hal_displayio_bitmap_deinited(displayio_bitmap_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_BITMAP_H diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index dc82d04e05..94981cbd4f 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -79,6 +79,13 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self, self->dirty_area.y2 = height; } +void common_hal_displayio_bitmap_deinit(displayio_bitmap_t *self) { + self->data = NULL; +} + +bool common_hal_displayio_bitmap_deinited(displayio_bitmap_t *self) { + return self->data == NULL; +} uint16_t common_hal_displayio_bitmap_get_height(displayio_bitmap_t *self) { return self->height; diff --git a/shared-module/gifio/OnDiskGif.c b/shared-module/gifio/OnDiskGif.c index eb8afb52ab..4c4a6b1f00 100644 --- a/shared-module/gifio/OnDiskGif.c +++ b/shared-module/gifio/OnDiskGif.c @@ -156,6 +156,7 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_ void common_hal_gifio_ondiskgif_deinit(gifio_ondiskgif_t *self) { self->file = NULL; + common_hal_displayio_bitmap_deinit(self->bitmap); self->bitmap = NULL; } From aa423cc1c63341b2476d0b8368f68d68d5e24ae5 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 18 Mar 2023 09:21:40 -0500 Subject: [PATCH 094/225] Free memory allocated by bitmap obj --- shared-module/displayio/Bitmap.c | 6 ++++++ shared-module/displayio/Bitmap.h | 1 + 2 files changed, 7 insertions(+) diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 94981cbd4f..8b578005c6 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -50,6 +50,9 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self, self->stride = stride(width, bits_per_value); if (!data) { data = m_malloc(self->stride * height * sizeof(uint32_t), false); + self->data_alloc = true; + } else { + self->data_alloc = false; } self->data = data; self->read_only = read_only; @@ -80,6 +83,9 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self, } void common_hal_displayio_bitmap_deinit(displayio_bitmap_t *self) { + if (self->data_alloc) { + m_free(self->data); + } self->data = NULL; } diff --git a/shared-module/displayio/Bitmap.h b/shared-module/displayio/Bitmap.h index 0373ae80c5..2025e56282 100644 --- a/shared-module/displayio/Bitmap.h +++ b/shared-module/displayio/Bitmap.h @@ -45,6 +45,7 @@ typedef struct { displayio_area_t dirty_area; uint16_t bitmask; bool read_only; + bool data_alloc; // did bitmap allocate data or someone else } displayio_bitmap_t; void displayio_bitmap_finish_refresh(displayio_bitmap_t *self); From 2c1e2061db5e12f6a7a8ba173bda432966e33806 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 18 Mar 2023 09:28:41 -0500 Subject: [PATCH 095/225] Change free function --- shared-module/displayio/Bitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 8b578005c6..094b2288a4 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -29,6 +29,7 @@ #include #include "py/runtime.h" +#include "py/gc.h" enum { ALIGN_BITS = 8 * sizeof(uint32_t) }; @@ -84,7 +85,7 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self, void common_hal_displayio_bitmap_deinit(displayio_bitmap_t *self) { if (self->data_alloc) { - m_free(self->data); + gc_free(self->data); } self->data = NULL; } From 3020893ba2718acbd4b936688b87c753ccc8d7a4 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 18 Mar 2023 10:01:41 -0500 Subject: [PATCH 096/225] Tweak to try to reduce low space builds --- shared-module/displayio/Bitmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 094b2288a4..4a439e56c0 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -49,11 +49,10 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self, self->width = width; self->height = height; self->stride = stride(width, bits_per_value); + self->data_alloc = false; if (!data) { data = m_malloc(self->stride * height * sizeof(uint32_t), false); self->data_alloc = true; - } else { - self->data_alloc = false; } self->data = data; self->read_only = read_only; From 2365f9b3bee1828500f5eb572a737e26e7d63b63 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 22 Mar 2023 12:41:38 -0400 Subject: [PATCH 097/225] shrink SAMD21 builds; rework shrink logic in Makefile --- ports/atmel-samd/Makefile | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 68beeaf129..84cb4d0dcc 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -59,6 +59,7 @@ INC += -I. \ ifeq ($(CHIP_FAMILY), samd21) PERIPHERALS_CHIP_FAMILY=samd21 OPTIMIZATION_FLAGS ?= -Os + # TinyUSB defines CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD21 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=128 -DCFG_TUD_MSC_BUFSIZE=512 endif @@ -101,24 +102,26 @@ ifeq ($(DEBUG), 1) endif else CFLAGS += -DNDEBUG - # -finline-limit can shrink the image size. - # -finline-limit=80 or so is similar to not having it on. - # There is no simple default value, though. - # Do a default shrink for small builds. - ifndef CFLAGS_INLINE_LIMIT - ifeq ($(CIRCUITPY_FULL_BUILD),0) - CFLAGS_INLINE_LIMIT = 50 + # Do a default shrink for small builds, including all SAMD21 builds. + ifeq ($(CIRCUITPY_FULL_BUILD),0) + SHRINK_BUILD = 1 + else + ifeq ($(CHIP_FAMILY), samd21) + SHRINK_BUILD = 1 endif endif - ifdef CFLAGS_INLINE_LIMIT - CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT) + # -finline-limit can shrink the image size. + # -finline-limit=80 or so is similar to not having it on. + # There is no simple default value, though. + ifeq ($(SHRINK_BUILD), 1) + CFLAGS += -finline-limit=45 endif - ifeq ($(CIRCUITPY_FULL_BUILD),0) - CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20 - endif + # We used to do this but it seems to not reduce space any more, at least in gcc 11. + # Leave it here, commented out, just for reference. + # --param inline-unit-growth=15 --param max-inline-insns-auto=20 ifdef CFLAGS_BOARD CFLAGS += $(CFLAGS_BOARD) From 98ebc676ce273734d5818b7910cb5b6ded4017ee Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Wed, 22 Mar 2023 18:00:18 -0500 Subject: [PATCH 098/225] Added documentation about freeing a GIF --- shared-bindings/gifio/OnDiskGif.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index 3eb56a1c32..cc7112c04c 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -98,6 +98,14 @@ //| display_bus.send(42, struct.pack(">hh", 0, odg.bitmap.width - 1)) //| display_bus.send(43, struct.pack(">hh", 0, odg.bitmap.height - 1)) //| display_bus.send(44, d.bitmap) +//| +//| # The following optional code will free the OnDiskGif and allocated resources +//| # after use. This may be required before loading a new GIF in situations +//| # where RAM is limited and the first GIF took most of the RAM. +//| odg.deinit() +//| odg = None +//| gc.collect() +//| //| """ //| //| def __init__(self, file: str) -> None: From e993d0f3c3bb68852faff35b7e5458f013a0cff0 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Wed, 22 Mar 2023 20:19:09 -0500 Subject: [PATCH 099/225] Missing brace --- shared-module/gifio/OnDiskGif.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared-module/gifio/OnDiskGif.c b/shared-module/gifio/OnDiskGif.c index 4c4a6b1f00..aeb4f7bb74 100644 --- a/shared-module/gifio/OnDiskGif.c +++ b/shared-module/gifio/OnDiskGif.c @@ -32,6 +32,7 @@ #include "py/mperrno.h" #include "py/runtime.h" + static int32_t GIFReadFile(GIFFILE *pFile, uint8_t *pBuf, int32_t iLen) { // mp_printf(&mp_plat_print, "GifReadFile len %d ", iLen); uint32_t iBytesRead; @@ -153,6 +154,7 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_ self->frame_count = info.iFrameCount; self->min_delay = info.iMinDelay; self->max_delay = info.iMaxDelay; +} void common_hal_gifio_ondiskgif_deinit(gifio_ondiskgif_t *self) { self->file = NULL; From 45599258c9cc64225bbba7110bfc60d2b4e1fd94 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 22 Mar 2023 22:00:59 -0400 Subject: [PATCH 100/225] fix missing close brace --- shared-module/gifio/OnDiskGif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-module/gifio/OnDiskGif.c b/shared-module/gifio/OnDiskGif.c index 4c4a6b1f00..309b48eca6 100644 --- a/shared-module/gifio/OnDiskGif.c +++ b/shared-module/gifio/OnDiskGif.c @@ -153,6 +153,7 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_ self->frame_count = info.iFrameCount; self->min_delay = info.iMinDelay; self->max_delay = info.iMaxDelay; +} void common_hal_gifio_ondiskgif_deinit(gifio_ondiskgif_t *self) { self->file = NULL; From 52631bb1c5664da8080b56a049c8cdb67b08ff00 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Wed, 22 Mar 2023 22:30:38 -0500 Subject: [PATCH 101/225] Restore OnDiskGif deinit --- shared-bindings/gifio/OnDiskGif.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index cc7112c04c..ed14cf9fe8 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -268,6 +268,17 @@ MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_get_max_delay_obj, gifio_ondiskgif_obj MP_PROPERTY_GETTER(gifio_ondiskgif_max_delay_obj, (mp_obj_t)&gifio_ondiskgif_get_max_delay_obj); +//| def deinit(self) -> None: +//| """Release resources allocated by OnDiskGif.""" +//| ... +//| +STATIC mp_obj_t gifio_ondiskgif_obj_deinit(mp_obj_t self_in) { + gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_gifio_ondiskgif_deinit(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_deinit_obj, gifio_ondiskgif_obj_deinit); + STATIC const mp_rom_map_elem_t gifio_ondiskgif_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&gifio_ondiskgif_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, From a8abe8e70518f0ced9069614cf81e51d1473b704 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 20 Mar 2023 13:36:08 +0700 Subject: [PATCH 102/225] remove lib from exludes, fix all remaining typos --- .codespell/exclude-file.txt | 7 +++++++ .codespell/ignore-words.txt | 3 +++ .pre-commit-config.yaml | 6 +++++- .../s140_nrf52_7.0.1_API/include/nrf_svc.h | 2 +- ports/raspberrypi/mpconfigport.mk | 4 ++-- ports/stm/common-hal/audiobusio/MEMS_Audio_ll_stm32l4.h | 2 +- py/emitbc.c | 4 ++-- py/emitnative.c | 2 +- py/scope.h | 2 +- shared-bindings/socketpool/SocketPool.c | 1 - tests/basics/int_big1.py | 2 +- tests/basics/with_return.py | 4 ++-- tests/feature_check/README | 2 +- tests/misc/non_compliant.py | 2 +- 14 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.codespell/exclude-file.txt b/.codespell/exclude-file.txt index e69de29bb2..9f49d9ae0c 100644 --- a/.codespell/exclude-file.txt +++ b/.codespell/exclude-file.txt @@ -0,0 +1,7 @@ +#define MICROPY_HW_BOARD_NAME "BLOK" +USB_PRODUCT = "BLOK" + uint32_t THI = (*(uint32_t *)FUSES_HOT_TEMP_VAL_INT_ADDR & FUSES_HOT_TEMP_VAL_INT_Msk) >> FUSES_HOT_TEMP_VAL_INT_Pos; + float TH = THI + convert_dec_to_frac(THD); +print(binascii.b2a_base64(b"fo")) + # again, neither will "there" or "wither", since they have "the" +i1Qb$TE"rl diff --git a/.codespell/ignore-words.txt b/.codespell/ignore-words.txt index 5a54e22f0d..f2a8dc2be5 100644 --- a/.codespell/ignore-words.txt +++ b/.codespell/ignore-words.txt @@ -7,6 +7,7 @@ pris synopsys reenable dout +inout wel iput hsi @@ -17,3 +18,5 @@ dum deque deques extint +shs +pass-thru diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1695a883b4..f8cc372d0f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,11 @@ repos: hooks: - id: codespell #args: [-w] - exclude: ^(locale/|lib/) + exclude: | + (?x)^( + locale/| + lib/ + ) - repo: local hooks: - id: translations diff --git a/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_svc.h b/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_svc.h index 293001eccf..629739ed75 100644 --- a/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_svc.h +++ b/ports/nrf/bluetooth/s140_nrf52_7.0.1/s140_nrf52_7.0.1_API/include/nrf_svc.h @@ -48,7 +48,7 @@ extern "C" { /** @brief Supervisor call declaration. * * A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception. - * The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice. + * The SVCs with SVC numbers 0x00-0x0F are forwarded to the application. All other SVCs are handled by the SoftDevice. * * @param[in] number The SVC number to be used. * @param[in] return_type The return type of the SVC function. diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index c5de2a439d..21dde6d239 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -21,11 +21,11 @@ CIRCUITPY_ROTARYIO ?= 1 CIRCUITPY_ROTARYIO_SOFTENCODER = 1 # Things that need to be implemented. -# Use PWM interally +# Use PWM internally CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CTARGET = 1 CIRCUITPY_NVM = 1 -# Use PIO interally +# Use PIO internally CIRCUITPY_PULSEIO ?= 1 CIRCUITPY_WATCHDOG ?= 1 diff --git a/ports/stm/common-hal/audiobusio/MEMS_Audio_ll_stm32l4.h b/ports/stm/common-hal/audiobusio/MEMS_Audio_ll_stm32l4.h index ce2c397d47..31a8133b63 100644 --- a/ports/stm/common-hal/audiobusio/MEMS_Audio_ll_stm32l4.h +++ b/ports/stm/common-hal/audiobusio/MEMS_Audio_ll_stm32l4.h @@ -148,7 +148,7 @@ typedef struct MemsAudio_STM32L4SAIPDM_t { pdm_data_available_t pdm_data_available; /** - * @brief A cound of the number of PDM clients in use. + * @brief A count of the number of PDM clients in use. */ uint32_t SAI1_client; diff --git a/py/emitbc.c b/py/emitbc.c index 8f7b1d5b72..80d0bf489b 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -253,7 +253,7 @@ STATIC void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, byte b, mp emit_write_bytecode_byte(emit, stack_adj, b); emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(mp_obj_t)); mp_obj_t *c = (mp_obj_t *)emit_get_cur_to_write_bytecode(emit, sizeof(mp_obj_t)); - // Verify thar c is already uint-aligned + // Verify that c is already uint-aligned assert(c == MP_ALIGN(c, sizeof(mp_obj_t))); *c = obj; #endif @@ -269,7 +269,7 @@ STATIC void emit_write_bytecode_byte_raw_code(emit_t *emit, int stack_adj, byte emit_write_bytecode_byte(emit, stack_adj, b); emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(void *)); void **c = (void **)emit_get_cur_to_write_bytecode(emit, sizeof(void *)); - // Verify thar c is already uint-aligned + // Verify that c is already uint-aligned assert(c == MP_ALIGN(c, sizeof(void *))); *c = rc; #endif diff --git a/py/emitnative.c b/py/emitnative.c index 5946fcd341..7d615d5816 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -944,7 +944,7 @@ STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int re } // does an efficient X=pop(); discard(); push(X) -// needs a (non-temp) register in case the poped element was stored in the stack +// needs a (non-temp) register in case the popped element was stored in the stack STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) { stack_info_t *si = &emit->stack_info[emit->stack_size - 2]; si[0] = si[1]; diff --git a/py/scope.h b/py/scope.h index 8b05421072..b189260a37 100644 --- a/py/scope.h +++ b/py/scope.h @@ -49,7 +49,7 @@ typedef struct _id_info_t { uint8_t kind; uint8_t flags; // when it's an ID_INFO_KIND_LOCAL this is the unique number of the local - // whet it's an ID_INFO_KIND_CELL/FREE this is the unique number of the closed over variable + // when it's an ID_INFO_KIND_CELL/FREE this is the unique number of the closed over variable uint16_t local_num; qstr qst; } id_info_t; diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 3023721378..f056c741f3 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -52,7 +52,6 @@ //| returned by :py:attr:`wifi.radio` //| """ //| ... -//| STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); diff --git a/tests/basics/int_big1.py b/tests/basics/int_big1.py index 40d16c455b..01d58f7233 100644 --- a/tests/basics/int_big1.py +++ b/tests/basics/int_big1.py @@ -1,4 +1,4 @@ -# to test arbitrariy precision integers +# to test arbitrarily precision integers x = 1000000000000000000000000000000 xn = -1000000000000000000000000000000 diff --git a/tests/basics/with_return.py b/tests/basics/with_return.py index fd848f1331..6f36d9ad03 100644 --- a/tests/basics/with_return.py +++ b/tests/basics/with_return.py @@ -30,7 +30,7 @@ def f(): return (i, j) print(f()) -# multiple for loops within nested withs +# multiple for loops within nested with(s) def f(): with CtxMgr(1): for i in [1, 2]: @@ -41,7 +41,7 @@ def f(): return (i, j, k, l) print(f()) -# multiple for loops that are optimised, and nested withs +# multiple for loops that are optimised, and nested with(s) def f(): with CtxMgr(1): for i in range(1, 3): diff --git a/tests/feature_check/README b/tests/feature_check/README index 3b7b6cba41..0f55e7ece4 100644 --- a/tests/feature_check/README +++ b/tests/feature_check/README @@ -1,4 +1,4 @@ This directory doesn't contain real tests, but code snippets to detect -various interpreter features, which can't be/inconvenient to detecte by +various interpreter features, which can't be/inconvenient to detected by other means. Scripts here are executed by run-tests.py at the beginning of testsuite to decide what other test groups to run/exclude. diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index 1c3706ec33..ecd4f10391 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -39,7 +39,7 @@ try: except NotImplementedError: print("NotImplementedError") -# uPy raises TypeError, shold be ValueError +# uPy raises TypeError, should be ValueError try: "%c" % b"\x01\x02" except (TypeError, ValueError): From bce1e7e28000abfcf45507db7e8106c982c1b910 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 23 Mar 2023 14:01:20 +0700 Subject: [PATCH 103/225] Revert changes in lib/ --- lib/cmsis/inc/core_armv81mml.h | 4 +-- lib/cmsis/inc/core_sc300.h | 2 +- lib/cmsis/inc/mpu_armv8.h | 2 +- lib/libm_dbl/__rem_pio2_large.c | 6 ++--- lib/libm_dbl/fmod.c | 2 +- lib/libm_dbl/sqrt.c | 2 +- lib/littlefs/lfs1.h | 12 ++++----- lib/littlefs/lfs2.c | 6 ++--- lib/littlefs/lfs2.h | 14 +++++----- lib/oofatfs/diskio.h | 4 +-- lib/oofatfs/ff.c | 48 ++++++++++++++++----------------- lib/oofatfs/ff.h | 2 +- lib/oofatfs/ffconf.h | 6 ++--- lib/oofatfs/ffunicode.c | 2 +- lib/sdmmc/sdmmc_io.c | 2 +- lib/uzlib/tinflate.c | 2 +- 16 files changed, 58 insertions(+), 58 deletions(-) diff --git a/lib/cmsis/inc/core_armv81mml.h b/lib/cmsis/inc/core_armv81mml.h index 48428fd650..9425dbc321 100644 --- a/lib/cmsis/inc/core_armv81mml.h +++ b/lib/cmsis/inc/core_armv81mml.h @@ -2162,7 +2162,7 @@ __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priority group */ + (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ SCB->AIRCR = reg_value; } @@ -2536,7 +2536,7 @@ __STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priority group */ + (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ SCB_NS->AIRCR = reg_value; } diff --git a/lib/cmsis/inc/core_sc300.h b/lib/cmsis/inc/core_sc300.h index cbbac7e82c..5478ea74a5 100644 --- a/lib/cmsis/inc/core_sc300.h +++ b/lib/cmsis/inc/core_sc300.h @@ -1467,7 +1467,7 @@ __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8U) ); /* Insert write key and priority group */ + (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ SCB->AIRCR = reg_value; } diff --git a/lib/cmsis/inc/mpu_armv8.h b/lib/cmsis/inc/mpu_armv8.h index 84fdd323ae..8002738606 100644 --- a/lib/cmsis/inc/mpu_armv8.h +++ b/lib/cmsis/inc/mpu_armv8.h @@ -84,7 +84,7 @@ * \param SH Defines the Shareability domain for this memory region. * \param RO Read-Only: Set to 1 for a read-only memory region. * \param NP Non-Privileged: Set to 1 for a non-privileged memory region. -* \param XN eXecute Never: Set to 1 for a non-executable memory region. +* \oaram XN eXecute Never: Set to 1 for a non-executable memory region. */ #define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \ ((BASE & MPU_RBAR_BASE_Msk) | \ diff --git a/lib/libm_dbl/__rem_pio2_large.c b/lib/libm_dbl/__rem_pio2_large.c index 2d1904efc3..958f28c255 100644 --- a/lib/libm_dbl/__rem_pio2_large.c +++ b/lib/libm_dbl/__rem_pio2_large.c @@ -40,14 +40,14 @@ * z = (z-x[i])*2**24 * * - * y[] output result in an array of double precision numbers. + * y[] ouput result in an array of double precision numbers. * The dimension of y[] is: * 24-bit precision 1 * 53-bit precision 2 * 64-bit precision 2 * 113-bit precision 3 * The actual value is the sum of them. Thus for 113-bit - * precision, one may have to do something like: + * precison, one may have to do something like: * * long double t,w,r_head, r_tail; * t = (long double)y[2] + (long double)y[1]; @@ -78,7 +78,7 @@ * jk+1 must be 2 larger than you might expect so that our * recomputation test works. (Up to 24 bits in the integer * part (the 24 bits of it that we compute) and 23 bits in - * the fraction part may be lost to cancellation before we + * the fraction part may be lost to cancelation before we * recompute.) * * jz local integer variable indicating the number of diff --git a/lib/libm_dbl/fmod.c b/lib/libm_dbl/fmod.c index cf03aacdb2..6849722bac 100644 --- a/lib/libm_dbl/fmod.c +++ b/lib/libm_dbl/fmod.c @@ -9,7 +9,7 @@ double fmod(double x, double y) int sx = ux.i>>63; uint64_t i; - /* in the following uxi should be ux.i, but then gcc wrongly adds */ + /* in the followings uxi should be ux.i, but then gcc wrongly adds */ /* float load/store to inner loops ruining performance and code size */ uint64_t uxi = ux.i; diff --git a/lib/libm_dbl/sqrt.c b/lib/libm_dbl/sqrt.c index 194b09fb52..b277567385 100644 --- a/lib/libm_dbl/sqrt.c +++ b/lib/libm_dbl/sqrt.c @@ -37,7 +37,7 @@ * If (2) is false, then q = q ; otherwise q = q + 2 . * i+1 i i+1 i * - * With some algebraic manipulation, it is not difficult to see + * With some algebric manipulation, it is not difficult to see * that (2) is equivalent to * -(i+1) * s + 2 <= y (3) diff --git a/lib/littlefs/lfs1.h b/lib/littlefs/lfs1.h index 08f0b193c8..355c145d08 100644 --- a/lib/littlefs/lfs1.h +++ b/lib/littlefs/lfs1.h @@ -94,7 +94,7 @@ enum lfs1_open_flags { LFS1_F_DIRTY = 0x10000, // File does not match storage LFS1_F_WRITING = 0x20000, // File has been written since last flush LFS1_F_READING = 0x40000, // File has been read since last flush - LFS1_F_ERRED = 0x80000, // An error occurred during write + LFS1_F_ERRED = 0x80000, // An error occured during write }; // File seek flags @@ -111,25 +111,25 @@ struct lfs1_config { // information to the block device operations void *context; - // Read a region in a block. Negative error codes are propagated + // Read a region in a block. Negative error codes are propogated // to the user. int (*read)(const struct lfs1_config *c, lfs1_block_t block, lfs1_off_t off, void *buffer, lfs1_size_t size); // Program a region in a block. The block must have previously - // been erased. Negative error codes are propagated to the user. + // been erased. Negative error codes are propogated to the user. // May return LFS1_ERR_CORRUPT if the block should be considered bad. int (*prog)(const struct lfs1_config *c, lfs1_block_t block, lfs1_off_t off, const void *buffer, lfs1_size_t size); // Erase a block. A block must be erased before being programmed. // The state of an erased block is undefined. Negative error codes - // are propagated to the user. + // are propogated to the user. // May return LFS1_ERR_CORRUPT if the block should be considered bad. int (*erase)(const struct lfs1_config *c, lfs1_block_t block); // Sync the state of the underlying block device. Negative error codes - // are propagated to the user. + // are propogated to the user. int (*sync)(const struct lfs1_config *c); // Minimum size of a block read. This determines the size of read buffers. @@ -484,7 +484,7 @@ int lfs1_dir_rewind(lfs1_t *lfs1, lfs1_dir_t *dir); // Returns a negative error code on failure. int lfs1_traverse(lfs1_t *lfs1, int (*cb)(void*, lfs1_block_t), void *data); -// Prunes any recoverable errors that may have occurred in the filesystem +// Prunes any recoverable errors that may have occured in the filesystem // // Not needed to be called by user unless an operation is interrupted // but the filesystem is still mounted. This is already called on first diff --git a/lib/littlefs/lfs2.c b/lib/littlefs/lfs2.c index 7f3519acd2..39bd2f0d1c 100644 --- a/lib/littlefs/lfs2.c +++ b/lib/littlefs/lfs2.c @@ -1449,7 +1449,7 @@ static int lfs2_dir_alloc(lfs2_t *lfs2, lfs2_mdir_t *dir) { } } - // zero for reproducibility in case initial block is unreadable + // zero for reproducability in case initial block is unreadable dir->rev = 0; // rather than clobbering one of the blocks we just pretend @@ -1643,7 +1643,7 @@ static int lfs2_dir_compact(lfs2_t *lfs2, return err; } - // whelp, we tried, if we ran out of space there's not much + // welp, we tried, if we ran out of space there's not much // we can do, we'll error later if we've become frozen if (!err) { end = begin; @@ -4037,7 +4037,7 @@ static int lfs2_fs_relocate(lfs2_t *lfs2, lfs2_fs_prepmove(lfs2, 0x3ff, NULL); } - // replace bad pair, either we clean up desync, or no desync occurred + // replace bad pair, either we clean up desync, or no desync occured lfs2_pair_tole32(newpair); err = lfs2_dir_commit(lfs2, &parent, LFS2_MKATTRS( {LFS2_MKTAG_IF(moveid != 0x3ff, diff --git a/lib/littlefs/lfs2.h b/lib/littlefs/lfs2.h index b819aaa3b5..f3b66d76ff 100644 --- a/lib/littlefs/lfs2.h +++ b/lib/littlefs/lfs2.h @@ -159,34 +159,34 @@ struct lfs2_config { // information to the block device operations void *context; - // Read a region in a block. Negative error codes are propagated + // Read a region in a block. Negative error codes are propogated // to the user. int (*read)(const struct lfs2_config *c, lfs2_block_t block, lfs2_off_t off, void *buffer, lfs2_size_t size); // Program a region in a block. The block must have previously - // been erased. Negative error codes are propagated to the user. + // been erased. Negative error codes are propogated to the user. // May return LFS2_ERR_CORRUPT if the block should be considered bad. int (*prog)(const struct lfs2_config *c, lfs2_block_t block, lfs2_off_t off, const void *buffer, lfs2_size_t size); // Erase a block. A block must be erased before being programmed. // The state of an erased block is undefined. Negative error codes - // are propagated to the user. + // are propogated to the user. // May return LFS2_ERR_CORRUPT if the block should be considered bad. int (*erase)(const struct lfs2_config *c, lfs2_block_t block); // Sync the state of the underlying block device. Negative error codes - // are propagated to the user. + // are propogated to the user. int (*sync)(const struct lfs2_config *c); #ifdef LFS2_THREADSAFE // Lock the underlying block device. Negative error codes - // are propagated to the user. + // are propogated to the user. int (*lock)(const struct lfs2_config *c); // Unlock the underlying block device. Negative error codes - // are propagated to the user. + // are propogated to the user. int (*unlock)(const struct lfs2_config *c); #endif @@ -479,7 +479,7 @@ int lfs2_stat(lfs2_t *lfs2, const char *path, struct lfs2_info *info); // Returns the size of the attribute, or a negative error code on failure. // Note, the returned size is the size of the attribute on disk, irrespective // of the size of the buffer. This can be used to dynamically allocate a buffer -// or check for existence. +// or check for existance. lfs2_ssize_t lfs2_getattr(lfs2_t *lfs2, const char *path, uint8_t type, void *buffer, lfs2_size_t size); diff --git a/lib/oofatfs/diskio.h b/lib/oofatfs/diskio.h index 00768cac72..d886bdd9cc 100644 --- a/lib/oofatfs/diskio.h +++ b/lib/oofatfs/diskio.h @@ -3,7 +3,7 @@ */ /*-----------------------------------------------------------------------/ -/ Low level disk interface module include file (C)ChaN, 2014 / +/ Low level disk interface modlue include file (C)ChaN, 2014 / /-----------------------------------------------------------------------*/ #ifndef _DISKIO_DEFINED @@ -42,7 +42,7 @@ DRESULT disk_ioctl (void *drv, BYTE cmd, void* buff); #define STA_PROTECT 0x04 /* Write protected */ -/* Command code for disk_ioctrl function */ +/* Command code for disk_ioctrl fucntion */ /* Generic command (Used by FatFs) */ #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ diff --git a/lib/oofatfs/ff.c b/lib/oofatfs/ff.c index a4c17f0560..dbcfa3efc3 100644 --- a/lib/oofatfs/ff.c +++ b/lib/oofatfs/ff.c @@ -996,7 +996,7 @@ static FRESULT dec_lock ( /* Decrement object open counter */ if (n == 0) Files[i].fs = 0; /* Delete the entry if open count gets zero */ res = FR_OK; } else { - res = FR_INT_ERR; /* Invalid index number */ + res = FR_INT_ERR; /* Invalid index nunber */ } return res; } @@ -1990,7 +1990,7 @@ static void gen_numname ( seq = (UINT)sr; } - /* itoa (hexadecimal) */ + /* itoa (hexdecimal) */ i = 7; do { c = (BYTE)((seq % 16) + '0'); @@ -2098,7 +2098,7 @@ static DWORD xsum32 ( /* Returns 32-bit checksum */ /*------------------------------------------------------*/ static void get_xfileinfo ( - BYTE* dirb, /* Pointer to the directory entry block 85+C0+C1s */ + BYTE* dirb, /* Pointer to the direcotry entry block 85+C0+C1s */ FILINFO* fno /* Buffer to store the extracted file information */ ) { @@ -2135,16 +2135,16 @@ static void get_xfileinfo ( /*-----------------------------------*/ -/* exFAT: Get a directory entry block */ +/* exFAT: Get a directry entry block */ /*-----------------------------------*/ static FRESULT load_xdir ( /* FR_INT_ERR: invalid entry block */ - DIR* dp /* Reading directory object pointing top of the entry block to load */ + DIR* dp /* Reading direcotry object pointing top of the entry block to load */ ) { FRESULT res; UINT i, sz_ent; - BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory directory entry block 85+C0+C1s */ + BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory direcotry entry block 85+C0+C1s */ /* Load file-directory entry */ @@ -2208,7 +2208,7 @@ static void init_alloc_info ( /*------------------------------------------------*/ static FRESULT load_obj_xdir ( - DIR* dp, /* Blank directory object to be used to access containing directory */ + DIR* dp, /* Blank directory object to be used to access containing direcotry */ const FFOBJID* obj /* Object with its containing directory information */ ) { @@ -2237,18 +2237,18 @@ static FRESULT load_obj_xdir ( /*----------------------------------------*/ static FRESULT store_xdir ( - DIR* dp /* Pointer to the directory object */ + DIR* dp /* Pointer to the direcotry object */ ) { FRESULT res; UINT nent; - BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the directory entry block 85+C0+C1s */ + BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the direcotry entry block 85+C0+C1s */ /* Create set sum */ st_word(dirb + XDIR_SetSum, xdir_sum(dirb)); nent = dirb[XDIR_NumSec] + 1; - /* Store the directory entry block to the directory */ + /* Store the direcotry entry block to the directory */ res = dir_sdi(dp, dp->blk_ofs); while (res == FR_OK) { res = move_window(dp->obj.fs, dp->sect); @@ -2265,11 +2265,11 @@ static FRESULT store_xdir ( /*-------------------------------------------*/ -/* exFAT: Create a new directory entry block */ +/* exFAT: Create a new directory enrty block */ /*-------------------------------------------*/ static void create_xdir ( - BYTE* dirb, /* Pointer to the directory entry block buffer */ + BYTE* dirb, /* Pointer to the direcotry entry block buffer */ const WCHAR* lfn /* Pointer to the object name */ ) { @@ -2690,7 +2690,7 @@ static void get_fileinfo ( fno->altname[di] = 0; /* Terminate the SFN (null string means SFN is invalid) */ if (fno->fname[0] == 0) { /* If LFN is invalid, altname[] needs to be copied to fname[] */ - if (di == 0) { /* If LFN and SFN both are invalid, this object is inaccessible */ + if (di == 0) { /* If LFN and SFN both are invalid, this object is inaccesible */ fno->fname[di++] = '?'; } else { for (si = di = 0, lcf = NS_BODY; fno->altname[si]; si++, di++) { /* Copy altname[] to fname[] with case information */ @@ -2764,7 +2764,7 @@ static DWORD get_achar ( /* Get a character and advances ptr */ static int pattern_matching ( /* 0:not matched, 1:matched */ const TCHAR* pat, /* Matching pattern */ - const TCHAR* name, /* String to be tested */ + const TCHAR* nam, /* String to be tested */ int skip, /* Number of pre-skip chars (number of ?s) */ int inf /* Infinite search (* specified) */ ) @@ -2775,12 +2775,12 @@ static int pattern_matching ( /* 0:not matched, 1:matched */ while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&name)) return 0; /* Branch mismatched if less name chars */ + if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ } if (*pat == 0 && inf) return 1; /* (short circuit) */ do { - pp = pat; np = name; /* Top of pattern and name to match */ + pp = pat; np = nam; /* Top of pattern and name to match */ for (;;) { if (*pp == '?' || *pp == '*') { /* Wildcard? */ nm = nx = 0; @@ -2795,7 +2795,7 @@ static int pattern_matching ( /* 0:not matched, 1:matched */ if (pc != nc) break; /* Branch mismatched? */ if (pc == 0) return 1; /* Branch matched? (matched at end of both strings) */ } - get_achar(&name); /* name++ */ + get_achar(&nam); /* nam++ */ } while (inf && nc); /* Retry until end of name if infinite search is specified */ return 0; @@ -3183,7 +3183,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */ } while (LD2PT(fs) == 0 && fmt >= 2 && ++i < 4); } - if (fmt == 4) return FR_DISK_ERR; /* An error occurred in the disk I/O layer */ + if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */ /* An FAT volume is found (bsect). Following code initializes the filesystem object */ @@ -3221,7 +3221,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred fs->volbase = bsect; fs->database = bsect + ld_dword(fs->win + BPB_DataOfsEx); fs->fatbase = bsect + ld_dword(fs->win + BPB_FatOfsEx); - if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size required) */ + if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size requiered) */ fs->dirbase = ld_dword(fs->win + BPB_RootClusEx); /* Get bitmap location and check if it is contiguous (implementation assumption) */ @@ -3365,7 +3365,7 @@ static FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */ if (obj && obj->fs && obj->fs->fs_type && obj->id == obj->fs->id) { /* Test if the object is valid */ #if FF_FS_REENTRANT if (lock_fs(obj->fs)) { /* Obtain the filesystem object */ - if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the physical drive is kept initialized */ + if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */ res = FR_OK; } else { unlock_fs(obj->fs, FR_OK); @@ -3374,7 +3374,7 @@ static FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */ res = FR_TIMEOUT; } #else - if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the physical drive is kept initialized */ + if (disk_ioctl(obj->fs->drv, IOCTL_STATUS, &stat) == RES_OK && !(stat & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */ res = FR_OK; } #endif @@ -3528,7 +3528,7 @@ FRESULT f_open ( } } else { /* Open an existing file */ - if (res == FR_OK) { /* Is the object existing? */ + if (res == FR_OK) { /* Is the object exsiting? */ if (dj.obj.attr & AM_DIR) { /* File open against a directory */ res = FR_NO_FILE; } else { @@ -4339,7 +4339,7 @@ FRESULT f_opendir ( FREE_NAMBUF(); if (res == FR_NO_FILE) res = FR_NO_PATH; } - if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function failed */ + if (res != FR_OK) dp->obj.fs = 0; /* Invalidate the directory object if function faild */ LEAVE_FF(fs, res); } @@ -4779,7 +4779,7 @@ FRESULT f_mkdir ( st_clust(fs, fs->win + SZDIRE, pcl); fs->wflag = 1; } - res = dir_register(&dj); /* Register the object to the parent directory */ + res = dir_register(&dj); /* Register the object to the parent directoy */ } } if (res == FR_OK) { diff --git a/lib/oofatfs/ff.h b/lib/oofatfs/ff.h index fe731eb694..b133d770db 100644 --- a/lib/oofatfs/ff.h +++ b/lib/oofatfs/ff.h @@ -240,7 +240,7 @@ typedef struct { WORD ftime; /* Modified time */ BYTE fattrib; /* File attribute */ #if FF_USE_LFN - TCHAR altname[FF_SFN_BUF + 1];/* Alternative file name */ + TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */ TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */ #else TCHAR fname[12 + 1]; /* File name */ diff --git a/lib/oofatfs/ffconf.h b/lib/oofatfs/ffconf.h index bcd7ee5baf..52ff6d0a7a 100644 --- a/lib/oofatfs/ffconf.h +++ b/lib/oofatfs/ffconf.h @@ -188,7 +188,7 @@ #define FF_LFN_BUF 255 #define FF_SFN_BUF 12 /* This set of options defines size of file name members in the FILINFO structure -/ which is used to read out directory items. These values should be sufficient for +/ which is used to read out directory items. These values should be suffcient for / the file names to read. The maximum possible length of the read file name depends / on character encoding. When LFN is not enabled, these options have no effect. */ @@ -251,7 +251,7 @@ / number and only an FAT volume found on the physical drive will be mounted. / When this function is enabled (1), each logical drive number can be bound to / arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() -/ function will be available. */ +/ funciton will be available. */ #define FF_MIN_SS 512 @@ -316,7 +316,7 @@ #define FF_NORTC_MON 1 #define FF_NORTC_MDAY 1 #define FF_NORTC_YEAR 2018 -/* The option FF_FS_NORTC switches timestamp function. If the system does not have +/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have / any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable / the timestamp function. Every object modified by FatFs will have a fixed timestamp / defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time. diff --git a/lib/oofatfs/ffunicode.c b/lib/oofatfs/ffunicode.c index ce60b42193..a04577616a 100644 --- a/lib/oofatfs/ffunicode.c +++ b/lib/oofatfs/ffunicode.c @@ -3,7 +3,7 @@ /*------------------------------------------------------------------------*/ /* This module will occupy a huge memory in the .const section when the / / FatFs is configured for LFN with DBCS. If the system has any Unicode / -/ utility for the code conversion, this module should be modified to use / +/ utilitiy for the code conversion, this module should be modified to use / / that function to avoid silly memory consumption. / /-------------------------------------------------------------------------*/ /* diff --git a/lib/sdmmc/sdmmc_io.c b/lib/sdmmc/sdmmc_io.c index 68c804982b..17ab291515 100644 --- a/lib/sdmmc/sdmmc_io.c +++ b/lib/sdmmc/sdmmc_io.c @@ -282,7 +282,7 @@ sdmmc_err_t sdmmc_io_rw_extended(sdmmc_card_t* card, int func, return SDMMC_ERR_INVALID_SIZE; } if (datalen == max_byte_transfer_size) { - count = 0; // See 5.3.1 SDIO simplified spec + count = 0; // See 5.3.1 SDIO simplifed spec } else { count = datalen; } diff --git a/lib/uzlib/tinflate.c b/lib/uzlib/tinflate.c index fbee7ce721..045952c755 100644 --- a/lib/uzlib/tinflate.c +++ b/lib/uzlib/tinflate.c @@ -597,7 +597,7 @@ next_blk: if (res == TINF_DONE && !d->bfinal) { /* the block has ended (without producing more data), but we - can't return without data, so start processing next block */ + can't return without data, so start procesing next block */ goto next_blk; } From 66129311f4a9e60ea00739dc95e0ba0db7f4c51d Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 23 Mar 2023 14:19:36 +0700 Subject: [PATCH 104/225] fix pre-commit format --- shared-bindings/socketpool/SocketPool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index f056c741f3..3023721378 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -52,6 +52,7 @@ //| returned by :py:attr:`wifi.radio` //| """ //| ... +//| STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); From 81e71c706f16f2e481b0c47a17c4c095a20f2683 Mon Sep 17 00:00:00 2001 From: ozgurbostan Date: Thu, 23 Mar 2023 13:13:56 +0300 Subject: [PATCH 105/225] Update pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1905b233cf..ce2167abbd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.4.0 hooks: - id: check-yaml - id: end-of-file-fixer From b38c0a4dc1e47b9b585d9d5fd5d9c3868ad126bf Mon Sep 17 00:00:00 2001 From: ozgurbostan Date: Thu, 23 Mar 2023 14:27:15 +0300 Subject: [PATCH 106/225] Add new boards (deneyapkart/1a/g) --- ports/espressif/boards/deneyap_kart/board.c | 34 +++++++ .../boards/deneyap_kart/mpconfigboard.h | 50 ++++++++++ .../boards/deneyap_kart/mpconfigboard.mk | 8 ++ ports/espressif/boards/deneyap_kart/pins.c | 99 +++++++++++++++++++ ports/espressif/boards/deneyap_kart/sdkconfig | 19 ++++ .../espressif/boards/deneyap_kart_1a/board.c | 34 +++++++ .../boards/deneyap_kart_1a/mpconfigboard.h | 50 ++++++++++ .../boards/deneyap_kart_1a/mpconfigboard.mk | 8 ++ ports/espressif/boards/deneyap_kart_1a/pins.c | 97 ++++++++++++++++++ .../boards/deneyap_kart_1a/sdkconfig | 19 ++++ ports/espressif/boards/deneyap_kart_g/board.c | 31 ++++++ .../boards/deneyap_kart_g/mpconfigboard.h | 44 +++++++++ .../boards/deneyap_kart_g/mpconfigboard.mk | 8 ++ ports/espressif/boards/deneyap_kart_g/pins.c | 51 ++++++++++ .../espressif/boards/deneyap_kart_g/sdkconfig | 5 + 15 files changed, 557 insertions(+) create mode 100644 ports/espressif/boards/deneyap_kart/board.c create mode 100644 ports/espressif/boards/deneyap_kart/mpconfigboard.h create mode 100644 ports/espressif/boards/deneyap_kart/mpconfigboard.mk create mode 100644 ports/espressif/boards/deneyap_kart/pins.c create mode 100644 ports/espressif/boards/deneyap_kart/sdkconfig create mode 100644 ports/espressif/boards/deneyap_kart_1a/board.c create mode 100644 ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h create mode 100644 ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk create mode 100644 ports/espressif/boards/deneyap_kart_1a/pins.c create mode 100644 ports/espressif/boards/deneyap_kart_1a/sdkconfig create mode 100644 ports/espressif/boards/deneyap_kart_g/board.c create mode 100644 ports/espressif/boards/deneyap_kart_g/mpconfigboard.h create mode 100644 ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk create mode 100644 ports/espressif/boards/deneyap_kart_g/pins.c create mode 100644 ports/espressif/boards/deneyap_kart_g/sdkconfig diff --git a/ports/espressif/boards/deneyap_kart/board.c b/ports/espressif/boards/deneyap_kart/board.c new file mode 100644 index 0000000000..8c0c8b8b0b --- /dev/null +++ b/ports/espressif/boards/deneyap_kart/board.c @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 Radio Sound, Inc. + * + * 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" +#include "components/driver/include/driver/gpio.h" +#include "components/hal/include/hal/gpio_hal.h" +#include "common-hal/microcontroller/Pin.h" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/deneyap_kart/mpconfigboard.h b/ports/espressif/boards/deneyap_kart/mpconfigboard.h new file mode 100644 index 0000000000..c2251c3dcb --- /dev/null +++ b/ports/espressif/boards/deneyap_kart/mpconfigboard.h @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Dan Halbert 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 "Deneyap Kart" +#define MICROPY_HW_MCU_NAME "ESP32" + +#define MICROPY_HW_LED_STATUS (&pin_GPIO4) + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO15, .sda = &pin_GPIO4}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO19, .mosi = &pin_GPIO5, .miso = &pin_GPIO18}} + +#define CIRCUITPY_BOARD_UART (0) + +// For entering safe mode, use BUT button +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +// Explanation of how a user got into safe mode +// #define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the BUT button at start up.") + +// UART pins attached to the USB-serial converter chip +#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) +#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3) diff --git a/ports/espressif/boards/deneyap_kart/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart/mpconfigboard.mk new file mode 100644 index 0000000000..c98cdb87b6 --- /dev/null +++ b/ports/espressif/boards/deneyap_kart/mpconfigboard.mk @@ -0,0 +1,8 @@ +CIRCUITPY_CREATOR_ID = 0x00001209 +CIRCUITPY_CREATION_ID = 0x0032D001 + +IDF_TARGET = esp32 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/deneyap_kart/pins.c b/ports/espressif/boards/deneyap_kart/pins.c new file mode 100644 index 0000000000..9408d4470c --- /dev/null +++ b/ports/espressif/boards/deneyap_kart/pins.c @@ -0,0 +1,99 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + // External pins are in silkscreen order, from top to bottom, right side, then left side + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_CAMD4), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_CAMD3), MP_ROM_PTR(&pin_GPIO22) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_LEDG), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_LEDR), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_CAMD5), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_CAMD2), MP_ROM_PTR(&pin_GPIO19) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_CAMD6), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_CAMPC), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GPKEY), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IMUSD), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_LEDB), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IMUSC), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_T5), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_MICC), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_T4), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_MICD), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_T3), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_T2), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_CAMV), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_CAMH), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_CAMD9), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_CAMD8), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO32) }, + { MP_ROM_QSTR(MP_QSTR_T0), MP_ROM_PTR(&pin_GPIO32) }, + { MP_ROM_QSTR(MP_QSTR_CAMXC), MP_ROM_PTR(&pin_GPIO32) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_T1), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_CAMSD), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_CAMSC), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_CAMD7), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); diff --git a/ports/espressif/boards/deneyap_kart/sdkconfig b/ports/espressif/boards/deneyap_kart/sdkconfig new file mode 100644 index 0000000000..c98c5de68d --- /dev/null +++ b/ports/espressif/boards/deneyap_kart/sdkconfig @@ -0,0 +1,19 @@ +CONFIG_ESP32_SPIRAM_SUPPORT=y +# +# SPI RAM config +CONFIG_SPIRAM_TYPE_AUTO=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=8388608 +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY is not set +CONFIG_SPIRAM_CACHE_WORKAROUND=y \ No newline at end of file diff --git a/ports/espressif/boards/deneyap_kart_1a/board.c b/ports/espressif/boards/deneyap_kart_1a/board.c new file mode 100644 index 0000000000..8c0c8b8b0b --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a/board.c @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 Radio Sound, Inc. + * + * 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" +#include "components/driver/include/driver/gpio.h" +#include "components/hal/include/hal/gpio_hal.h" +#include "common-hal/microcontroller/Pin.h" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h new file mode 100644 index 0000000000..ba7c216c89 --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Dan Halbert 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 "Deneyap Kart 1A" +#define MICROPY_HW_MCU_NAME "ESP32" + +#define MICROPY_HW_LED_STATUS (&pin_GPIO13) + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO15, .sda = &pin_GPIO4}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO19, .mosi = &pin_GPIO5, .miso = &pin_GPIO18}} + +#define CIRCUITPY_BOARD_UART (0) + +// For entering safe mode, use BUT button +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +// Explanation of how a user got into safe mode +// #define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the BUT button at start up.") + +// UART pins attached to the USB-serial converter chip +#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) +#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3) diff --git a/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk new file mode 100644 index 0000000000..8b3da63e5b --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk @@ -0,0 +1,8 @@ +CIRCUITPY_CREATOR_ID = 0x00001209 +CIRCUITPY_CREATION_ID = 0x0032D002 + +IDF_TARGET = esp32 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/deneyap_kart_1a/pins.c b/ports/espressif/boards/deneyap_kart_1a/pins.c new file mode 100644 index 0000000000..c4b1d51840 --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a/pins.c @@ -0,0 +1,97 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + // External pins are in silkscreen order, from top to bottom, right side, then left side + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_CAMD4), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_CAMD3), MP_ROM_PTR(&pin_GPIO22) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_CAMD5), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_CAMD2), MP_ROM_PTR(&pin_GPIO19) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_CAMD6), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_CAMPC), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GPKEY), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SDMI), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_T5), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_RGBLED), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_T4), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SDCS), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_T3), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_SDMO), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_T2), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_SDCK), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_CAMV), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_CAMH), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_CAMD9), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_CAMD8), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO32) }, + { MP_ROM_QSTR(MP_QSTR_T0), MP_ROM_PTR(&pin_GPIO32) }, + { MP_ROM_QSTR(MP_QSTR_CAMXC), MP_ROM_PTR(&pin_GPIO32) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_T1), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_CAMSD), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_CAMSC), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_CAMD7), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); diff --git a/ports/espressif/boards/deneyap_kart_1a/sdkconfig b/ports/espressif/boards/deneyap_kart_1a/sdkconfig new file mode 100644 index 0000000000..c98c5de68d --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a/sdkconfig @@ -0,0 +1,19 @@ +CONFIG_ESP32_SPIRAM_SUPPORT=y +# +# SPI RAM config +CONFIG_SPIRAM_TYPE_AUTO=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=8388608 +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY is not set +CONFIG_SPIRAM_CACHE_WORKAROUND=y \ No newline at end of file diff --git a/ports/espressif/boards/deneyap_kart_g/board.c b/ports/espressif/boards/deneyap_kart_g/board.c new file mode 100644 index 0000000000..9b26fe466d --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_g/board.c @@ -0,0 +1,31 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" + + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/deneyap_kart_g/mpconfigboard.h b/ports/espressif/boards/deneyap_kart_g/mpconfigboard.h new file mode 100644 index 0000000000..ce2969bbda --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_g/mpconfigboard.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * 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. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "Deneyap Kart G" +#define MICROPY_HW_MCU_NAME "ESP32-C3FN4" + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO2, .sda = &pin_GPIO8}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO4, .mosi = &pin_GPIO6, .miso = &pin_GPIO5}} + +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO21, .rx = &pin_GPIO20}} + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) + +#define CIRCUITPY_ESP_USB_SERIAL_JTAG (1) diff --git a/ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk new file mode 100644 index 0000000000..c01e84611b --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk @@ -0,0 +1,8 @@ +CIRCUITPY_CREATOR_ID = 0x00001209 +CIRCUITPY_CREATION_ID = 0x0032D003 + +IDF_TARGET = esp32c3 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/deneyap_kart_g/pins.c b/ports/espressif/boards/deneyap_kart_g/pins.c new file mode 100644 index 0000000000..c8b7ef4996 --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_g/pins.c @@ -0,0 +1,51 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_GPKEY), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_BT), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_RGBLED), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_PWM2), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); diff --git a/ports/espressif/boards/deneyap_kart_g/sdkconfig b/ports/espressif/boards/deneyap_kart_g/sdkconfig new file mode 100644 index 0000000000..a988de5fea --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_g/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="DeneyapKartG" +# end of LWIP From b947605ab781cb5e7435223681b70c5e1260c6b0 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 23 Mar 2023 09:24:11 -0400 Subject: [PATCH 107/225] Touch up --- ports/espressif/boards/m5stack_stick_c/board.c | 2 +- tests/basics/int_big1.py | 2 +- tests/basics/with_return.py | 4 ++-- tools/preprocess_frozen_modules.py | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ports/espressif/boards/m5stack_stick_c/board.c b/ports/espressif/boards/m5stack_stick_c/board.c index 88d0287419..ae29c9fa76 100644 --- a/ports/espressif/boards/m5stack_stick_c/board.c +++ b/ports/espressif/boards/m5stack_stick_c/board.c @@ -193,7 +193,7 @@ static bool pmic_init(void) { } // Reg: 12h - // Enable EXTENT, DCDC1, LDO2 and LDO3 + // Enable CTRL_EXTEN, DCDC1, LDO2 and LDO3 write_buf[0] = AXP192_DCDC13_LDO23_CTRL; write_buf[1] = AXP192_DCDC13_LDO23_CTRL_EXTEN | AXP192_DCDC13_LDO23_CTRL_LDO3 | diff --git a/tests/basics/int_big1.py b/tests/basics/int_big1.py index 01d58f7233..f6e4b61d1d 100644 --- a/tests/basics/int_big1.py +++ b/tests/basics/int_big1.py @@ -1,4 +1,4 @@ -# to test arbitrarily precision integers +# to test arbitrary precision integers x = 1000000000000000000000000000000 xn = -1000000000000000000000000000000 diff --git a/tests/basics/with_return.py b/tests/basics/with_return.py index 6f36d9ad03..af65a5b984 100644 --- a/tests/basics/with_return.py +++ b/tests/basics/with_return.py @@ -30,7 +30,7 @@ def f(): return (i, j) print(f()) -# multiple for loops within nested with(s) +# multiple for loops within nested with statements def f(): with CtxMgr(1): for i in [1, 2]: @@ -41,7 +41,7 @@ def f(): return (i, j, k, l) print(f()) -# multiple for loops that are optimised, and nested with(s) +# multiple for loops that are optimised, and nested with statements def f(): with CtxMgr(1): for i in range(1, 3): diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py index 80ab547f3b..eb835961f6 100755 --- a/tools/preprocess_frozen_modules.py +++ b/tools/preprocess_frozen_modules.py @@ -21,10 +21,10 @@ def version_string(path=None, *, valid_semver=False): version = tag.strip().decode("utf-8", "strict") except subprocess.CalledProcessError: describe = subprocess.check_output("git describe --tags", shell=True, cwd=path) - tag, additional_commits, committish = ( + tag, additional_commits, commit_ish = ( describe.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2) ) - committish = committish[1:] + commit_ish = commit_ish[1:] if valid_semver: version_info = semver.parse_version_info(tag) if not version_info.prerelease: @@ -33,12 +33,12 @@ def version_string(path=None, *, valid_semver=False): + "-alpha.0.plus." + additional_commits + "+" - + committish + + commit_ish ) else: - version = tag + ".plus." + additional_commits + "+" + committish + version = tag + ".plus." + additional_commits + "+" + commit_ish else: - version = committish + version = commit_ish return version From b50c80e3d93775561a314c0712195760547bb18c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 09:12:46 -0500 Subject: [PATCH 108/225] remove unused macro --- ports/mimxrt10xx/common-hal/audiobusio/__init__.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c index 2be6c6bcbb..515c39a268 100644 --- a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c +++ b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c @@ -38,11 +38,6 @@ #define SAI_CLOCK_FREQ (CLOCK_GetFreq(kCLOCK_AudioPllClk) / (SAI_CLOCK_SOURCE_DIVIDER + 1U) / \ (SAI_CLOCK_SOURCE_PRE_DIVIDER + 1U)) -// must match what's in clocks.c (but that's a C file so there's no way to include it) -// This is 480MMHz * (18/17) / 8 (around 63.5MHz) and there's no partiuclar -// logic to this value that I was able to determine. -#define BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT 63529411UL - #define AUDIO_BUFFER_FRAME_COUNT (128) // in uint32_t; there are 4, giving 2048 bytes. In all they hold 10ms @ stereo 16-bit 48kHz before all buffers drain /* From 47e1abdbc7ba23dac7b6596bacd22416002649ec Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 6 Mar 2023 16:04:39 -0600 Subject: [PATCH 109/225] Add IncrementalEncoder for mimxrt1011 .. and write a general 'pin change interrupt' facility to power it This uses the same quadrature state machine as atmel-samd, nrf, and rp2040. The 1011 doesn't have a dedicated encoder peripheral, so we go the pin-change + software route. --- .../common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/digitalio/DigitalInOut.h | 2 + .../common-hal/microcontroller/Pin.c | 98 +++++++++++++++++++ .../common-hal/microcontroller/Pin.h | 4 + .../common-hal/rotaryio/IncrementalEncoder.c | 87 ++++++++++++++++ .../common-hal/rotaryio/IncrementalEncoder.h | 44 +++++++++ .../mimxrt10xx/common-hal/rotaryio/__init__.c | 0 .../mimxrt10xx/common-hal/rotaryio/__init__.h | 0 ports/mimxrt10xx/mpconfigport.mk | 3 +- 9 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c create mode 100644 ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.h create mode 100644 ports/mimxrt10xx/common-hal/rotaryio/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/rotaryio/__init__.h diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c index 3445cf42a0..2b4a78948e 100644 --- a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c @@ -40,7 +40,7 @@ #define IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5 5U -STATIC void pin_config(const mcu_pin_obj_t *pin, bool open_drain, digitalio_pull_t pull) { +void pin_config(const mcu_pin_obj_t *pin, bool open_drain, digitalio_pull_t pull) { IOMUXC_SetPinConfig(0, 0, 0, 0, pin->cfg_reg, IOMUXC_SW_PAD_CTL_PAD_HYS(1) | IOMUXC_SW_PAD_CTL_PAD_PUS((pull == PULL_UP) ? 2 : 0) diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h index 4c19de20b6..06adb93cb8 100644 --- a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h @@ -40,4 +40,6 @@ typedef struct { digitalio_pull_t pull; } digitalio_digitalinout_obj_t; +void pin_config(const mcu_pin_obj_t *pin, bool open_drain, digitalio_pull_t pull); + #endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DIGITALIO_DIGITALINOUT_H diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index 3c8c7f2b27..9d55382306 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -84,6 +84,7 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) { return; } + disable_pin_change_interrupt(pin); never_reset_pins[pin->mux_idx] = false; claimed_pins[pin->mux_idx] = false; *(uint32_t *)pin->mux_reg = pin->mux_reset; @@ -116,3 +117,100 @@ void claim_pin(const mcu_pin_obj_t *pin) { void common_hal_mcu_pin_reset_number(uint8_t pin_no) { common_hal_reset_pin((mcu_pin_obj_t *)(mcu_pin_globals.map.table[pin_no].value)); } + +/* Array of GPIO peripheral base address. */ +static GPIO_Type *const s_gpioBases[] = GPIO_BASE_PTRS; +static uint32_t GPIO_GetInstance(GPIO_Type *base) { + uint32_t instance; + + /* Find the instance index from base address mappings. */ + for (instance = 0U; instance < ARRAY_SIZE(s_gpioBases); instance++) + { + if (s_gpioBases[instance] == base) { + break; + } + } + + assert(instance < ARRAY_SIZE(s_gpioBases)); + + return instance; +} + +/* to find IRQ based on GPIO */ +static const IRQn_Type low_irqs[] = GPIO_COMBINED_LOW_IRQS; +static const IRQn_Type high_irqs[] = GPIO_COMBINED_HIGH_IRQS; + +typedef struct { + gpio_change_interrupt_t *func; + void *data; +} pin_change_interrupt_data; + +volatile static pin_change_interrupt_data pcid[MP_ARRAY_SIZE(s_gpioBases)][32]; + +void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data) { + int instance = GPIO_GetInstance(pin->gpio); + volatile pin_change_interrupt_data *pci = &pcid[instance][pin->number]; + common_hal_mcu_disable_interrupts(); + pci->data = data; + pci->func = func; + IRQn_Type irq = pin->number < 16 ? low_irqs[instance] : high_irqs[instance]; + if (irq != NotAvail_IRQn) { + EnableIRQ(irq); + } + pin->gpio->IMR |= (1 << pin->number); + common_hal_mcu_enable_interrupts(); +} + +void disable_pin_change_interrupt(const mcu_pin_obj_t *pin) { + volatile pin_change_interrupt_data *pci = &pcid[GPIO_GetInstance(pin->gpio)][pin->number]; + common_hal_mcu_disable_interrupts(); + pin->gpio->IMR &= ~(1 << pin->number); + pci->data = NULL; + pci->func = NULL; + pin->gpio->ISR = (1 << pin->number); // acknowledge any pending interrupt + common_hal_mcu_enable_interrupts(); +} + +static void pin_change_interrupt_common(uint32_t isr, volatile pin_change_interrupt_data *pcr) { + for (uint32_t i = 0; i < 32; i++) { + if (isr & (1 << i)) { + pin_change_interrupt_data cb = pcr[i]; + if (cb.func) { + cb.func(cb.data); + } + } + } +} + +#define GPIO_INTERRUPT_HANDLER(name, ptr, instance, offset) \ + void name(void); \ + __attribute__((used)) void name(void) { \ + uint32_t isr = ptr->ISR; \ + ptr->ISR = isr; \ + pin_change_interrupt_common(isr, pcid[instance]); \ + } + +#if defined(GPIO1) +GPIO_INTERRUPT_HANDLER(GPIO1_Combined_0_15_IRQHandler, GPIO1, 1, 0); +GPIO_INTERRUPT_HANDLER(GPIO1_Combined_16_31_IRQHandler, GPIO1, 1, 16); +#endif +#if defined(GPIO2) +GPIO_INTERRUPT_HANDLER(GPIO2_Combined_0_15_IRQHandler, GPIO2, 2, 0); +GPIO_INTERRUPT_HANDLER(GPIO2_Combined_16_31_IRQHandler, GPIO2, 2, 16); +#endif +#if defined(GPIO3) +GPIO_INTERRUPT_HANDLER(GPIO3_Combined_0_15_IRQHandler, GPIO3, 3, 0); +GPIO_INTERRUPT_HANDLER(GPIO3_Combined_16_31_IRQHandler, GPIO3, 3, 16); +#endif +#if defined(GPIO4) +GPIO_INTERRUPT_HANDLER(GPIO4_Combined_0_15_IRQHandler, GPIO4, 4, 0); +GPIO_INTERRUPT_HANDLER(GPIO4_Combined_16_31_IRQHandler, GPIO4, 4, 16); +#endif +#if defined(GPIO5) +GPIO_INTERRUPT_HANDLER(GPIO5_Combined_0_15_IRQHandler, GPIO5, 5, 0); +GPIO_INTERRUPT_HANDLER(GPIO5_Combined_16_31_IRQHandler, GPIO5, 5, 16); +#endif +#if defined(GPIO6) +GPIO_INTERRUPT_HANDLER(GPIO6_Combined_0_15_IRQHandler, GPIO6, 6, 0); +GPIO_INTERRUPT_HANDLER(GPIO6_Combined_16_31_IRQHandler, GPIO6, 6, 16); +#endif diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h index 1bfbe41a18..cbcce13e2b 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h @@ -45,4 +45,8 @@ extern const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[]; // the port-default reset behavior. extern bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin); +typedef void (gpio_change_interrupt_t)(void *data); +void disable_pin_change_interrupt(const mcu_pin_obj_t *pin); +void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data); + #endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H diff --git a/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c b/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c new file mode 100644 index 0000000000..dab74c1ce9 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c @@ -0,0 +1,87 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Nick Moore for Adafruit Industries + * Copyright (c) 2023 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 "common-hal/digitalio/DigitalInOut.h" +#include "common-hal/rotaryio/IncrementalEncoder.h" +#include "shared-module/rotaryio/IncrementalEncoder.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/rotaryio/IncrementalEncoder.h" + +#include "py/runtime.h" + +#include "fsl_gpio.h" +static void encoder_change(void *self_in) { + rotaryio_incrementalencoder_obj_t *self = self_in; + + bool value_a = GPIO_PinRead(self->pin_a->gpio, self->pin_a->number); + bool value_b = GPIO_PinRead(self->pin_b->gpio, self->pin_b->number); + uint8_t new_state = (value_a << 1) | value_b; + shared_module_softencoder_state_update(self, new_state); +} + +void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t *self, + const mcu_pin_obj_t *pin_a, const mcu_pin_obj_t *pin_b) { + + self->pin_a = pin_a; + self->pin_b = pin_b; + + // GPIO is always IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5 until proven otherwise +#define IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5 5U + IOMUXC_SetPinMux(pin_a->mux_reg, IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5, 0, 0, 0, 0); + IOMUXC_SetPinMux(pin_b->mux_reg, IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5, 0, 0, 0, 0); + + const gpio_pin_config_t config = { kGPIO_DigitalInput, 0, kGPIO_IntRisingOrFallingEdge }; + GPIO_PinInit(pin_a->gpio, pin_a->number, &config); + GPIO_PinInit(pin_b->gpio, pin_b->number, &config); + + enable_pin_change_interrupt(pin_a, encoder_change, self); + enable_pin_change_interrupt(pin_b, encoder_change, self); + + pin_config(pin_a, false, PULL_UP); + pin_config(pin_b, false, PULL_UP); + + claim_pin(pin_a); + claim_pin(pin_b); +} + +bool common_hal_rotaryio_incrementalencoder_deinited(rotaryio_incrementalencoder_obj_t *self) { + return !self->pin_a; +} + +void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_obj_t *self) { + if (common_hal_rotaryio_incrementalencoder_deinited(self)) { + return; + } + disable_pin_change_interrupt(self->pin_a); + disable_pin_change_interrupt(self->pin_b); + + common_hal_reset_pin(self->pin_a); + common_hal_reset_pin(self->pin_b); + + self->pin_a = NULL; + self->pin_b = NULL; +} diff --git a/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.h b/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.h new file mode 100644 index 0000000000..920b32cba9 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2023 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "common-hal/microcontroller/Pin.h" + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t *pin_a, *pin_b; + uint8_t state; // + int8_t sub_count; // count intermediate transitions between detents + int8_t divisor; // Number of quadrature edges required per count + mp_int_t position; +} rotaryio_incrementalencoder_obj_t; + + +void incrementalencoder_interrupt_handler(uint8_t channel); diff --git a/ports/mimxrt10xx/common-hal/rotaryio/__init__.c b/ports/mimxrt10xx/common-hal/rotaryio/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/mimxrt10xx/common-hal/rotaryio/__init__.h b/ports/mimxrt10xx/common-hal/rotaryio/__init__.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 236d5b9966..15a0a0e466 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -20,7 +20,8 @@ CIRCUITPY_I2CTARGET = 0 CIRCUITPY_NVM = 0 CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_PULSEIO = 0 -CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_ROTARYIO = 1 +CIRCUITPY_ROTARYIO_SOFTENCODER = 1 CIRCUITPY_USB_MIDI = 1 LONGINT_IMPL = MPZ From d247e5c6c97a5e88af86dfb73daeb54e1642bba3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 7 Mar 2023 10:37:08 -0600 Subject: [PATCH 110/225] Add the ability for a port to gc things, collect pin change objects that way --- main.c | 6 ++++++ ports/mimxrt10xx/common-hal/microcontroller/Pin.c | 7 +++++++ ports/mimxrt10xx/common-hal/microcontroller/Pin.h | 1 + ports/mimxrt10xx/supervisor/port.c | 4 ++++ supervisor/port.h | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/main.c b/main.c index 7b805b57b0..6ff6202d6d 100644 --- a/main.c +++ b/main.c @@ -1111,6 +1111,8 @@ void gc_collect(void) { // have lost their references in the VM even though they are mounted. gc_collect_root((void **)&MP_STATE_VM(vfs_mount_table), sizeof(mp_vfs_mount_t) / sizeof(mp_uint_t)); + port_gc_collect(); + background_callback_gc_collect(); #if CIRCUITPY_ALARM @@ -1143,6 +1145,10 @@ void gc_collect(void) { gc_collect_end(); } +// Ports may provide an implementation of this function if it is needed +MP_WEAK void port_gc_collect() { +} + void NORETURN nlr_jump_fail(void *val) { reset_into_safe_mode(SAFE_MODE_NLR_JUMP_FAIL); while (true) { diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index 9d55382306..fc455d7a27 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -28,6 +28,8 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" +#include "py/gc.h" + STATIC bool claimed_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT]; STATIC bool never_reset_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT]; @@ -147,6 +149,11 @@ typedef struct { volatile static pin_change_interrupt_data pcid[MP_ARRAY_SIZE(s_gpioBases)][32]; +// The 'data' pointers may be to gc objects, they must be kept alive. +void pin_gc_collect() { + gc_collect_root((void **)&pcid, sizeof(pcid) / sizeof(void *)); +} + void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data) { int instance = GPIO_GetInstance(pin->gpio); volatile pin_change_interrupt_data *pci = &pcid[instance][pin->number]; diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h index cbcce13e2b..f75f4fbbee 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h @@ -48,5 +48,6 @@ extern bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin); typedef void (gpio_change_interrupt_t)(void *data); void disable_pin_change_interrupt(const mcu_pin_obj_t *pin); void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data); +void pin_gc_collect(void); #endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 55bf72352d..1e46159829 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -555,6 +555,10 @@ void port_idle_until_interrupt(void) { common_hal_mcu_enable_interrupts(); } +void port_gc_collect(void) { + pin_gc_collect(); +} + // Catch faults where the memory access violates MPU settings. void MemManage_Handler(void); __attribute__((used)) void PLACE_IN_ITCM(MemManage_Handler)(void) { diff --git a/supervisor/port.h b/supervisor/port.h index 70bdcb0170..b50179e4de 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -128,4 +128,8 @@ void port_post_boot_py(bool heap_valid); // A default weak implementation is provided that does nothing. void port_boot_info(void); +// Some ports want to mark additional pointers as gc roots. +// A default weak implementation is provided that does nothing. +void port_gc_collect(void); + #endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H From de74b634725a464e82795ed9e48f2562b9eb3fd7 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 09:28:14 -0500 Subject: [PATCH 111/225] move pin change interrupt stuff to peripherals --- ports/mimxrt10xx/Makefile | 1 + .../common-hal/microcontroller/Pin.c | 97 ------------------- .../common-hal/microcontroller/Pin.h | 3 - .../common-hal/rotaryio/IncrementalEncoder.c | 2 +- .../mimxrt10xx/peripherals/mimxrt10xx/pins.c | 94 ++++++++++++++++++ .../mimxrt10xx/peripherals/mimxrt10xx/pins.h | 10 ++ 6 files changed, 106 insertions(+), 101 deletions(-) create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index d8d12b74da..542014e91a 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -136,6 +136,7 @@ SRC_C += \ peripherals/mimxrt10xx/$(CHIP_FAMILY)/clocks.c \ peripherals/mimxrt10xx/$(CHIP_FAMILY)/periph.c \ peripherals/mimxrt10xx/$(CHIP_FAMILY)/pins.c \ + peripherals/mimxrt10xx/pins.c \ reset.c \ supervisor/flexspi_nor_flash_ops.c diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index fc455d7a27..a5c491ee7d 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -120,104 +120,7 @@ void common_hal_mcu_pin_reset_number(uint8_t pin_no) { common_hal_reset_pin((mcu_pin_obj_t *)(mcu_pin_globals.map.table[pin_no].value)); } -/* Array of GPIO peripheral base address. */ -static GPIO_Type *const s_gpioBases[] = GPIO_BASE_PTRS; -static uint32_t GPIO_GetInstance(GPIO_Type *base) { - uint32_t instance; - - /* Find the instance index from base address mappings. */ - for (instance = 0U; instance < ARRAY_SIZE(s_gpioBases); instance++) - { - if (s_gpioBases[instance] == base) { - break; - } - } - - assert(instance < ARRAY_SIZE(s_gpioBases)); - - return instance; -} - -/* to find IRQ based on GPIO */ -static const IRQn_Type low_irqs[] = GPIO_COMBINED_LOW_IRQS; -static const IRQn_Type high_irqs[] = GPIO_COMBINED_HIGH_IRQS; - -typedef struct { - gpio_change_interrupt_t *func; - void *data; -} pin_change_interrupt_data; - -volatile static pin_change_interrupt_data pcid[MP_ARRAY_SIZE(s_gpioBases)][32]; - // The 'data' pointers may be to gc objects, they must be kept alive. void pin_gc_collect() { gc_collect_root((void **)&pcid, sizeof(pcid) / sizeof(void *)); } - -void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data) { - int instance = GPIO_GetInstance(pin->gpio); - volatile pin_change_interrupt_data *pci = &pcid[instance][pin->number]; - common_hal_mcu_disable_interrupts(); - pci->data = data; - pci->func = func; - IRQn_Type irq = pin->number < 16 ? low_irqs[instance] : high_irqs[instance]; - if (irq != NotAvail_IRQn) { - EnableIRQ(irq); - } - pin->gpio->IMR |= (1 << pin->number); - common_hal_mcu_enable_interrupts(); -} - -void disable_pin_change_interrupt(const mcu_pin_obj_t *pin) { - volatile pin_change_interrupt_data *pci = &pcid[GPIO_GetInstance(pin->gpio)][pin->number]; - common_hal_mcu_disable_interrupts(); - pin->gpio->IMR &= ~(1 << pin->number); - pci->data = NULL; - pci->func = NULL; - pin->gpio->ISR = (1 << pin->number); // acknowledge any pending interrupt - common_hal_mcu_enable_interrupts(); -} - -static void pin_change_interrupt_common(uint32_t isr, volatile pin_change_interrupt_data *pcr) { - for (uint32_t i = 0; i < 32; i++) { - if (isr & (1 << i)) { - pin_change_interrupt_data cb = pcr[i]; - if (cb.func) { - cb.func(cb.data); - } - } - } -} - -#define GPIO_INTERRUPT_HANDLER(name, ptr, instance, offset) \ - void name(void); \ - __attribute__((used)) void name(void) { \ - uint32_t isr = ptr->ISR; \ - ptr->ISR = isr; \ - pin_change_interrupt_common(isr, pcid[instance]); \ - } - -#if defined(GPIO1) -GPIO_INTERRUPT_HANDLER(GPIO1_Combined_0_15_IRQHandler, GPIO1, 1, 0); -GPIO_INTERRUPT_HANDLER(GPIO1_Combined_16_31_IRQHandler, GPIO1, 1, 16); -#endif -#if defined(GPIO2) -GPIO_INTERRUPT_HANDLER(GPIO2_Combined_0_15_IRQHandler, GPIO2, 2, 0); -GPIO_INTERRUPT_HANDLER(GPIO2_Combined_16_31_IRQHandler, GPIO2, 2, 16); -#endif -#if defined(GPIO3) -GPIO_INTERRUPT_HANDLER(GPIO3_Combined_0_15_IRQHandler, GPIO3, 3, 0); -GPIO_INTERRUPT_HANDLER(GPIO3_Combined_16_31_IRQHandler, GPIO3, 3, 16); -#endif -#if defined(GPIO4) -GPIO_INTERRUPT_HANDLER(GPIO4_Combined_0_15_IRQHandler, GPIO4, 4, 0); -GPIO_INTERRUPT_HANDLER(GPIO4_Combined_16_31_IRQHandler, GPIO4, 4, 16); -#endif -#if defined(GPIO5) -GPIO_INTERRUPT_HANDLER(GPIO5_Combined_0_15_IRQHandler, GPIO5, 5, 0); -GPIO_INTERRUPT_HANDLER(GPIO5_Combined_16_31_IRQHandler, GPIO5, 5, 16); -#endif -#if defined(GPIO6) -GPIO_INTERRUPT_HANDLER(GPIO6_Combined_0_15_IRQHandler, GPIO6, 6, 0); -GPIO_INTERRUPT_HANDLER(GPIO6_Combined_16_31_IRQHandler, GPIO6, 6, 16); -#endif diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h index f75f4fbbee..57df61c691 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h @@ -45,9 +45,6 @@ extern const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[]; // the port-default reset behavior. extern bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin); -typedef void (gpio_change_interrupt_t)(void *data); -void disable_pin_change_interrupt(const mcu_pin_obj_t *pin); -void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data); void pin_gc_collect(void); #endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H diff --git a/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c b/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c index dab74c1ce9..043b791b4d 100644 --- a/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/mimxrt10xx/common-hal/rotaryio/IncrementalEncoder.c @@ -33,7 +33,7 @@ #include "py/runtime.h" -#include "fsl_gpio.h" +#include "sdk/drivers/igpio/fsl_gpio.h" static void encoder_change(void *self_in) { rotaryio_incrementalencoder_obj_t *self = self_in; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c new file mode 100644 index 0000000000..1f2d5321e9 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c @@ -0,0 +1,94 @@ +#include "peripherals/mimxrt10xx/pins.h" + +/* Array of GPIO peripheral base address. */ +static GPIO_Type *const s_gpioBases[] = GPIO_BASE_PTRS; +static uint32_t GPIO_GetInstance(GPIO_Type *base) { + uint32_t instance; + + /* Find the instance index from base address mappings. */ + for (instance = 0U; instance < ARRAY_SIZE(s_gpioBases); instance++) + { + if (s_gpioBases[instance] == base) { + break; + } + } + + assert(instance < ARRAY_SIZE(s_gpioBases)); + + return instance; +} + + +/* to find IRQ based on GPIO */ +static const IRQn_Type low_irqs[] = GPIO_COMBINED_LOW_IRQS; +static const IRQn_Type high_irqs[] = GPIO_COMBINED_HIGH_IRQS; + +volatile pin_change_interrupt_data pcid[MP_ARRAY_SIZE(s_gpioBases)][32]; + +void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data) { + int instance = GPIO_GetInstance(pin->gpio); + volatile pin_change_interrupt_data *pci = &pcid[instance][pin->number]; + common_hal_mcu_disable_interrupts(); + pci->data = data; + pci->func = func; + IRQn_Type irq = pin->number < 16 ? low_irqs[instance] : high_irqs[instance]; + if (irq != NotAvail_IRQn) { + EnableIRQ(irq); + } + pin->gpio->IMR |= (1 << pin->number); + common_hal_mcu_enable_interrupts(); +} + +void disable_pin_change_interrupt(const mcu_pin_obj_t *pin) { + volatile pin_change_interrupt_data *pci = &pcid[GPIO_GetInstance(pin->gpio)][pin->number]; + common_hal_mcu_disable_interrupts(); + pin->gpio->IMR &= ~(1 << pin->number); + pci->data = NULL; + pci->func = NULL; + pin->gpio->ISR = (1 << pin->number); // acknowledge any pending interrupt + common_hal_mcu_enable_interrupts(); +} + +static void pin_change_interrupt_common(uint32_t isr, volatile pin_change_interrupt_data *pcr) { + for (uint32_t i = 0; i < 32; i++) { + if (isr & (1 << i)) { + pin_change_interrupt_data cb = pcr[i]; + if (cb.func) { + cb.func(cb.data); + } + } + } +} + +#define GPIO_INTERRUPT_HANDLER(name, ptr, instance, offset) \ + void name(void); \ + __attribute__((used)) void name(void) { \ + uint32_t isr = ptr->ISR; \ + ptr->ISR = isr; \ + pin_change_interrupt_common(isr, pcid[instance]); \ + } + +#if defined(GPIO1) +GPIO_INTERRUPT_HANDLER(GPIO1_Combined_0_15_IRQHandler, GPIO1, 1, 0); +GPIO_INTERRUPT_HANDLER(GPIO1_Combined_16_31_IRQHandler, GPIO1, 1, 16); +#endif +#if defined(GPIO2) +GPIO_INTERRUPT_HANDLER(GPIO2_Combined_0_15_IRQHandler, GPIO2, 2, 0); +GPIO_INTERRUPT_HANDLER(GPIO2_Combined_16_31_IRQHandler, GPIO2, 2, 16); +#endif +#if defined(GPIO3) +GPIO_INTERRUPT_HANDLER(GPIO3_Combined_0_15_IRQHandler, GPIO3, 3, 0); +GPIO_INTERRUPT_HANDLER(GPIO3_Combined_16_31_IRQHandler, GPIO3, 3, 16); +#endif +#if defined(GPIO4) +GPIO_INTERRUPT_HANDLER(GPIO4_Combined_0_15_IRQHandler, GPIO4, 4, 0); +GPIO_INTERRUPT_HANDLER(GPIO4_Combined_16_31_IRQHandler, GPIO4, 4, 16); +#endif +#if defined(GPIO5) +GPIO_INTERRUPT_HANDLER(GPIO5_Combined_0_15_IRQHandler, GPIO5, 5, 0); +GPIO_INTERRUPT_HANDLER(GPIO5_Combined_16_31_IRQHandler, GPIO5, 5, 16); +#endif +#if defined(GPIO6) +GPIO_INTERRUPT_HANDLER(GPIO6_Combined_0_15_IRQHandler, GPIO6, 6, 0); +GPIO_INTERRUPT_HANDLER(GPIO6_Combined_16_31_IRQHandler, GPIO6, 6, 16); +#endif diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h index 82cb0dc69e..76a8d03e08 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h @@ -72,6 +72,16 @@ typedef struct { .pad_reset = p_pad_reset, \ } +typedef void (gpio_change_interrupt_t)(void *data); +typedef struct { + gpio_change_interrupt_t *func; + void *data; +} pin_change_interrupt_data; +extern volatile pin_change_interrupt_data pcid[MP_ARRAY_SIZE((GPIO_Type *const[])GPIO_BASE_PTRS)][32]; + +void disable_pin_change_interrupt(const mcu_pin_obj_t *pin); +void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data); + #ifdef MIMXRT1011_SERIES #include "MIMXRT1011/pins.h" #elif defined(MIMXRT1021_SERIES) From c45db1c1eb0a71b8378c4007fb23b4dfe24c2059 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 09:56:14 -0500 Subject: [PATCH 112/225] incrementalencoder: give it a finaliser --- shared-bindings/rotaryio/IncrementalEncoder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index fae55db317..ec2a281157 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -76,7 +76,7 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, const mcu_pin_obj_t *pin_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj, MP_QSTR_pin_b); // Make long-lived because some implementations use a pointer to the object as interrupt-handler data. - rotaryio_incrementalencoder_obj_t *self = m_new_ll_obj(rotaryio_incrementalencoder_obj_t); + rotaryio_incrementalencoder_obj_t *self = m_new_ll_obj_with_finaliser(rotaryio_incrementalencoder_obj_t); self->base.type = &rotaryio_incrementalencoder_type; common_hal_rotaryio_incrementalencoder_construct(self, pin_a, pin_b); @@ -171,6 +171,7 @@ MP_PROPERTY_GETSET(rotaryio_incrementalencoder_position_obj, STATIC const mp_rom_map_elem_t rotaryio_incrementalencoder_locals_dict_table[] = { // Methods { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&rotaryio_incrementalencoder_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&rotaryio_incrementalencoder_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&rotaryio_incrementalencoder___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_position), MP_ROM_PTR(&rotaryio_incrementalencoder_position_obj) }, From 50ba218afb199685e96a43ef8333cba76d0a691f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 09:57:32 -0500 Subject: [PATCH 113/225] PulseIn, Counter: give finali(s/z)ers to these types too for similar reasons, an interrupt handler might point at these objects, and we can worry less about it if the object deinits when it is GC'd. --- shared-bindings/countio/Counter.c | 3 ++- shared-bindings/pulseio/PulseIn.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 4f0e0a692f..fc60994f5c 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -57,7 +57,7 @@ STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg const countio_edge_t edge = validate_edge(args[ARG_edge].u_obj, MP_QSTR_edge); const digitalio_pull_t pull = validate_pull(args[ARG_pull].u_obj, MP_QSTR_pull); // Make long-lived because some implementations use a pointer to the object as interrupt-handler data. - countio_counter_obj_t *self = m_new_ll_obj(countio_counter_obj_t); + countio_counter_obj_t *self = m_new_ll_obj_with_finaliser(countio_counter_obj_t); self->base.type = &countio_counter_type; common_hal_countio_counter_construct(self, pin, edge, pull); @@ -134,6 +134,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_reset_obj, countio_counter_reset); STATIC const mp_rom_map_elem_t countio_counter_locals_dict_table[] = { // Methods { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&countio_counter_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&countio_counter_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&countio_counter___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&countio_counter_count_obj) }, diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 81edc48bfd..3510f11289 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -89,7 +89,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj, MP_QSTR_pin); // Make object long-lived to avoid moving between imports - pulseio_pulsein_obj_t *self = m_new_ll_obj(pulseio_pulsein_obj_t); + pulseio_pulsein_obj_t *self = m_new_ll_obj_with_finaliser(pulseio_pulsein_obj_t); self->base.type = &pulseio_pulsein_type; common_hal_pulseio_pulsein_construct(self, pin, args[ARG_maxlen].u_int, @@ -277,6 +277,7 @@ STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t va STATIC const mp_rom_map_elem_t pulseio_pulsein_locals_dict_table[] = { // Methods { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pulseio_pulsein_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&pulseio_pulsein_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&pulseio_pulsein___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&pulseio_pulsein_pause_obj) }, From b235b50647845f4eb624c70785b385943a4a2821 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 09:58:40 -0500 Subject: [PATCH 114/225] mimxrt: no longer need to collect the pin chainge interrupt ptrs .. the objects on the gc heap are guaranteed to be alive, as their finali(s/z)er will disable the interrupt. --- ports/mimxrt10xx/common-hal/microcontroller/Pin.c | 5 ----- ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c | 7 ++++++- ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h | 6 ------ ports/mimxrt10xx/supervisor/port.c | 4 ---- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index a5c491ee7d..f888152af1 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -119,8 +119,3 @@ void claim_pin(const mcu_pin_obj_t *pin) { void common_hal_mcu_pin_reset_number(uint8_t pin_no) { common_hal_reset_pin((mcu_pin_obj_t *)(mcu_pin_globals.map.table[pin_no].value)); } - -// The 'data' pointers may be to gc objects, they must be kept alive. -void pin_gc_collect() { - gc_collect_root((void **)&pcid, sizeof(pcid) / sizeof(void *)); -} diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c index 1f2d5321e9..d052711033 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c @@ -1,5 +1,10 @@ #include "peripherals/mimxrt10xx/pins.h" +typedef struct { + gpio_change_interrupt_t *func; + void *data; +} pin_change_interrupt_data; + /* Array of GPIO peripheral base address. */ static GPIO_Type *const s_gpioBases[] = GPIO_BASE_PTRS; static uint32_t GPIO_GetInstance(GPIO_Type *base) { @@ -23,7 +28,7 @@ static uint32_t GPIO_GetInstance(GPIO_Type *base) { static const IRQn_Type low_irqs[] = GPIO_COMBINED_LOW_IRQS; static const IRQn_Type high_irqs[] = GPIO_COMBINED_HIGH_IRQS; -volatile pin_change_interrupt_data pcid[MP_ARRAY_SIZE(s_gpioBases)][32]; +static volatile pin_change_interrupt_data pcid[MP_ARRAY_SIZE(s_gpioBases)][32]; void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data) { int instance = GPIO_GetInstance(pin->gpio); diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h index 76a8d03e08..0457a09a1a 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h @@ -73,12 +73,6 @@ typedef struct { } typedef void (gpio_change_interrupt_t)(void *data); -typedef struct { - gpio_change_interrupt_t *func; - void *data; -} pin_change_interrupt_data; -extern volatile pin_change_interrupt_data pcid[MP_ARRAY_SIZE((GPIO_Type *const[])GPIO_BASE_PTRS)][32]; - void disable_pin_change_interrupt(const mcu_pin_obj_t *pin); void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data); diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 1e46159829..55bf72352d 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -555,10 +555,6 @@ void port_idle_until_interrupt(void) { common_hal_mcu_enable_interrupts(); } -void port_gc_collect(void) { - pin_gc_collect(); -} - // Catch faults where the memory access violates MPU settings. void MemManage_Handler(void); __attribute__((used)) void PLACE_IN_ITCM(MemManage_Handler)(void) { From 1525672146d071a95766b1208ebe62c8e69858ce Mon Sep 17 00:00:00 2001 From: Jose David M Date: Thu, 23 Mar 2023 11:18:03 +0000 Subject: [PATCH 115/225] Translated using Weblate (Spanish) Currently translated at 100.0% (1004 of 1004 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/es.po b/locale/es.po index cf81206c3d..0201f7f78c 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-03-09 10:38+0000\n" +"PO-Revision-Date: 2023-03-23 17:26+0000\n" "Last-Translator: Jose David M \n" "Language-Team: \n" "Language: es\n" @@ -1292,7 +1292,7 @@ msgstr "BSSID inválido" #: main.c msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" -msgstr "" +msgstr "CIRCUITPY_PYSTACK_SIZE inválido\n" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" From da0df8a692b4a6d4d8f4b74f30a9c98e13cfedfa Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Wed, 22 Mar 2023 22:18:49 +0000 Subject: [PATCH 116/225] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1004 of 1004 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index bef3ea8849..c998d04270 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: 2023-03-08 07:10+0000\n" +"PO-Revision-Date: 2023-03-23 17:26+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -1288,7 +1288,7 @@ msgstr "BSSID Inválido" #: main.c msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" -msgstr "" +msgstr "CIRCUITPY_PYSTACK_SIZE inválido\n" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" From 24aea014752bd6de6d873025eb1b3354b3281984 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Thu, 23 Mar 2023 13:08:50 +0000 Subject: [PATCH 117/225] Translated using Weblate (Swedish) Currently translated at 100.0% (1004 of 1004 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 3c2c9f6520..66318a01b1 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: 2023-03-08 07:10+0000\n" +"PO-Revision-Date: 2023-03-23 17:26+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -1273,7 +1273,7 @@ msgstr "Ogiltig BSSID" #: main.c msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" -msgstr "" +msgstr "Ogiltig CIRCUITPY_PYSTACK_SIZE\n" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" From ff242e6198b486adf03c27f6f666c2c5708945ea Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Thu, 23 Mar 2023 18:26:38 +0100 Subject: [PATCH 118/225] 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 | 45 +++++++++++++++++----------------- locale/cs.po | 40 ++++++++++++++----------------- locale/de_DE.po | 52 ++++++++++++++++++++++------------------ locale/el.po | 37 ++++++++++++---------------- locale/en_GB.po | 48 +++++++++++++++++++------------------ locale/es.po | 52 ++++++++++++++++++++++------------------ locale/fil.po | 40 ++++++++++++++----------------- locale/fr.po | 52 ++++++++++++++++++++++------------------ locale/hi.po | 37 ++++++++++++---------------- locale/it_IT.po | 40 ++++++++++++++----------------- locale/ja.po | 48 +++++++++++++++++++------------------ locale/ko.po | 37 ++++++++++++---------------- locale/nl.po | 48 +++++++++++++++++++------------------ locale/pl.po | 48 +++++++++++++++++++------------------ locale/pt_BR.po | 52 ++++++++++++++++++++++------------------ locale/ru.po | 40 ++++++++++++++----------------- locale/sv.po | 52 ++++++++++++++++++++++------------------ locale/tr.po | 37 ++++++++++++---------------- locale/zh_Latn_pinyin.po | 52 ++++++++++++++++++++++------------------ 19 files changed, 428 insertions(+), 429 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index a136f6e498..0affac3ed4 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -183,10 +183,6 @@ msgstr "%q harus <= %d" msgid "%q must be >= %d" msgstr "%q harus >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -195,6 +191,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1233,7 +1233,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1531,10 +1532,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Tidak ada kunci yang ditentukan" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Tidak ada dukungan bilangan bulat yang panjang" @@ -1961,8 +1958,8 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Pindai sudah dalam proses. Hentikan dengan stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2274,6 +2271,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2309,11 +2311,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2768,7 +2765,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3068,8 +3065,8 @@ msgid "extra positional arguments given" msgstr "argumen posisi ekstra telah diberikan" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4143,10 +4140,6 @@ msgstr "" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4403,6 +4396,12 @@ msgstr "zi harus berjenis float" msgid "zi must be of shape (n_section, 2)" msgstr "Zi harus berbentuk (n_section, 2)" +#~ msgid "No key was specified" +#~ msgstr "Tidak ada kunci yang ditentukan" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Pindai sudah dalam proses. Hentikan dengan stop_scan." + #~ msgid "Supply at least one UART pin" #~ msgstr "Berikan setidaknya satu pin UART" diff --git a/locale/cs.po b/locale/cs.po index 1d666730ec..7af7d489b1 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -184,10 +184,6 @@ msgstr "%q musí být <= %d" msgid "%q must be >= %d" msgstr "%q musí být >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -196,6 +192,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1233,7 +1233,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1531,10 +1532,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Nebyl zadán klíč" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1950,7 +1947,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2263,6 +2260,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2298,11 +2300,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2755,7 +2752,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3055,8 +3052,8 @@ msgid "extra positional arguments given" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4129,10 +4126,6 @@ msgstr "" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4389,6 +4382,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "No key was specified" +#~ msgstr "Nebyl zadán klíč" + #~ msgid "%q pin invalid" #~ msgstr "pin %q není platný" diff --git a/locale/de_DE.po b/locale/de_DE.po index f6bc0b789e..fb676d621e 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -187,10 +187,6 @@ msgstr "%q muss <= %d sein" msgid "%q must be >= %d" msgstr "%q muss >= %d sein" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -200,6 +196,10 @@ msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" "%q muss ein Byte-Array oder ein array vom Typ 'h', 'H', 'b', oder 'B' sein" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1252,7 +1252,8 @@ msgstr "Der Interne WatchDog Timer ist abgelaufen." msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "Ungültiger %q" @@ -1551,10 +1552,6 @@ msgstr "Nicht in Programm" msgid "No in or out in program" msgstr "Kein Ein oder Aus in Programm" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Es wurde kein Schlüssel angegeben" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Keine langen Integer (long) unterstützt" @@ -1979,8 +1976,8 @@ msgstr "Maßstabs-Abmeßungen müssen durch 3 teilbar sein" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Scannen bereits in Bearbeitung. Stoppe mit stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2298,6 +2295,11 @@ msgstr "Unbekannter BLE-Fehler bei %s:%d: %d" msgid "Unknown BLE error: %d" msgstr "Unbekannter BLE-Fehler: %d" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2333,11 +2335,6 @@ msgstr "Unbekannter Systemfirmware Fehler: %04x" msgid "Unknown system firmware error: %d" msgstr "Unbekannter System-Firmware-Fehler: %d" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "Unbekannter Fehlercode %d" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2808,7 +2805,7 @@ msgstr "Kann Blockgröße von 512 nicht setzen" msgid "can't set attribute" msgstr "kann Attribut nicht setzen" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3116,8 +3113,8 @@ msgid "extra positional arguments given" msgstr "Es wurden zusätzliche Argumente ohne Schlüsselwort angegeben" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" @@ -4203,10 +4200,6 @@ msgstr "Zeitstempel außerhalb des Bereichs für Plattform time_t" msgid "tobytes can be invoked for dense arrays only" msgstr "tobytes kann nur für dichte Arrays aufgerufen werden" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "zu viele Argumente mit dem angegebenen Format" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "zu viele Dimensionen" @@ -4465,6 +4458,19 @@ msgstr "zi muss eine Gleitkommazahl sein" msgid "zi must be of shape (n_section, 2)" msgstr "zi muss die Form (n_section, 2) haben" +#~ msgid "No key was specified" +#~ msgstr "Es wurde kein Schlüssel angegeben" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Scannen bereits in Bearbeitung. Stoppe mit stop_scan." + +#, c-format +#~ msgid "Unkown error code %d" +#~ msgstr "Unbekannter Fehlercode %d" + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "zu viele Argumente mit dem angegebenen Format" + #~ msgid "" #~ "\n" #~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" diff --git a/locale/el.po b/locale/el.po index f2382feb94..ab4b2d9b90 100644 --- a/locale/el.po +++ b/locale/el.po @@ -188,10 +188,6 @@ msgstr "%q πρέπει να είναι <= %d" msgid "%q must be >= %d" msgstr "%q πρέπει να είναι >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -200,6 +196,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "%q πρέπει να είναι bytearray ή array τύπου 'h', 'H', 'b', ή 'B'" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1242,7 +1242,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1540,10 +1541,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1958,7 +1955,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2271,6 +2268,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2306,11 +2308,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2763,7 +2760,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3063,8 +3060,8 @@ msgid "extra positional arguments given" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4137,10 +4134,6 @@ msgstr "" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index 45131d1dcb..e2d9cd9f13 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -187,10 +187,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "%q must be >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -199,6 +195,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1234,7 +1234,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "Invalid %q" @@ -1532,10 +1533,6 @@ msgstr "No in in program" msgid "No in or out in program" msgstr "No in or out in program" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "No key was specified" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "No long integer support" @@ -1956,8 +1953,8 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2269,6 +2266,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2304,11 +2306,6 @@ msgstr "Unknown system firmware error: %04x" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2763,7 +2760,7 @@ msgstr "can't set 512 block size" msgid "can't set attribute" msgstr "can't set attribute" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3066,8 +3063,8 @@ msgid "extra positional arguments given" msgstr "extra positional arguments given" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "file must be a file opened in byte mode" @@ -4140,10 +4137,6 @@ msgstr "timestamp out of range for platform time_t" msgid "tobytes can be invoked for dense arrays only" msgstr "tobytes can be invoked for dense arrays only" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "too many arguments provided with the given format" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "too many dimensions" @@ -4400,6 +4393,15 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "No key was specified" +#~ msgstr "No key was specified" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Scan already in progess. Stop with stop_scan." + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "too many arguments provided with the given format" + #~ msgid "Supply at least one UART pin" #~ msgstr "Supply at least one UART pin" diff --git a/locale/es.po b/locale/es.po index 0201f7f78c..ebd1ea4a2b 100644 --- a/locale/es.po +++ b/locale/es.po @@ -195,10 +195,6 @@ msgstr "%q debe ser <= %d" msgid "%q must be >= %d" msgstr "%q debe ser >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "%q debe ser un arreglo de tipo 'H'" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "%q debe ser un bytearray o array de tipo 'H' o 'B'" @@ -207,6 +203,10 @@ msgstr "%q debe ser un bytearray o array de tipo 'H' o 'B'" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "%q debe ser un byte-matriz o matriz de tipo 'h', 'H', 'b', o 'B'" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "%q debe ser un arreglo de tipo 'H'" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1267,7 +1267,8 @@ msgstr "El temporizador interno watchdog terminó." msgid "Interrupt error." msgstr "Error de interrupción." -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "%q inválido" @@ -1569,10 +1570,6 @@ msgstr "No hay \"in\" en el programa" msgid "No in or out in program" msgstr "No hay \"in\" o \"out\" en el programa" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "No se especificó ninguna llave" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "No hay soporte de entero largo" @@ -2000,8 +1997,8 @@ msgstr "Las dimensiones de escala debe ser divisibles por 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Escaneo en progreso. Usa stop_scan para detener." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2320,6 +2317,11 @@ msgstr "Error BLE desconocido en %s:%d: %d" msgid "Unknown BLE error: %d" msgstr "Error BLE desconocido: %d" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2355,11 +2357,6 @@ msgstr "Error desconocido en el firmware sistema: %04x" msgid "Unknown system firmware error: %d" msgstr "Error del sistema de firmware desconocido: %d" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "Codigo de error desconocido: %d" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2823,7 +2820,7 @@ msgstr "no se puede definir un tamaño de bloque de 512" msgid "can't set attribute" msgstr "no se puede asignar el atributo" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "no se puede configurar el attributo '%q'" @@ -3131,8 +3128,8 @@ msgid "extra positional arguments given" msgstr "argumento posicional adicional dado" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "el archivo deberia ser una archivo abierto en modo byte" @@ -4213,10 +4210,6 @@ msgstr "timestamp fuera de rango para plataform time_t" msgid "tobytes can be invoked for dense arrays only" msgstr "tobytes solo pueden ser invocados por arrays densos" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "demasiados argumentos provistos con el formato dado" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "demasiadas dimensiones" @@ -4473,6 +4466,19 @@ 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 "No key was specified" +#~ msgstr "No se especificó ninguna llave" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Escaneo en progreso. Usa stop_scan para detener." + +#, c-format +#~ msgid "Unkown error code %d" +#~ msgstr "Codigo de error desconocido: %d" + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "demasiados argumentos provistos con el formato dado" + #~ msgid "" #~ "\n" #~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" diff --git a/locale/fil.po b/locale/fil.po index 591620e6c4..86677af69b 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -181,10 +181,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -193,6 +189,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1233,7 +1233,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1531,10 +1532,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1951,7 +1948,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2265,6 +2262,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2300,11 +2302,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2761,7 +2758,7 @@ msgstr "" msgid "can't set attribute" msgstr "hindi ma i-set ang attribute" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3069,8 +3066,8 @@ msgid "extra positional arguments given" msgstr "dagdag na positional argument na ibinigay" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "file ay dapat buksan sa byte mode" @@ -4150,10 +4147,6 @@ msgstr "wala sa sakop ng timestamp ang platform time_t" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "masyadong maraming mga argumento na ibinigay sa ibinigay na format" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4412,6 +4405,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "too many arguments provided with the given format" +#~ msgstr "masyadong maraming mga argumento na ibinigay sa ibinigay na format" + #~ msgid "Expected a %q" #~ msgstr "Umasa ng %q" diff --git a/locale/fr.po b/locale/fr.po index 4ebcc918bf..812f09b454 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -192,10 +192,6 @@ msgstr "%q doit être <= %d" msgid "%q must be >= %d" msgstr "%q doit être >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "%q doit être un bytearray ou matrice de type 'H' ou 'B'" @@ -204,6 +200,10 @@ msgstr "%q doit être un bytearray ou matrice de type 'H' ou 'B'" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "%q doit être a bytearray ou array de type 'h', 'H', 'b', ou 'B'" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1273,7 +1273,8 @@ msgstr "Le minuteur du watchdog interne a expiré." msgid "Interrupt error." msgstr "Erreur d'interruption." -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "%q invalide" @@ -1575,10 +1576,6 @@ msgstr "Programme n'a pas de \"in\"" msgid "No in or out in program" msgstr "Programme n'a aucun \"in\" ni \"out\"" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Aucune clé n'a été spécifiée" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Pas de support pour chiffre entier long" @@ -2006,8 +2003,8 @@ msgstr "La dimension d'échelle doit être un multiple de 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Scan déjà en cours. Arrêtez avec stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2326,6 +2323,11 @@ msgstr "Erreur BLE inconnue à %s:%d : %d" msgid "Unknown BLE error: %d" msgstr "Erreur BLE inconnue : %d" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2361,11 +2363,6 @@ msgstr "Faute inconnue du logiciel système : %04x" msgid "Unknown system firmware error: %d" msgstr "Erreur du logiciel système inconnue : %d" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "Erreur inconnue %d" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2833,7 +2830,7 @@ msgstr "impossible de définir une taille de bloc de 512" msgid "can't set attribute" msgstr "attribut non modifiable" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "attribut '%q' non modifiable" @@ -3145,8 +3142,8 @@ msgid "extra positional arguments given" msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "le fichier doit être un fichier ouvert en mode 'byte'" @@ -4232,10 +4229,6 @@ msgstr "timestamp hors bornes pour 'time_t' de la plateforme" msgid "tobytes can be invoked for dense arrays only" msgstr "tobytes ne peut être appelée que pour des matrices dense" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "trop d'arguments fournis avec ce format" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "Trop de dimensions" @@ -4492,6 +4485,19 @@ 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 "No key was specified" +#~ msgstr "Aucune clé n'a été spécifiée" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Scan déjà en cours. Arrêtez avec stop_scan." + +#, c-format +#~ msgid "Unkown error code %d" +#~ msgstr "Erreur inconnue %d" + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "trop d'arguments fournis avec ce format" + #~ msgid "" #~ "\n" #~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" diff --git a/locale/hi.po b/locale/hi.po index 2b9825e4b8..75efddc294 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -180,10 +180,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -192,6 +188,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1221,7 +1221,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1519,10 +1520,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1935,7 +1932,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2248,6 +2245,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2283,11 +2285,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2740,7 +2737,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3040,8 +3037,8 @@ msgid "extra positional arguments given" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4114,10 +4111,6 @@ msgstr "" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 84bc790df4..e8d32b163e 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -184,10 +184,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -196,6 +192,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1235,7 +1235,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1534,10 +1535,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1958,7 +1955,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2272,6 +2269,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2307,11 +2309,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2769,7 +2766,7 @@ msgstr "" msgid "can't set attribute" msgstr "impossibile impostare attributo" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3074,8 +3071,8 @@ msgid "extra positional arguments given" msgstr "argomenti posizonali extra dati" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4160,10 +4157,6 @@ msgstr "timestamp è fuori intervallo per il time_t della piattaforma" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "troppi argomenti forniti con il formato specificato" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4422,6 +4415,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "too many arguments provided with the given format" +#~ msgstr "troppi argomenti forniti con il formato specificato" + #~ msgid "%q pin invalid" #~ msgstr "%q pin non valido" diff --git a/locale/ja.po b/locale/ja.po index 081dd57e9f..f90abd66da 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -187,10 +187,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -199,6 +195,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1234,7 +1234,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "不正な %q" @@ -1532,10 +1533,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "キーが指定されていません" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "long integerに対応していません" @@ -1951,8 +1948,8 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "既にスキャン進行中。stop_scanで停止してください" +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2265,6 +2262,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2300,11 +2302,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2757,7 +2754,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3061,8 +3058,8 @@ msgid "extra positional arguments given" msgstr "余分な位置引数が与えられました" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "fileはバイトモードで開かれたファイルでなければなりません" @@ -4138,10 +4135,6 @@ msgstr "timestampがプラットフォームのtime_tの範囲外" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "指定された書式に対して引数が多すぎます" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4398,6 +4391,15 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "No key was specified" +#~ msgstr "キーが指定されていません" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "既にスキャン進行中。stop_scanで停止してください" + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "指定された書式に対して引数が多すぎます" + #~ msgid "Supply at least one UART pin" #~ msgstr "少なくとも1つのUARTピンが必要" diff --git a/locale/ko.po b/locale/ko.po index 7668d8c8a3..fbb45ed195 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -181,10 +181,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -193,6 +189,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1224,7 +1224,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "" @@ -1522,10 +1523,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1938,7 +1935,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2252,6 +2249,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2287,11 +2289,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2744,7 +2741,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3044,8 +3041,8 @@ msgid "extra positional arguments given" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4118,10 +4115,6 @@ msgstr "" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 61c96a877d..f9faf2a6a5 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -180,10 +180,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -192,6 +188,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1229,7 +1229,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "Ongeldige %q" @@ -1527,10 +1528,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Een sleutel was niet gespecificeerd" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Geen lange integer ondersteuning" @@ -1956,8 +1953,8 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Scan wordt al uitvoerd. Stop met stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2269,6 +2266,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2304,11 +2306,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2768,7 +2765,7 @@ msgstr "kan geen 512 blokgrootte instellen" msgid "can't set attribute" msgstr "kan attribute niet instellen" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3070,8 +3067,8 @@ msgid "extra positional arguments given" msgstr "extra positionele argumenten gegeven" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "bestand moet een bestand zijn geopend in byte modus" @@ -4148,10 +4145,6 @@ msgstr "timestamp buiten bereik voor platform time_t" msgid "tobytes can be invoked for dense arrays only" msgstr "tobytes kunnen alleen ingeroepen worden voor gesloten arrays" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "te veel argumenten opgegeven bij dit formaat" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4408,6 +4401,15 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "No key was specified" +#~ msgstr "Een sleutel was niet gespecificeerd" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Scan wordt al uitvoerd. Stop met stop_scan." + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "te veel argumenten opgegeven bij dit formaat" + #~ msgid "Supply at least one UART pin" #~ msgstr "Geef op zijn minst 1 UART pin op" diff --git a/locale/pl.po b/locale/pl.po index 642e5f99de..4fc4337a55 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -182,10 +182,6 @@ msgstr "" msgid "%q must be >= %d" msgstr "" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "" @@ -194,6 +190,10 @@ msgstr "" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1229,7 +1229,8 @@ msgstr "" msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "Nieprawidłowe %q" @@ -1527,10 +1528,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Nie określono klucza" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1943,8 +1940,8 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Skanuj już w toku. Zatrzymaj za pomocą stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2256,6 +2253,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2291,11 +2293,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2748,7 +2745,7 @@ msgstr "" msgid "can't set attribute" msgstr "nie można ustawić atrybutu" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3049,8 +3046,8 @@ msgid "extra positional arguments given" msgstr "nadmiarowe argumenty pozycyjne" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "file musi być otwarte w trybie bajtowym" @@ -4124,10 +4121,6 @@ msgstr "timestamp poza zakresem dla time_t na tej platformie" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "zbyt wiele argumentów podanych dla tego formatu" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4384,6 +4377,15 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "No key was specified" +#~ msgstr "Nie określono klucza" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Skanuj już w toku. Zatrzymaj za pomocą stop_scan." + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "zbyt wiele argumentów podanych dla tego formatu" + #~ msgid "Supply at least one UART pin" #~ msgstr "Podaj co najmniej jeden pin UART" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index c998d04270..88ccd57c4e 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -193,10 +193,6 @@ msgstr "%q deve ser <= %d" msgid "%q must be >= %d" msgstr "o %q deve ser >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "%q deve ser uma matriz do tipo 'H'" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "%q deve ser um bytearray ou uma matriz do tipo 'H' ou 'B'" @@ -205,6 +201,10 @@ msgstr "%q deve ser um bytearray ou uma matriz do tipo 'H' ou 'B'" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "%q deve ser um bytearray ou uma matriz do tipo 'h', 'H', 'b', ou 'B'" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "%q deve ser uma matriz do tipo 'H'" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1263,7 +1263,8 @@ msgstr "O temporizador do watchdog interno expirou." msgid "Interrupt error." msgstr "Erro de interrupção." -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "%q Inválido" @@ -1561,10 +1562,6 @@ msgstr "Sem entrada no programa" msgid "No in or out in program" msgstr "Sem entrada ou saída no programa" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Nenhuma chave foi definida" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Não há compatibilidade com inteiro longo" @@ -1994,8 +1991,8 @@ msgstr "As dimensões da escala devem ser poder ser divididas por 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "O escaneamento já está em andamento. Interrompa com stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2314,6 +2311,11 @@ msgstr "Houve um erro BLE desconhecido em %s:%d: %d" msgid "Unknown BLE error: %d" msgstr "Houve um erro BLE desconhecido: %d" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2349,11 +2351,6 @@ msgstr "Erro desconhecido do firmware: %04x" msgid "Unknown system firmware error: %d" msgstr "Ocorreu um erro desconhecido no firmware do sistema: %d" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "Código de erro desconhecido %d" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2819,7 +2816,7 @@ msgstr "não é possível definir o tamanho de 512 blocos" msgid "can't set attribute" msgstr "não é possível definir o atributo" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "não é possível definir o atributo '%q'" @@ -3128,8 +3125,8 @@ msgid "extra positional arguments given" msgstr "argumentos extra posicionais passados" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "o arquivo deve ser um arquivo aberto no modo byte" @@ -4213,10 +4210,6 @@ msgstr "timestamp fora do intervalo para a plataforma time_t" msgid "tobytes can be invoked for dense arrays only" msgstr "os tobytes podem ser invocados apenas nas matrizes densas" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "Muitos argumentos fornecidos com o formato dado" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "dimensões demais" @@ -4473,6 +4466,19 @@ 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 "No key was specified" +#~ msgstr "Nenhuma chave foi definida" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "O escaneamento já está em andamento. Interrompa com stop_scan." + +#, c-format +#~ msgid "Unkown error code %d" +#~ msgstr "Código de erro desconhecido %d" + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "Muitos argumentos fornecidos com o formato dado" + #~ msgid "" #~ "\n" #~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" diff --git a/locale/ru.po b/locale/ru.po index 2ad4b094a2..c2e6ccc265 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -187,10 +187,6 @@ msgstr "%q должно быть <= %d" msgid "%q must be >= %d" msgstr "%q должно быть >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "%q должно быть bytearray или array типа 'H' или 'B'" @@ -199,6 +195,10 @@ msgstr "%q должно быть bytearray или array типа 'H' или 'B'" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "%q должно быть bytearray или array типа 'h', 'H', 'b', или 'B'" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1266,7 +1266,8 @@ msgstr "Внутренний сторожевой таймер истек." msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "Недопустимый %q" @@ -1567,10 +1568,6 @@ msgstr "Нет in в программе" msgid "No in or out in program" msgstr "В программе отсутствует ввод или вывод" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Ключ не был указан" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Нет поддержки длинных целых чисел (long integer)" @@ -1996,7 +1993,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2311,6 +2308,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2346,11 +2348,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2803,7 +2800,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3103,8 +3100,8 @@ msgid "extra positional arguments given" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4177,10 +4174,6 @@ msgstr "" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4437,6 +4430,9 @@ msgstr "zi должно быть типа float" msgid "zi must be of shape (n_section, 2)" msgstr "zi должен иметь форму (n_section, 2)" +#~ msgid "No key was specified" +#~ msgstr "Ключ не был указан" + #~ msgid "Supply at least one UART pin" #~ msgstr "Предоставьте хотяб один пин UART" diff --git a/locale/sv.po b/locale/sv.po index 66318a01b1..da13d25599 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -192,10 +192,6 @@ msgstr "%q måste vara <= %d" msgid "%q must be >= %d" msgstr "%q måste vara >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "%q måste vara en array av typen 'H'" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "%q måste vara en bytearray eller array av typen 'H' eller 'B'" @@ -206,6 +202,10 @@ msgstr "" "%q måste vara en bytearray eller en array av typen \"h\", \"H\", \"b\" eller " "\"B\"" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "%q måste vara en array av typen 'H'" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1248,7 +1248,8 @@ msgstr "Intern watchdog-timer har löpt ut." msgid "Interrupt error." msgstr "Interrupt-fel." -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "Ogiltig %q" @@ -1547,10 +1548,6 @@ msgstr "Inget in i programmet" msgid "No in or out in program" msgstr "Inget in eller ut i programmet" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Ingen nyckel angavs" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Inget stöd för långt heltal" @@ -1975,8 +1972,8 @@ msgstr "Skaldimension måste vara delbar med 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Skanning pågår redan. Avsluta med stop_scan." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2290,6 +2287,11 @@ msgstr "Okänt BLE-fel vid %s:%d: %d" msgid "Unknown BLE error: %d" msgstr "Okänt BLE-fel: %d" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2325,11 +2327,6 @@ msgstr "Okänt systemfirmwarefel: %04x" msgid "Unknown system firmware error: %d" msgstr "Okänt fel i systemets firmware: %d" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "Okänd felkod %d" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2790,7 +2787,7 @@ msgstr "kan inte sätta blockstorlek 512" msgid "can't set attribute" msgstr "kan inte att ange attribut" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "kan inte sätta attribut '%q'" @@ -3097,8 +3094,8 @@ msgid "extra positional arguments given" msgstr "extra positions-argument angivna" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "filen måste vara en fil som öppnats i byte-läge" @@ -4175,10 +4172,6 @@ msgstr "timestamp utom räckvidd för plattformens \"time_t\"" msgid "tobytes can be invoked for dense arrays only" msgstr "tobyte kan enbart anropas för täta matriser" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "för många argument för det givna formatet" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "för många dimensioner" @@ -4435,6 +4428,19 @@ 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 "No key was specified" +#~ msgstr "Ingen nyckel angavs" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Skanning pågår redan. Avsluta med stop_scan." + +#, c-format +#~ msgid "Unkown error code %d" +#~ msgstr "Okänd felkod %d" + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "för många argument för det givna formatet" + #~ msgid "" #~ "\n" #~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" diff --git a/locale/tr.po b/locale/tr.po index bd9d746940..62c5fc9dc2 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -188,10 +188,6 @@ msgstr "%q <= %d olmalıdır" msgid "%q must be >= %d" msgstr "%q >= %d olmalıdır" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "%q 'H' ya da 'B' tipi bir bytearray ya da array olmalıdır" @@ -200,6 +196,10 @@ msgstr "%q 'H' ya da 'B' tipi bir bytearray ya da array olmalıdır" msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "%q 'h', 'H', 'b' ya da 'B' tipi bir bytearray ya da array olmalı" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1239,7 +1239,8 @@ msgstr "Dahili bekçi zamanlayıcısının süresi doldu." msgid "Interrupt error." msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "Geçersiz %q" @@ -1538,10 +1539,6 @@ msgstr "" msgid "No in or out in program" msgstr "" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "" @@ -1957,7 +1954,7 @@ msgstr "" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." +msgid "Scan already in progress. Stop with stop_scan." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -2270,6 +2267,11 @@ msgstr "" msgid "Unknown BLE error: %d" msgstr "" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2305,11 +2307,6 @@ msgstr "" msgid "Unknown system firmware error: %d" msgstr "" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2762,7 +2759,7 @@ msgstr "" msgid "can't set attribute" msgstr "" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "" @@ -3062,8 +3059,8 @@ msgid "extra positional arguments given" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4136,10 +4133,6 @@ msgstr "" msgid "tobytes can be invoked for dense arrays only" msgstr "" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 72df0f5aed..98876f3cdb 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -195,10 +195,6 @@ msgstr "%q bìxū <= %d" msgid "%q must be >= %d" msgstr "%q bìxū >= %d" -#: ports/espressif/common-hal/analogbufio/BufferedIn.c -msgid "%q must be array of type 'H'" -msgstr "%q bì xū shì lèi xíng wéi 'H' de shù zǔ" - #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" msgstr "%q bì xū shì zì jié shù zǔ huò lèi xíng wéi 'H' huò 'B' de shù zǔ" @@ -208,6 +204,10 @@ msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" msgstr "" "%q bì xū shì zì jié shù zǔ huò lèi xíng wéi 'h', 'H', 'b', huò 'B' de shù zǔ" +#: ports/espressif/common-hal/analogbufio/BufferedIn.c +msgid "%q must be array of type 'H'" +msgstr "%q bì xū shì lèi xíng wéi 'H' de shù zǔ" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1255,7 +1255,8 @@ msgstr "Nèibù kān mén gǒu dìngshí qì chāoshí." msgid "Interrupt error." msgstr "zhōng duàn cuò wù." -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c +#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c msgid "Invalid %q" msgstr "wú xiào %q" @@ -1554,10 +1555,6 @@ msgstr "chéng xù zhōng méi yǒu" msgid "No in or out in program" msgstr "chéng xù zhōng méi yǒu jìn chū" -#: shared-bindings/aesio/aes.c -msgid "No key was specified" -msgstr "Wèi zhǐdìng mì yào" - #: shared-bindings/time/__init__.c msgid "No long integer support" msgstr "Méiyǒu zhǎng zhěngshù zhīchí" @@ -1980,8 +1977,8 @@ msgstr "bǐ lì chǐ cùn bì xū chú yǐ 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c -msgid "Scan already in progess. Stop with stop_scan." -msgstr "Zhèngzài jìn háng sǎomiáo. Shǐyòng stop_scan tíngzhǐ." +msgid "Scan already in progress. Stop with stop_scan." +msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2295,6 +2292,11 @@ msgstr "%s:%d: %d chù chū xiàn wèi zhī BLE cuò wù" msgid "Unknown BLE error: %d" msgstr "wèi zhī de BLE cuò wù: %d" +#: ports/raspberrypi/common-hal/wifi/__init__.c +#, c-format +msgid "Unknown error code %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2330,11 +2332,6 @@ msgstr "wèi zhī xì tǒng gù jiàn cuò wù: %04x" msgid "Unknown system firmware error: %d" msgstr "wèi zhī de xì tǒng gù jiàn cuò wù: %d" -#: ports/raspberrypi/common-hal/wifi/__init__.c -#, c-format -msgid "Unkown error code %d" -msgstr "wèi zhī cuò wù dài %d" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #: shared-module/_pixelmap/PixelMap.c #, c-format @@ -2795,7 +2792,7 @@ msgstr "wúfǎ shèzhì 512 kuài dàxiǎo" msgid "can't set attribute" msgstr "wúfǎ shèzhì shǔxìng" -#: py/runtime.c +#: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" msgstr "wú fǎ shè zhì shǔ xìng '%q'" @@ -3103,8 +3100,8 @@ msgid "extra positional arguments given" msgstr "gěi chūle éwài de wèizhì cānshù" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c -#: shared-module/gifio/GifWriter.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c +#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "wénjiàn bìxū shì zài zì jié móshì xià dǎkāi de wénjiàn" @@ -4181,10 +4178,6 @@ msgstr "time_t shíjiān chuō chāochū píngtái fànwéi" msgid "tobytes can be invoked for dense arrays only" msgstr "tobytes zhǐ néng duì mì jí shù zǔ diào yòng" -#: shared-module/struct/__init__.c -msgid "too many arguments provided with the given format" -msgstr "tígōng jǐ dìng géshì de cānshù tài duō" - #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "chǐ cùn tài duō" @@ -4441,6 +4434,19 @@ 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 "No key was specified" +#~ msgstr "Wèi zhǐdìng mì yào" + +#~ msgid "Scan already in progess. Stop with stop_scan." +#~ msgstr "Zhèngzài jìn háng sǎomiáo. Shǐyòng stop_scan tíngzhǐ." + +#, c-format +#~ msgid "Unkown error code %d" +#~ msgstr "wèi zhī cuò wù dài %d" + +#~ msgid "too many arguments provided with the given format" +#~ msgstr "tígōng jǐ dìng géshì de cānshù tài duō" + #~ msgid "" #~ "\n" #~ "Invalid CIRCUITPY_PYSTACK_SIZE\n" From e2565e2305df87c12f115514d66634ba9bfdfd60 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 14:00:14 -0500 Subject: [PATCH 119/225] mimxrt10xx: Add PWMAudioOut .. via a peripheral known as the "MQS" (medium quality sound). It uses an ~192kHz PWM signal to generate audio. It sounds OK on a small speaker with no amplifier. There's a small pop when starting/stopping audio, as is typical. --- .../mimxrt10xx/common-hal/audiobusio/I2SOut.h | 4 +- .../common-hal/audiobusio/__init__.c | 1 + .../common-hal/audiopwmio/PWMAudioOut.c | 159 ++++++++++++++++++ .../common-hal/audiopwmio/PWMAudioOut.h | 43 +++++ .../common-hal/audiopwmio/__init__.c | 0 .../common-hal/audiopwmio/__init__.h | 0 ports/mimxrt10xx/mpconfigport.mk | 1 + .../mimxrt10xx/MIMXRT1011/periph.c | 18 +- .../mimxrt10xx/MIMXRT1011/periph.h | 3 + .../mimxrt10xx/MIMXRT1021/periph.c | 10 ++ .../mimxrt10xx/MIMXRT1021/periph.h | 3 + .../mimxrt10xx/MIMXRT1062/periph.c | 10 ++ .../mimxrt10xx/MIMXRT1062/periph.h | 3 + 13 files changed, 246 insertions(+), 9 deletions(-) create mode 100644 ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c create mode 100644 ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h create mode 100644 ports/mimxrt10xx/common-hal/audiopwmio/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/audiopwmio/__init__.h diff --git a/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h index c4194402be..2473eb4cab 100644 --- a/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h +++ b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h @@ -26,15 +26,13 @@ #pragma once +#if CIRCUITPY_AUDIOBUSIO_I2SOUT #include "supervisor/background_callback.h" #include "common-hal/microcontroller/Pin.h" #include "common-hal/audiobusio/__init__.h" // Some boards don't implement I2SOut, so suppress any routines from here. -#if CIRCUITPY_AUDIOBUSIO_I2SOUT - -#include "sdk/drivers/sai/fsl_sai.h" typedef struct { mp_obj_base_t base; diff --git a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c index 515c39a268..f2de99f004 100644 --- a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c +++ b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c @@ -284,6 +284,7 @@ static void i2s_fill_buffer(i2s_t *self) { static void i2s_callback_fun(void *self_in) { i2s_t *self = self_in; + mp_printf(&mp_plat_print, "."); i2s_fill_buffer(self); } diff --git a/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c new file mode 100644 index 0000000000..dd50c7950a --- /dev/null +++ b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c @@ -0,0 +1,159 @@ +/* + * This file is part of the MicroPython 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. + */ + +#include +#include + +#include "mpconfigport.h" + +#include "py/gc.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "common-hal/audiobusio/__init__.h" +#include "common-hal/audiopwmio/PWMAudioOut.h" +#include "shared-bindings/audiopwmio/PWMAudioOut.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate/translate.h" +#include "supervisor/shared/tick.h" + +// Where required we use identifier names that are required by NXP's +// API, even though they do not conform to the naming standards that Adafruit +// strives to adhere to. https://www.adafruit.com/blacklivesmatter +#include "sdk/drivers/sai/fsl_sai.h" + +STATIC void config_periph_pin(const mcu_periph_obj_t *periph) { + if (!periph) { + return; + } + if (periph->pin->mux_reg) { + IOMUXC_SetPinMux( + periph->pin->mux_reg, periph->mux_mode, + periph->input_reg, periph->input_idx, + 0, + 1); + } + + IOMUXC_SetPinConfig(0, 0, 0, 0, + periph->pin->cfg_reg, + IOMUXC_SW_PAD_CTL_PAD_HYS(0) + | IOMUXC_SW_PAD_CTL_PAD_PUS(0) + | IOMUXC_SW_PAD_CTL_PAD_PUE(0) + | IOMUXC_SW_PAD_CTL_PAD_PKE(1) + | IOMUXC_SW_PAD_CTL_PAD_ODE(0) + | IOMUXC_SW_PAD_CTL_PAD_SPEED(2) + | IOMUXC_SW_PAD_CTL_PAD_DSE(4) + | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); +} + +static void config_mqs(void) { + CCM->CCGR0 = (CCM->CCGR0 & (~CCM_CCGR0_CG2_MASK)) | CCM_CCGR0_CG2(3); /* Enable MQS hmclk. */ + + IOMUXC_MQSEnterSoftwareReset(IOMUXC_GPR, true); /* Reset MQS. */ + IOMUXC_MQSEnterSoftwareReset(IOMUXC_GPR, false); /* Release reset MQS. */ + IOMUXC_MQSEnable(IOMUXC_GPR, true); /* Enable MQS. */ + IOMUXC_MQSConfig(IOMUXC_GPR, kIOMUXC_MqsPwmOverSampleRate64, 0u); /* 98.304MHz/64/(0+1) = 1.536MHz + Higher frequency PWM involves less low frequen cy harmonic.*/ + +} + +// Caller validates that pins are free. +void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *self, + const mcu_pin_obj_t *left_channel, const mcu_pin_obj_t *right_channel, uint16_t default_value) { + + int instance = -1; + const mcu_periph_obj_t *left_periph = find_pin_function(mcu_mqs_left_list, left_channel, &instance, MP_QSTR_left_channel); + const mcu_periph_obj_t *right_periph = find_pin_function(mcu_mqs_right_list, right_channel, &instance, MP_QSTR_right_channel); + + mp_printf(&mp_plat_print, "note: peripheral %d\n", instance); + sai_transceiver_t config; + SAI_GetClassicI2SConfig(&config, kSAI_WordWidth16bits, kSAI_Stereo, 1U << 0u); + config.frameSync.frameSyncEarly = false; + config.frameSync.frameSyncPolarity = kSAI_PolarityActiveHigh; + // config.syncMode = kSAI_ModeAsync; + config.fifo.fifoPacking = kSAI_FifoPackingDisabled; + // These identifier names are required by NXP's API, even though they do + // not conform to the naming standards that Adafruit strives to adhere to. + // https://www.adafruit.com/blacklivesmatter + // config.masterSlave = kSAI_Master; + port_i2s_initialize(&self->i2s, instance, &config); + + self->left_channel = left_channel; + self->right_channel = right_channel; + claim_pin(left_channel); + claim_pin(right_channel); + config_periph_pin(left_periph); + config_periph_pin(right_periph); + config_mqs(); +} + +bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t *self) { + return port_i2s_deinited(&self->i2s); +} + +void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self) { + if (common_hal_audiopwmio_pwmaudioout_deinited(self)) { + return; + } + + port_i2s_deinit(&self->i2s); + + common_hal_reset_pin(self->left_channel); + self->left_channel = NULL; + + common_hal_reset_pin(self->right_channel); + self->right_channel = NULL; + + IOMUXC_MQSEnterSoftwareReset(IOMUXC_GPR, true); /* Reset MQS. */ + CCM->CCGR0 = CCM->CCGR0 & (~CCM_CCGR0_CG2_MASK); /* Disable MQS hmclk. */ +} + +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); + } + port_i2s_play(&self->i2s, sample, loop); +} + +void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t *self) { + port_i2s_pause(&self->i2s); +} + +void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t *self) { + port_i2s_resume(&self->i2s); +} + +bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t *self) { + return port_i2s_get_paused(&self->i2s); +} + +void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t *self) { + port_i2s_stop(&self->i2s); +} + +bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t *self) { + return port_i2s_get_playing(&self->i2s); +} diff --git a/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h new file mode 100644 index 0000000000..27cebc649b --- /dev/null +++ b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython 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. + */ + +#pragma once + +#if CIRCUITPY_AUDIOBUSIO_I2SOUT +#include "supervisor/background_callback.h" +#include "common-hal/microcontroller/Pin.h" + +#include "common-hal/audiobusio/__init__.h" + +// Some boards don't implement I2SOut, so suppress any routines from here. + +typedef struct { + mp_obj_base_t base; + i2s_t i2s; + const mcu_pin_obj_t *left_channel, *right_channel; +} audiopwmio_pwmaudioout_obj_t; + +#endif diff --git a/ports/mimxrt10xx/common-hal/audiopwmio/__init__.c b/ports/mimxrt10xx/common-hal/audiopwmio/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/mimxrt10xx/common-hal/audiopwmio/__init__.h b/ports/mimxrt10xx/common-hal/audiopwmio/__init__.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index a952460259..f7ab3d8130 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -17,6 +17,7 @@ CIRCUITPY_AUDIOCORE = 1 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_AUDIOMP3 = 1 +CIRCUITPY_AUDIOPWMIO = 1 CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c index fbbf65c8a5..b67f7b1179 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c @@ -169,25 +169,31 @@ const mcu_pwm_obj_t mcu_pwm_list[20] = { const mcu_periph_obj_t mcu_sai_rx_bclk_list[] = { PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_08), - PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_00), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_00), }; const mcu_periph_obj_t mcu_sai_rx_data0_list[] = { PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_03), - PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_03), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_SD_03), }; const mcu_periph_obj_t mcu_sai_rx_sync_list[] = { PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_02), - PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_04), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_SD_04), }; const mcu_periph_obj_t mcu_sai_tx_bclk_list[] = { PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_06), - PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_01), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_SD_01), }; const mcu_periph_obj_t mcu_sai_tx_data0_list[] = { PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_04), - PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_02), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_SD_02), }; const mcu_periph_obj_t mcu_sai_tx_sync_list[] = { PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_07), - PERIPH_PIN(2, 1, 0, 0, &pin_GPIO_SD_00), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_SD_00), +}; +const mcu_periph_obj_t mcu_mqs_left_list[] = { + PERIPH_PIN(3, 4, 0, 0, &pin_GPIO_AD_01), +}; +const mcu_periph_obj_t mcu_mqs_right_list[] = { + PERIPH_PIN(3, 4, 0, 0, &pin_GPIO_AD_02), }; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h index 109717528f..045e33ca0e 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h @@ -54,4 +54,7 @@ extern const mcu_periph_obj_t mcu_sai_tx_bclk_list[2]; extern const mcu_periph_obj_t mcu_sai_tx_data0_list[2]; extern const mcu_periph_obj_t mcu_sai_tx_sync_list[2]; +extern const mcu_periph_obj_t mcu_mqs_left_list[1]; +extern const mcu_periph_obj_t mcu_mqs_right_list[1]; + #endif // MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1011_PERIPHERALS_MIMXRT1011_PERIPH_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c index b80fcf5065..59bd3cc105 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c @@ -311,3 +311,13 @@ const mcu_periph_obj_t mcu_sai_tx_sync_list[] = { PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_34), PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_07), }; +const mcu_periph_obj_t mcu_mqs_left_list[] = { + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_07), + PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_EMC_17), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_38), +}; +const mcu_periph_obj_t mcu_mqs_right_list[] = { + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_06), + PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_EMC_16), + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_37), +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h index 31ac10e651..51c97b3eef 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h @@ -53,3 +53,6 @@ extern const mcu_periph_obj_t mcu_sai_rx_sync_list[7]; extern const mcu_periph_obj_t mcu_sai_tx_bclk_list[7]; extern const mcu_periph_obj_t mcu_sai_tx_data0_list[7]; extern const mcu_periph_obj_t mcu_sai_tx_sync_list[7]; + +extern const mcu_periph_obj_t mcu_mqs_left_list[3]; +extern const mcu_periph_obj_t mcu_mqs_right_list[3]; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c index 8c038bdb71..c43f4eb96b 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c @@ -362,3 +362,13 @@ const mcu_periph_obj_t mcu_sai_tx_sync_list[] = { PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_39), PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_02), }; +const mcu_periph_obj_t mcu_mqs_left_list[] = { + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_14), + PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_B0_01), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_05), +}; +const mcu_periph_obj_t mcu_mqs_right_list[] = { + PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_13), + PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_B0_00), + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_04), +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h index ab8eb22678..28ea8e3742 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h @@ -54,4 +54,7 @@ extern const mcu_periph_obj_t mcu_sai_tx_bclk_list[7]; extern const mcu_periph_obj_t mcu_sai_tx_data0_list[7]; extern const mcu_periph_obj_t mcu_sai_tx_sync_list[7]; +extern const mcu_periph_obj_t mcu_mqs_left_list[3]; +extern const mcu_periph_obj_t mcu_mqs_right_list[3]; + #endif // MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1062_PERIPHERALS_MIMXRT1011_PERIPH_H From e1c8a3062a0c5000162ff8730dcb28dc2637a78c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 21:06:53 -0500 Subject: [PATCH 120/225] remove debugging print --- ports/mimxrt10xx/common-hal/audiobusio/__init__.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c index f2de99f004..515c39a268 100644 --- a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c +++ b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c @@ -284,7 +284,6 @@ static void i2s_fill_buffer(i2s_t *self) { static void i2s_callback_fun(void *self_in) { i2s_t *self = self_in; - mp_printf(&mp_plat_print, "."); i2s_fill_buffer(self); } From 0c0e06c940848e9bf26642272e5bb2eb0fa1352a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 21:10:04 -0500 Subject: [PATCH 121/225] remove comment that was copypasted --- ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h index 27cebc649b..b9e4279927 100644 --- a/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h +++ b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.h @@ -32,8 +32,6 @@ #include "common-hal/audiobusio/__init__.h" -// Some boards don't implement I2SOut, so suppress any routines from here. - typedef struct { mp_obj_base_t base; i2s_t i2s; From b1d9331367b4717996cf4c353a18212491dcfa5b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Mar 2023 21:11:05 -0500 Subject: [PATCH 122/225] move comment next to its associated #if --- ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h index 2473eb4cab..319e52c159 100644 --- a/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h +++ b/ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h @@ -26,14 +26,13 @@ #pragma once +// Some boards don't implement I2SOut, so suppress any routines from here. #if CIRCUITPY_AUDIOBUSIO_I2SOUT #include "supervisor/background_callback.h" #include "common-hal/microcontroller/Pin.h" #include "common-hal/audiobusio/__init__.h" -// Some boards don't implement I2SOut, so suppress any routines from here. - typedef struct { mp_obj_base_t base; i2s_t i2s; From c5a6fd97b0bd602ec6d057683fb253f7418b9f18 Mon Sep 17 00:00:00 2001 From: Ozgur BOSTAN <79173593+ozgurbostan@users.noreply.github.com> Date: Fri, 24 Mar 2023 09:43:49 +0300 Subject: [PATCH 123/225] Update sdkconfig Add missing new line --- ports/espressif/boards/deneyap_kart/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/deneyap_kart/sdkconfig b/ports/espressif/boards/deneyap_kart/sdkconfig index c98c5de68d..7ec0461dcf 100644 --- a/ports/espressif/boards/deneyap_kart/sdkconfig +++ b/ports/espressif/boards/deneyap_kart/sdkconfig @@ -16,4 +16,4 @@ CONFIG_SPIRAM_USE_MEMMAP=y CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set # CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY is not set -CONFIG_SPIRAM_CACHE_WORKAROUND=y \ No newline at end of file +CONFIG_SPIRAM_CACHE_WORKAROUND=y From 8814e0f4f7660be9a17b8acd836be19e545dfbf7 Mon Sep 17 00:00:00 2001 From: Ozgur BOSTAN <79173593+ozgurbostan@users.noreply.github.com> Date: Fri, 24 Mar 2023 15:34:17 +0300 Subject: [PATCH 124/225] Update sdkconfig Add missing new line --- ports/espressif/boards/deneyap_kart_1a/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/deneyap_kart_1a/sdkconfig b/ports/espressif/boards/deneyap_kart_1a/sdkconfig index c98c5de68d..7ec0461dcf 100644 --- a/ports/espressif/boards/deneyap_kart_1a/sdkconfig +++ b/ports/espressif/boards/deneyap_kart_1a/sdkconfig @@ -16,4 +16,4 @@ CONFIG_SPIRAM_USE_MEMMAP=y CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set # CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY is not set -CONFIG_SPIRAM_CACHE_WORKAROUND=y \ No newline at end of file +CONFIG_SPIRAM_CACHE_WORKAROUND=y From a2b2158bcbb1a4031fb47bca8dedf4c07b11a133 Mon Sep 17 00:00:00 2001 From: Jose David M Date: Thu, 23 Mar 2023 20:35:44 +0000 Subject: [PATCH 125/225] Translated using Weblate (Spanish) Currently translated at 100.0% (1002 of 1002 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 ebd1ea4a2b..9578e4048a 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-03-23 17:26+0000\n" +"PO-Revision-Date: 2023-03-25 02:42+0000\n" "Last-Translator: Jose David M \n" "Language-Team: \n" "Language: es\n" @@ -16,7 +16,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.16.2-dev\n" +"X-Generator: Weblate 4.17-dev\n" #: main.c msgid "" @@ -1998,7 +1998,7 @@ msgstr "Las dimensiones de escala debe ser divisibles por 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progress. Stop with stop_scan." -msgstr "" +msgstr "Escaneo en progreso. Usa stop_scan para detenerlo." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2320,7 +2320,7 @@ msgstr "Error BLE desconocido: %d" #: ports/raspberrypi/common-hal/wifi/__init__.c #, c-format msgid "Unknown error code %d" -msgstr "" +msgstr "Código de error desconocido %d" #: shared-bindings/wifi/Radio.c #, c-format From 277edddf2a8c9e50b559dbd9088a536e88568241 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Fri, 24 Mar 2023 02:02:08 +0000 Subject: [PATCH 126/225] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1002 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 88ccd57c4e..a684aacfb1 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: 2023-03-23 17:26+0000\n" +"PO-Revision-Date: 2023-03-25 02:42+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.16.2-dev\n" +"X-Generator: Weblate 4.17-dev\n" #: main.c msgid "" @@ -1992,7 +1992,7 @@ msgstr "As dimensões da escala devem ser poder ser divididas por 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progress. Stop with stop_scan." -msgstr "" +msgstr "Digitalização já em andamento. Pare com stop_scan." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2314,7 +2314,7 @@ msgstr "Houve um erro BLE desconhecido: %d" #: ports/raspberrypi/common-hal/wifi/__init__.c #, c-format msgid "Unknown error code %d" -msgstr "" +msgstr "Código de erro desconhecido %d" #: shared-bindings/wifi/Radio.c #, c-format From 6effaef9b45c407e9178f436432e01bef73dcc06 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Thu, 23 Mar 2023 17:30:20 +0000 Subject: [PATCH 127/225] Translated using Weblate (Swedish) Currently translated at 100.0% (1002 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index da13d25599..bbbe1ad4fb 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: 2023-03-23 17:26+0000\n" +"PO-Revision-Date: 2023-03-25 02:42+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.16.2-dev\n" +"X-Generator: Weblate 4.17-dev\n" #: main.c msgid "" @@ -1973,7 +1973,7 @@ msgstr "Skaldimension måste vara delbar med 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progress. Stop with stop_scan." -msgstr "" +msgstr "Skanning pågår redan. Stoppa med stop_scan." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2290,7 +2290,7 @@ msgstr "Okänt BLE-fel: %d" #: ports/raspberrypi/common-hal/wifi/__init__.c #, c-format msgid "Unknown error code %d" -msgstr "" +msgstr "Okänd felkod %d" #: shared-bindings/wifi/Radio.c #, c-format From 94f487c08d132645f25d282ce151e2ebe82f3815 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 24 Mar 2023 22:45:12 -0400 Subject: [PATCH 128/225] handle older versions of git for make fetch-submodules; add remove-submodules --- Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 50c86fc128..d0f1fcb3d0 100644 --- a/Makefile +++ b/Makefile @@ -324,9 +324,24 @@ clean-stm: $(MAKE) -C ports/stm BOARD=feather_stm32f405_express clean -# Do blobless partial clones of submodules to save time and space. +# If available, do blobless partial clones of submodules to save time and space. # A blobless partial clone lazily fetches data as needed, but has all the metadata available (tags, etc.) # so it does not have the idiosyncrasies of a shallow clone. +# +# If not available, do a fetch that will fail, and then fix it up with a second fetch. +# (Only works for git servers that allow sha fetches.) .PHONY: fetch-submodules fetch-submodules: - git submodule update --init --filter=blob:none + git submodule sync + ##################################################################################### + # NOTE: Ideally, use git version 2.36.0 or later, to do partial clones of submodules. + # If an older git is used, submodules will be cloned with a shallow clone of depth 1. + # You will see a git usage message first if the git version is too old to do + # clones of submodules. + ##################################################################################### + git submodule update --init --filter=blob:none || git submodule update --init -N --depth 1 || git submodule foreach 'git fetch --tags --depth 1 origin $$sha1 && git checkout -q $$sha1' || echo 'make fetch-submodules FAILED' + +.PHONY: remove-submodules +remove-submodules: + git submodule deinit -f --all + rm -rf .git/modules/* From 730a2a9c2c9b43bfdfda86fb61111bd46e5eedfd Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Sat, 25 Mar 2023 13:09:35 +0530 Subject: [PATCH 129/225] remove certain excludes from pre-commit --- .pre-commit-config.yaml | 4 ++-- .../espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig | 1 - ports/espressif/boards/espressif_esp32_eye/sdkconfig | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab0279f7d7..942a51afdc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,9 +8,9 @@ repos: hooks: - id: check-yaml - id: end-of-file-fixer - exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/espressif/esp-idf-config/.*|ports/espressif/boards/.*/sdkconfig)' + exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*)' - id: trailing-whitespace - exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|lib/mbedtls_errors/.*)' + exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|lib/mbedtls_errors/generate_errors.diff)' - repo: https://github.com/codespell-project/codespell rev: v2.2.4 hooks: diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig index a162344cfb..9d924272ec 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig @@ -5,4 +5,3 @@ CONFIG_ESP32S3_SPIRAM_SUPPORT=n # CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" # end of LWIP - diff --git a/ports/espressif/boards/espressif_esp32_eye/sdkconfig b/ports/espressif/boards/espressif_esp32_eye/sdkconfig index a73d92e0a2..26db1e8087 100644 --- a/ports/espressif/boards/espressif_esp32_eye/sdkconfig +++ b/ports/espressif/boards/espressif_esp32_eye/sdkconfig @@ -69,4 +69,3 @@ CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX=32768 # CONFIG_ESP_CONSOLE_UART_TX_GPIO=1 CONFIG_ESP_CONSOLE_UART_RX_GPIO=3 - From efeaa1ad20a9977117169a9670707e17e767bd8a Mon Sep 17 00:00:00 2001 From: Ozgur BOSTAN <79173593+ozgurbostan@users.noreply.github.com> Date: Sun, 26 Mar 2023 01:02:08 +0300 Subject: [PATCH 130/225] Update mpconfigboard.mk of Deneyap Kart --- ports/espressif/boards/deneyap_kart/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/boards/deneyap_kart/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart/mpconfigboard.mk index c98cdb87b6..ea8c9a8522 100644 --- a/ports/espressif/boards/deneyap_kart/mpconfigboard.mk +++ b/ports/espressif/boards/deneyap_kart/mpconfigboard.mk @@ -1,5 +1,5 @@ -CIRCUITPY_CREATOR_ID = 0x00001209 -CIRCUITPY_CREATION_ID = 0x0032D001 +CIRCUITPY_CREATOR_ID = 0x19231923 +CIRCUITPY_CREATION_ID = 0x00320001 IDF_TARGET = esp32 From c8b329c4eeafcfd7350fe75652b2193a72e3bbcd Mon Sep 17 00:00:00 2001 From: Ozgur BOSTAN <79173593+ozgurbostan@users.noreply.github.com> Date: Sun, 26 Mar 2023 01:03:01 +0300 Subject: [PATCH 131/225] Update mpconfigboard.mk of Deneyap Kart 1A --- ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk index 8b3da63e5b..976083217e 100644 --- a/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk +++ b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.mk @@ -1,5 +1,5 @@ -CIRCUITPY_CREATOR_ID = 0x00001209 -CIRCUITPY_CREATION_ID = 0x0032D002 +CIRCUITPY_CREATOR_ID = 0x19231923 +CIRCUITPY_CREATION_ID = 0x00320002 IDF_TARGET = esp32 From 872495ef36a49c939d0e46f147476b1f4d904cf7 Mon Sep 17 00:00:00 2001 From: Ozgur BOSTAN <79173593+ozgurbostan@users.noreply.github.com> Date: Sun, 26 Mar 2023 01:03:40 +0300 Subject: [PATCH 132/225] Update mpconfigboard.mk Deneyap Kart G --- ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk index c01e84611b..a470d7a088 100644 --- a/ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk +++ b/ports/espressif/boards/deneyap_kart_g/mpconfigboard.mk @@ -1,5 +1,5 @@ -CIRCUITPY_CREATOR_ID = 0x00001209 -CIRCUITPY_CREATION_ID = 0x0032D003 +CIRCUITPY_CREATOR_ID = 0x19231923 +CIRCUITPY_CREATION_ID = 0x00C30001 IDF_TARGET = esp32c3 From 297d9d0a8152299d95d7c04cf07a409d2a955d66 Mon Sep 17 00:00:00 2001 From: ozgurbostan Date: Sun, 26 Mar 2023 14:54:34 +0300 Subject: [PATCH 133/225] Add new boards (deneyapmini/v2 and deneyapkart1a) --- .../boards/deneyap_kart_1a_v2/board.c | 32 +++++++ .../boards/deneyap_kart_1a_v2/mpconfigboard.h | 47 ++++++++++ .../deneyap_kart_1a_v2/mpconfigboard.mk | 12 +++ .../boards/deneyap_kart_1a_v2/pins.c | 73 +++++++++++++++ .../boards/deneyap_kart_1a_v2/sdkconfig | 47 ++++++++++ ports/espressif/boards/deneyap_mini/board.c | 31 +++++++ .../boards/deneyap_mini/mpconfigboard.h | 39 ++++++++ .../boards/deneyap_mini/mpconfigboard.mk | 12 +++ ports/espressif/boards/deneyap_mini/pins.c | 89 +++++++++++++++++++ ports/espressif/boards/deneyap_mini/sdkconfig | 4 + .../espressif/boards/deneyap_mini_v2/board.c | 32 +++++++ .../boards/deneyap_mini_v2/mpconfigboard.h | 39 ++++++++ .../boards/deneyap_mini_v2/mpconfigboard.mk | 11 +++ ports/espressif/boards/deneyap_mini_v2/pins.c | 85 ++++++++++++++++++ .../boards/deneyap_mini_v2/sdkconfig | 37 ++++++++ 15 files changed, 590 insertions(+) create mode 100644 ports/espressif/boards/deneyap_kart_1a_v2/board.c create mode 100644 ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.h create mode 100644 ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk create mode 100644 ports/espressif/boards/deneyap_kart_1a_v2/pins.c create mode 100644 ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig create mode 100644 ports/espressif/boards/deneyap_mini/board.c create mode 100644 ports/espressif/boards/deneyap_mini/mpconfigboard.h create mode 100644 ports/espressif/boards/deneyap_mini/mpconfigboard.mk create mode 100644 ports/espressif/boards/deneyap_mini/pins.c create mode 100644 ports/espressif/boards/deneyap_mini/sdkconfig create mode 100644 ports/espressif/boards/deneyap_mini_v2/board.c create mode 100644 ports/espressif/boards/deneyap_mini_v2/mpconfigboard.h create mode 100644 ports/espressif/boards/deneyap_mini_v2/mpconfigboard.mk create mode 100644 ports/espressif/boards/deneyap_mini_v2/pins.c create mode 100644 ports/espressif/boards/deneyap_mini_v2/sdkconfig diff --git a/ports/espressif/boards/deneyap_kart_1a_v2/board.c b/ports/espressif/boards/deneyap_kart_1a_v2/board.c new file mode 100644 index 0000000000..2287dbaaa7 --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a_v2/board.c @@ -0,0 +1,32 @@ +/* + * 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" + + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.h b/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.h new file mode 100644 index 0000000000..088bfbfd41 --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.h @@ -0,0 +1,47 @@ +/* + * 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 "Deneyap Kart 1A v2" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO33) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO21) + +#define MICROPY_HW_LED_STATUS (&pin_GPIO13) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO38) +#define DEFAULT_UART_BUS_TX (&pin_GPIO39) + +#define DOUBLE_TAP_PIN (&pin_GPIO34) diff --git a/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk new file mode 100644 index 0000000000..1ec7c73185 --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk @@ -0,0 +1,12 @@ +USB_VID = 0x239A +USB_PID = 0x8148 + +USB_PRODUCT = "Deneyap Kart 1A v2" +USB_MANUFACTURER = "Turkish Technology Team Foundation" + +IDF_TARGET = esp32s3 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB +CIRCUITPY_ESPCAMERA = 0 diff --git a/ports/espressif/boards/deneyap_kart_1a_v2/pins.c b/ports/espressif/boards/deneyap_kart_1a_v2/pins.c new file mode 100644 index 0000000000..cf4c915e7f --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a_v2/pins.c @@ -0,0 +1,73 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); diff --git a/ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig b/ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig new file mode 100644 index 0000000000..4e99a09f2e --- /dev/null +++ b/ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig @@ -0,0 +1,47 @@ +# +# Component config +# +# +# ESP32S3-Specific +# +CONFIG_ESP32S3_SPIRAM_SUPPORT=y +# +# SPI RAM config +# +# CONFIG_SPIRAM_MODE_QUAD is not set +CONFIG_SPIRAM_MODE_OCT=y +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 +# +# PSRAM Clock and CS IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM Clock and CS IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_120M is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# end of SPI RAM config + +# end of ESP32S3-Specific + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP + +# end of Component config diff --git a/ports/espressif/boards/deneyap_mini/board.c b/ports/espressif/boards/deneyap_mini/board.c new file mode 100644 index 0000000000..ac27ce4970 --- /dev/null +++ b/ports/espressif/boards/deneyap_mini/board.c @@ -0,0 +1,31 @@ +/* + * 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" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/deneyap_mini/mpconfigboard.h b/ports/espressif/boards/deneyap_mini/mpconfigboard.h new file mode 100644 index 0000000000..0e47285238 --- /dev/null +++ b/ports/espressif/boards/deneyap_mini/mpconfigboard.h @@ -0,0 +1,39 @@ +/* + * 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 "Deneyap Mini" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO37, .sda = &pin_GPIO36}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO38, .mosi = &pin_GPIO40, .miso = &pin_GPIO39}} + +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO43, .rx = &pin_GPIO44}} diff --git a/ports/espressif/boards/deneyap_mini/mpconfigboard.mk b/ports/espressif/boards/deneyap_mini/mpconfigboard.mk new file mode 100644 index 0000000000..f6944b7d7a --- /dev/null +++ b/ports/espressif/boards/deneyap_mini/mpconfigboard.mk @@ -0,0 +1,12 @@ +USB_VID = 0x303A +USB_PID = 0x8142 + +USB_PRODUCT = "Deneyap Mini" +USB_MANUFACTURER = "Turkish Technology Team Foundation" + +IDF_TARGET = esp32s2 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB +CIRCUITPY_ESPCAMERA = 0 diff --git a/ports/espressif/boards/deneyap_mini/pins.c b/ports/espressif/boards/deneyap_mini/pins.c new file mode 100644 index 0000000000..6c04661467 --- /dev/null +++ b/ports/espressif/boards/deneyap_mini/pins.c @@ -0,0 +1,89 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_MC), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_SC), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_SD), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_DA1), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_DA0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_DAC0), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_BT), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GPKEY), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_LEDB), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_LEDG), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_LEDR), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_T0), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_T1), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_T2), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_T3), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_T4), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_T5), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); diff --git a/ports/espressif/boards/deneyap_mini/sdkconfig b/ports/espressif/boards/deneyap_mini/sdkconfig new file mode 100644 index 0000000000..7dfaf3052c --- /dev/null +++ b/ports/espressif/boards/deneyap_mini/sdkconfig @@ -0,0 +1,4 @@ +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="DeneyapMini" +# end of LWIP diff --git a/ports/espressif/boards/deneyap_mini_v2/board.c b/ports/espressif/boards/deneyap_mini_v2/board.c new file mode 100644 index 0000000000..2287dbaaa7 --- /dev/null +++ b/ports/espressif/boards/deneyap_mini_v2/board.c @@ -0,0 +1,32 @@ +/* + * 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" + + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/deneyap_mini_v2/mpconfigboard.h b/ports/espressif/boards/deneyap_mini_v2/mpconfigboard.h new file mode 100644 index 0000000000..be6cbd86b7 --- /dev/null +++ b/ports/espressif/boards/deneyap_mini_v2/mpconfigboard.h @@ -0,0 +1,39 @@ +/* + * 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 "Deneyap Mini v2" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO37, .sda = &pin_GPIO36}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO38, .mosi = &pin_GPIO40, .miso = &pin_GPIO39}} + +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO43, .rx = &pin_GPIO44}} diff --git a/ports/espressif/boards/deneyap_mini_v2/mpconfigboard.mk b/ports/espressif/boards/deneyap_mini_v2/mpconfigboard.mk new file mode 100644 index 0000000000..fa9c6b40ea --- /dev/null +++ b/ports/espressif/boards/deneyap_mini_v2/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x303A +USB_PID = 0x8145 + +USB_PRODUCT = "Deneyap Mini v2" +USB_MANUFACTURER = "Turkish Technology Team Foundation" + +IDF_TARGET = esp32s2 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/deneyap_mini_v2/pins.c b/ports/espressif/boards/deneyap_mini_v2/pins.c new file mode 100644 index 0000000000..ab3250769d --- /dev/null +++ b/ports/espressif/boards/deneyap_mini_v2/pins.c @@ -0,0 +1,85 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_MC), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_SC), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_SD), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_DA1), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_DA0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_DAC0), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GPKEY), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_RGBLED), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_T0), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_T1), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_T2), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_T3), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_T4), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_T5), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_T6), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); diff --git a/ports/espressif/boards/deneyap_mini_v2/sdkconfig b/ports/espressif/boards/deneyap_mini_v2/sdkconfig new file mode 100644 index 0000000000..613b744ef2 --- /dev/null +++ b/ports/espressif/boards/deneyap_mini_v2/sdkconfig @@ -0,0 +1,37 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config + +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="DeneyapMini_v2" +# end of LWIP From d9c4050f9263ca0f62a20f4c36362b8d31221865 Mon Sep 17 00:00:00 2001 From: Luc Date: Sat, 25 Mar 2023 22:01:49 +0000 Subject: [PATCH 134/225] Translated using Weblate (German) Currently translated at 96.0% (962 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/de/ --- locale/de_DE.po | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index fb676d621e..68b1152895 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -6,14 +6,14 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-03-01 17:39+0000\n" -"Last-Translator: Ettore Atalan \n" +"PO-Revision-Date: 2023-03-26 22:37+0000\n" +"Last-Translator: Luc \n" "Language: de_DE\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.16\n" +"X-Generator: Weblate 4.17-dev\n" #: main.c msgid "" @@ -198,7 +198,7 @@ msgstr "" #: ports/espressif/common-hal/analogbufio/BufferedIn.c msgid "%q must be array of type 'H'" -msgstr "" +msgstr "%q muss ein Array vom Typ 'H' sein" #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c @@ -526,7 +526,7 @@ msgstr "Sucht bereits nach Wifi-Netzwerken" #: shared-module/os/getenv.c #, c-format msgid "An error occurred while retrieving '%s':\n" -msgstr "" +msgstr "Ein Fehler ist aufgetreten beim Abfragen von '%s':\n" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Another PWMAudioOut is already active" @@ -826,11 +826,11 @@ msgstr "" #: shared-bindings/bitmaptools/__init__.c msgid "Coordinate arrays have different lengths" -msgstr "" +msgstr "Koordinaten-Arrays haben unterschiedliche Längen" #: shared-bindings/bitmaptools/__init__.c msgid "Coordinate arrays types have different sizes" -msgstr "" +msgstr "Typen der Koordinaten-Arrays haben unterschiedliche Längen" #: py/persistentcode.c msgid "Corrupt .mpy file" @@ -951,7 +951,7 @@ msgstr "Fehler in regex" #: supervisor/shared/safe_mode.c msgid "Error in safemode.py." -msgstr "" +msgstr "Fehler in safemode.py." #: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "Error: Failure to bind" @@ -1028,7 +1028,7 @@ msgstr "Interner Flash konnte nicht geschrieben werden." #: supervisor/shared/safe_mode.c msgid "Fault detected by hardware." -msgstr "" +msgstr "Hardware hat Fehler festgestellt." #: py/moduerrno.c msgid "File exists" @@ -1250,7 +1250,7 @@ msgstr "Der Interne WatchDog Timer ist abgelaufen." #: supervisor/shared/safe_mode.c msgid "Interrupt error." -msgstr "" +msgstr "Interrupt Fehler." #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c @@ -1278,7 +1278,7 @@ msgstr "Ungültige BSSID" #: main.c msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" -msgstr "" +msgstr "Ungültiger Wert CIRCUITPY_PYSTACK_SIZE\n" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" @@ -1977,7 +1977,7 @@ msgstr "Maßstabs-Abmeßungen müssen durch 3 teilbar sein" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progress. Stop with stop_scan." -msgstr "" +msgstr "Scan läuft schon. Stoppen mit stop_scan." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c From 19429d3626c7396b6ce064ea844e98081e53a0bb Mon Sep 17 00:00:00 2001 From: Neradoc Date: Mon, 27 Mar 2023 16:58:44 +0200 Subject: [PATCH 135/225] espnow.Peer: fix argument types and default values --- ports/espressif/bindings/espnow/ESPNow.c | 2 +- ports/espressif/bindings/espnow/Peer.c | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 513966e1e8..06c186d210 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -53,7 +53,7 @@ static void espnow_check_for_deinit(espnow_obj_t *self) { //| class ESPNow: //| """Provides access to the ESP-NOW protocol.""" //| -//| def __init__(self, buffer_size: Optional[int], phy_rate: Optional[int]) -> None: +//| def __init__(self, buffer_size: int = 526, phy_rate: Optional[int] = None) -> None: //| """Allocate and initialize `ESPNow` instance as a singleton. //| //| :param int buffer_size: The size of the internal ring buffer. Default: 526 bytes. diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index ca756409a6..89766dbf11 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -40,6 +40,7 @@ //| def __init__( //| self, //| mac: bytes, +//| *, //| lmk: Optional[bytes], //| channel: int = 0, //| interface: int = 0, @@ -58,10 +59,10 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s enum { ARG_mac, ARG_lmk, ARG_channel, ARG_interface, ARG_encrypt }; static const mp_arg_t allowed_args[] = { { MP_QSTR_mac, MP_ARG_OBJ | MP_ARG_REQUIRED }, - { MP_QSTR_lmk, MP_ARG_OBJ, { .u_obj = mp_const_none } }, - { MP_QSTR_channel, MP_ARG_INT, { .u_obj = mp_const_none } }, - { MP_QSTR_interface,MP_ARG_INT, { .u_obj = mp_const_none } }, - { MP_QSTR_encrypt, MP_ARG_BOOL,{ .u_obj = mp_const_none } }, + { MP_QSTR_lmk, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, + { MP_QSTR_channel, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, + { MP_QSTR_interface,MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, + { MP_QSTR_encrypt, MP_ARG_BOOL | MP_ARG_KW_ONLY,{ .u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -77,20 +78,11 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s memcpy(self->peer_info.peer_addr, common_hal_espnow_get_bytes_len(args[ARG_mac].u_obj, ESP_NOW_ETH_ALEN), ESP_NOW_ETH_ALEN); - const mp_obj_t channel = args[ARG_channel].u_obj; - if (channel != mp_const_none) { - self->peer_info.channel = mp_arg_validate_int_range(mp_obj_get_int(channel), 0, 14, MP_QSTR_channel); - } + self->peer_info.channel = mp_arg_validate_int_range(args[ARG_channel].u_int, 0, 14, MP_QSTR_channel); - const mp_obj_t interface = args[ARG_interface].u_obj; - if (interface != mp_const_none) { - self->peer_info.ifidx = (wifi_interface_t)mp_arg_validate_int_range(mp_obj_get_int(interface), 0, 1, MP_QSTR_interface); - } + self->peer_info.ifidx = (wifi_interface_t)mp_arg_validate_int_range(args[ARG_interface].u_int, 0, 1, MP_QSTR_interface); - const mp_obj_t encrypt = args[ARG_encrypt].u_obj; - if (encrypt != mp_const_none) { - self->peer_info.encrypt = mp_obj_is_true(encrypt); - } + self->peer_info.encrypt = args[ARG_encrypt].u_bool; const mp_obj_t lmk = args[ARG_lmk].u_obj; if (lmk != mp_const_none) { From d6a067b0e564cc9d40d7782541393c5fe63f99e2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 27 Mar 2023 10:52:23 -0500 Subject: [PATCH 136/225] Make PWMAudioOut object ll, have finaliser .. for reasons stated in the comment --- shared-bindings/audiopwmio/PWMAudioOut.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index b4cea75184..56c6412bc6 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -114,7 +114,12 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_ validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj, MP_QSTR_right_channel); // create AudioOut object from the given pin - audiopwmio_pwmaudioout_obj_t *self = m_new_obj(audiopwmio_pwmaudioout_obj_t); + // The object is made long-lived because many implementations keep + // a pointer to the object (e.g., for the interrupt handler), which + // will not work properly if the object is moved. It is created + // with a finaliser as some ports use these (rather than 'reset' functions) + // to ensure resources are collected at interpreter shutdown. + audiopwmio_pwmaudioout_obj_t *self = m_new_ll_obj_with_finaliser(audiopwmio_pwmaudioout_obj_t); self->base.type = &audiopwmio_pwmaudioout_type; common_hal_audiopwmio_pwmaudioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int); @@ -249,6 +254,7 @@ MP_PROPERTY_GETTER(audiopwmio_pwmaudioout_paused_obj, STATIC const mp_rom_map_elem_t audiopwmio_pwmaudioout_locals_dict_table[] = { // Methods { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiopwmio_pwmaudioout_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&audiopwmio_pwmaudioout_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiopwmio_pwmaudioout___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiopwmio_pwmaudioout_play_obj) }, From 9d090ee73eabe5a84eb7f2aeacad431b4994cd29 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 27 Mar 2023 10:52:52 -0500 Subject: [PATCH 137/225] get rid of another debug print --- ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c index dd50c7950a..8650522b41 100644 --- a/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/mimxrt10xx/common-hal/audiopwmio/PWMAudioOut.c @@ -87,7 +87,6 @@ void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *s const mcu_periph_obj_t *left_periph = find_pin_function(mcu_mqs_left_list, left_channel, &instance, MP_QSTR_left_channel); const mcu_periph_obj_t *right_periph = find_pin_function(mcu_mqs_right_list, right_channel, &instance, MP_QSTR_right_channel); - mp_printf(&mp_plat_print, "note: peripheral %d\n", instance); sai_transceiver_t config; SAI_GetClassicI2SConfig(&config, kSAI_WordWidth16bits, kSAI_Stereo, 1U << 0u); config.frameSync.frameSyncEarly = false; From 1fad969389ee76138c4ae3834724e2bde550ae78 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 17 Jul 2022 10:17:05 +0200 Subject: [PATCH 138/225] add unsigned ints and 64 bit types to msgpack change msgpack error message when format invalid --- locale/circuitpython.pot | 8 +++--- shared-module/msgpack/__init__.c | 42 +++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 55ab977e97..b5026f7829 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -400,10 +400,6 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1271,6 +1267,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index d32550722c..3a34731d77 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -102,6 +102,16 @@ STATIC uint32_t read4(msgpack_stream_t *s) { return res; } +STATIC uint64_t read8(msgpack_stream_t *s) { + uint64_t res = 0; + read(s, &res, 8); + int n = 1; + if (*(char *)&n == 1) { + res = __builtin_bswap64(res); + } + return res; +} + STATIC size_t read_size(msgpack_stream_t *s, uint8_t len_index) { size_t res = 0; switch (len_index) { @@ -207,7 +217,7 @@ STATIC void pack_bin(msgpack_stream_t *s, const uint8_t *data, size_t len) { } } -STATIC void pack_ext(msgpack_stream_t *s, int8_t code, const uint8_t *data, size_t len) { +STATIC void pack_ext(msgpack_stream_t *s, int8_t code, const uint8_t *data, size_t len) { if (len == 1) { write1(s, 0xd4); } else if (len == 2) { @@ -424,22 +434,39 @@ STATIC mp_obj_t unpack(msgpack_stream_t *s, mp_obj_t ext_hook, bool use_list) { return unpack_bytes(s, read_size(s, code - 0xc4)); } case 0xcc: // uint8 + return MP_OBJ_NEW_SMALL_INT((uint8_t)read1(s)); case 0xd0: // int8 return MP_OBJ_NEW_SMALL_INT((int8_t)read1(s)); case 0xcd: // uint16 + return MP_OBJ_NEW_SMALL_INT((uint16_t)read2(s)); case 0xd1: // int16 return MP_OBJ_NEW_SMALL_INT((int16_t)read2(s)); case 0xce: // uint32 + return mp_obj_new_int_from_uint((uint32_t)read4(s)); case 0xd2: // int32 - return MP_OBJ_NEW_SMALL_INT((int32_t)read4(s)); - case 0xca: { - union Float { mp_float_t f; - uint32_t u; + return mp_obj_new_int((int32_t)read4(s)); + case 0xcf: // uint 64 + return mp_obj_new_int_from_ull((uint64_t)read8(s)); + case 0xd3: // int 64 + return mp_obj_new_int_from_ll((int64_t)read8(s)); + case 0xca: { // float + union Float { + mp_float_t f; + uint32_t u; }; union Float data; data.u = read4(s); return mp_obj_new_float(data.f); } + case 0xcb: { // double + union Double { + uint64_t u; + double d; + }; + union Double data; + data.u = read8(s); + return mp_obj_new_float_from_d(data.d); + } case 0xd9: case 0xda: case 0xdb: { @@ -483,11 +510,8 @@ STATIC mp_obj_t unpack(msgpack_stream_t *s, mp_obj_t ext_hook, bool use_list) { // ext 8, 16, 32 return unpack_ext(s, read_size(s, code - 0xc7), ext_hook); case 0xc1: // never used - case 0xcb: // float 64 - case 0xcf: // uint 64 - case 0xd3: // int 64 default: - mp_raise_NotImplementedError(translate("64 bit types")); + mp_raise_ValueError(translate("Invalid format")); } } From 16854ae57084659390ed14f1dc69afa4f5547bc6 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 27 Mar 2023 16:29:03 -0400 Subject: [PATCH 139/225] Add BUTTON, reorganise pins. --- .../raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c index e014ace05a..368f96b6fe 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c @@ -19,8 +19,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, @@ -31,10 +32,12 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_CKN), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_CKP), MP_ROM_PTR(&pin_GPIO17) }, { MP_ROM_QSTR(MP_QSTR_D0N), MP_ROM_PTR(&pin_GPIO18) }, From ca23f1e1acf573d8922bef35df2d4235f26d3aad Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 27 Mar 2023 16:52:01 -0500 Subject: [PATCH 140/225] attempt to fix missing jquery in RTD --- conf.py | 1 + requirements-doc.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/conf.py b/conf.py index 7b3b4ca585..ea5072ae4c 100644 --- a/conf.py +++ b/conf.py @@ -77,6 +77,7 @@ needs_sphinx = '1.3' extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', + "sphinxcontrib.jquery", 'sphinxcontrib.rsvgconverter', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', diff --git a/requirements-doc.txt b/requirements-doc.txt index 43e99fa32f..0489dc0b9f 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -13,6 +13,7 @@ sphinx!=5.2.0.post0 sphinx-autoapi sphinx-rtd-theme sphinxcontrib-svg2pdfconverter +sphinxcontrib-jquery readthedocs-sphinx-search myst-parser From 89bd5fae616ec6d403d820bb470a5375789ccf5d Mon Sep 17 00:00:00 2001 From: CDario Date: Tue, 28 Mar 2023 06:28:56 +0000 Subject: [PATCH 141/225] Add M5stack AtomS3 Lite --- .../boards/m5stack_atoms3_lite/board.c | 29 +++++++++++++ .../m5stack_atoms3_lite/mpconfigboard.h | 36 ++++++++++++++++ .../m5stack_atoms3_lite/mpconfigboard.mk | 11 +++++ .../boards/m5stack_atoms3_lite/pins.c | 42 +++++++++++++++++++ .../boards/m5stack_atoms3_lite/sdkconfig | 7 ++++ 5 files changed, 125 insertions(+) create mode 100644 ports/espressif/boards/m5stack_atoms3_lite/board.c create mode 100644 ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.h create mode 100644 ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.mk create mode 100644 ports/espressif/boards/m5stack_atoms3_lite/pins.c create mode 100644 ports/espressif/boards/m5stack_atoms3_lite/sdkconfig diff --git a/ports/espressif/boards/m5stack_atoms3_lite/board.c b/ports/espressif/boards/m5stack_atoms3_lite/board.c new file mode 100644 index 0000000000..164430c88c --- /dev/null +++ b/ports/espressif/boards/m5stack_atoms3_lite/board.c @@ -0,0 +1,29 @@ +/* + * 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" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.h b/ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.h new file mode 100644 index 0000000000..43dd436345 --- /dev/null +++ b/ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.h @@ -0,0 +1,36 @@ +/* + * 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 "M5Stack AtomS3 Lite" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO35) + +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO39, .sda = &pin_GPIO38}, \ + {.scl = &pin_GPIO1, .sda = &pin_GPIO2}} diff --git a/ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.mk b/ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.mk new file mode 100644 index 0000000000..8bb5ab76d8 --- /dev/null +++ b/ports/espressif/boards/m5stack_atoms3_lite/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x303A +USB_PID = 0x815F +USB_PRODUCT = "M5Stack AtomS3 Lite" +USB_MANUFACTURER = "M5Stack" + +IDF_TARGET = esp32s3 + +CIRCUITPY_ESP_FLASH_MODE = qio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 8MB +CIRCUITPY_ESPCAMERA = 0 diff --git a/ports/espressif/boards/m5stack_atoms3_lite/pins.c b/ports/espressif/boards/m5stack_atoms3_lite/pins.c new file mode 100644 index 0000000000..052c15e69f --- /dev/null +++ b/ports/espressif/boards/m5stack_atoms3_lite/pins.c @@ -0,0 +1,42 @@ +#include "shared-bindings/board/__init__.h" + +CIRCUITPY_BOARD_BUS_SINGLETON(porta_i2c, i2c, 1) + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_PORTA_SCL), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_PORTA_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_BTN), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_IR_LED), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_PORTA_I2C), MP_ROM_PTR(&board_porta_i2c_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/m5stack_atoms3_lite/sdkconfig b/ports/espressif/boards/m5stack_atoms3_lite/sdkconfig new file mode 100644 index 0000000000..9d924272ec --- /dev/null +++ b/ports/espressif/boards/m5stack_atoms3_lite/sdkconfig @@ -0,0 +1,7 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=n + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP From a481c564da37beeaa5d88b08a33103901b803839 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 28 Mar 2023 14:00:03 +0200 Subject: [PATCH 142/225] change Peer(encrypt=) to encrypted to match the property --- ports/espressif/bindings/espnow/Peer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index 89766dbf11..5c21dafc4c 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -44,7 +44,7 @@ //| lmk: Optional[bytes], //| channel: int = 0, //| interface: int = 0, -//| encrypt: bool = False, +//| encrypted: bool = False, //| ) -> None: //| """Construct a new peer object. //| @@ -52,17 +52,17 @@ //| :param bytes lmk: The Local Master Key (lmk) of the peer. //| :param int channel: The peer's channel. Default: 0 ie. use the current channel. //| :param int interface: The WiFi interface to use. Default: 0 ie. STA. -//| :param bool encrypt: Whether or not to use encryption. +//| :param bool encrypted: Whether or not to use encryption. //| """ //| ... STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_mac, ARG_lmk, ARG_channel, ARG_interface, ARG_encrypt }; + enum { ARG_mac, ARG_lmk, ARG_channel, ARG_interface, ARG_encrypted }; static const mp_arg_t allowed_args[] = { { MP_QSTR_mac, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_lmk, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, { MP_QSTR_channel, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, { MP_QSTR_interface,MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, - { MP_QSTR_encrypt, MP_ARG_BOOL | MP_ARG_KW_ONLY,{ .u_bool = false } }, + { MP_QSTR_encrypted,MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -82,7 +82,7 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s self->peer_info.ifidx = (wifi_interface_t)mp_arg_validate_int_range(args[ARG_interface].u_int, 0, 1, MP_QSTR_interface); - self->peer_info.encrypt = args[ARG_encrypt].u_bool; + self->peer_info.encrypt = args[ARG_encrypted].u_bool; const mp_obj_t lmk = args[ARG_lmk].u_obj; if (lmk != mp_const_none) { From 02c628a3c70870557c83477a78b6a85a87f40bb7 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 28 Mar 2023 14:36:43 +0200 Subject: [PATCH 143/225] Update ports/espressif/bindings/espnow/ESPNow.c Co-authored-by: MicroDev <70126934+microdev1@users.noreply.github.com> --- ports/espressif/bindings/espnow/ESPNow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 06c186d210..32676bc9be 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -53,7 +53,7 @@ static void espnow_check_for_deinit(espnow_obj_t *self) { //| class ESPNow: //| """Provides access to the ESP-NOW protocol.""" //| -//| def __init__(self, buffer_size: int = 526, phy_rate: Optional[int] = None) -> None: +//| def __init__(self, buffer_size: int = 526, phy_rate: int = 0) -> None: //| """Allocate and initialize `ESPNow` instance as a singleton. //| //| :param int buffer_size: The size of the internal ring buffer. Default: 526 bytes. From f7c2599c293dde3e790adc4cb337ae1e9195261e Mon Sep 17 00:00:00 2001 From: Luc Date: Mon, 27 Mar 2023 19:20:28 +0000 Subject: [PATCH 144/225] Translated using Weblate (German) Currently translated at 100.0% (1002 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/de/ --- locale/de_DE.po | 163 ++++++++++++++++++++++++++---------------------- 1 file changed, 87 insertions(+), 76 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index 68b1152895..98d4f651de 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-03-26 22:37+0000\n" +"PO-Revision-Date: 2023-03-28 14:18+0000\n" "Last-Translator: Luc \n" "Language: de_DE\n" "MIME-Version: 1.0\n" @@ -37,12 +37,17 @@ msgid "" "Please file an issue with your program at https://github.com/adafruit/" "circuitpython/issues." msgstr "" +"\n" +"Bitte erstellen Sie ein Problem (Issue) für Ihr Programm unter https://github" +".com/adafruit/circuitpython/issues." #: supervisor/shared/safe_mode.c msgid "" "\n" "Press reset to exit safe mode.\n" msgstr "" +"\n" +"Drücke Reset, um den Sicherheitsmodus zu beenden.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -189,7 +194,7 @@ msgstr "%q muss >= %d sein" #: shared-bindings/analogbufio/BufferedIn.c msgid "%q must be a bytearray or array of type 'H' or 'B'" -msgstr "" +msgstr "%q muss ein Bytearray oder ein Array vom Typ 'H' oder 'B' sein" #: shared-bindings/audiocore/RawSample.c msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'" @@ -602,7 +607,7 @@ msgstr "Bitmap-Grösse und Bits pro Wert müssen übereinstimmen" #: supervisor/shared/safe_mode.c msgid "Boot device must be first (interface #0)." -msgstr "" +msgstr "Boot-Device muss an erster Stelle kommen (Interface #0)." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Both RX and TX required for flow control" @@ -792,9 +797,8 @@ msgstr "" "Die Frequenz eines bereits verwendeten Timers kann nicht variiert werden" #: ports/nrf/common-hal/alarm/pin/PinAlarm.c -#, fuzzy msgid "Cannot wake on pin edge, only level" -msgstr "Kann nicht durch \"Pin edge\" geweckt werden nur durch \"level\"" +msgstr "Kann nicht durch Flanke an Pin geweckt werden, sondern nur durch Pegel" #: ports/espressif/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." @@ -1121,12 +1125,13 @@ msgstr "Hardware in Benutzung, probiere alternative Pins" #: supervisor/shared/safe_mode.c msgid "Heap allocation when VM not running." -msgstr "" +msgstr "Allokation auf Heap während VM nicht läuft." #: supervisor/shared/safe_mode.c msgid "" "Heap was corrupted because the stack was too small. Increase stack size." msgstr "" +"Heap wurde beschädigt, weil der Stack zu klein war. Bitte Stack vergrößern." #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" @@ -1325,7 +1330,7 @@ msgstr "Ungültiger Zustand" #: shared-module/os/getenv.c msgid "Invalid unicode escape" -msgstr "" +msgstr "Ungültiges Unicode-Escape-Zeichen" #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" @@ -1720,7 +1725,7 @@ msgstr "Zeit für Vorgang abgelaufen" #: ports/raspberrypi/common-hal/mdns/Server.c msgid "Out of MDNS service slots" -msgstr "" +msgstr "Keine freien Slots für MDNS-Dienst mehr verfügbar" #: ports/espressif/common-hal/espidf/__init__.c msgid "Out of memory" @@ -1826,7 +1831,7 @@ msgstr "Polygone brauchen mindestens 3 Punkte" #: shared-bindings/_bleio/Adapter.c msgid "Prefix buffer must be on the heap" -msgstr "Der Präfix-Puffer muss sich auf dem Heap befinden" +msgstr "Präfix-Puffer muss sich auf dem Heap befinden" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload.\n" @@ -1874,7 +1879,7 @@ msgstr "RNG DeInit-Fehler" #: ports/stm/common-hal/os/__init__.c msgid "RNG Init Error" -msgstr "RNG Init-Fehler" +msgstr "RNG-Init-Fehler" #: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c #: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c @@ -2015,7 +2020,7 @@ msgstr "SocketPool kann nur mit wifi.radio verwendet werden" #: shared-bindings/aesio/aes.c msgid "Source and destination buffers must be the same length" -msgstr "Quell- und Zielbuffer müssen gleich lang sein" +msgstr "Quell- und Zielpuffer müssen gleich lang sein" #: shared-bindings/paralleldisplay/ParallelBus.c msgid "Specify exactly one of data0 or data_pins" @@ -2035,7 +2040,7 @@ msgstr "Stereo rechts muss sich auf PWM-Kanal B befinden" #: ports/raspberrypi/common-hal/wifi/Radio.c msgid "Stopping AP is not supported." -msgstr "" +msgstr "Das Stoppen des AP wird nicht unterstützt." #: shared-bindings/alarm/time/TimeAlarm.c msgid "Supply one of monotonic_time or epoch_time" @@ -2052,6 +2057,8 @@ msgstr "Zeitüberschreitung beim Auslesen der Temperatur" #: supervisor/shared/safe_mode.c msgid "The `microcontroller` module was used to boot into safe mode." msgstr "" +"Das 'microcontroller'-Modul wurde benutzt, um in den Sichheitsmodus zu " +"booten." #: py/obj.c msgid "The above exception was the direct cause of the following exception:" @@ -2065,6 +2072,8 @@ msgstr "Die Länge von rgb_pins muss 6, 12, 18, 24 oder 30 betragen" #: supervisor/shared/safe_mode.c msgid "The power dipped. Make sure you are providing enough power." msgstr "" +"Die Spannung ist eingebrochen. Stelle sicher, dass genügend Leistung " +"verfügbar ist." #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -2073,7 +2082,7 @@ msgstr "" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's channel count does not match the mixer's" -msgstr "Die Kanalanzahl des Samples stimmt nicht mit der des Mixers überein" +msgstr "Die Kanalanzahl des Samples stimmt nicht mit der des Mischers überein" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's sample rate does not match the mixer's" @@ -2081,12 +2090,11 @@ msgstr "Die Abtastrate der Probe stimmt nicht mit der des Mischers überein" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's signedness does not match the mixer's" -msgstr "" -"Die Art des Vorzeichens des Samples stimmt nicht mit dem des Mixers überein" +msgstr "Der Vorzeichentyp des Samples stimmt nicht mit dem des Mixers überein" #: supervisor/shared/safe_mode.c msgid "Third-party firmware fatal error." -msgstr "" +msgstr "Fataler Fehler bei Drittanbieter-Firmware." #: shared-module/imagecapture/ParallelImageCapture.c msgid "This microcontroller does not support continuous capture." @@ -2106,7 +2114,7 @@ msgstr "Die Kachelhöhe muss die Bitmaphöhe genau teilen" #: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c msgid "Tile index out of bounds" -msgstr "Kachel index außerhalb der Grenzen" +msgstr "Kachelindex außerhalb der Grenzen" #: shared-bindings/displayio/TileGrid.c msgid "Tile width must exactly divide bitmap width" @@ -2133,7 +2141,7 @@ msgstr "Zu viele Kanäle im sample." #: shared-module/displayio/__init__.c msgid "Too many display busses" -msgstr "Zu viele Display Busse" +msgstr "Zu viele Anzeigebusse" #: shared-module/displayio/__init__.c msgid "Too many displays" @@ -2169,7 +2177,7 @@ msgstr "UART-Initialisierung" #: ports/raspberrypi/common-hal/busio/UART.c msgid "UART peripheral in use" -msgstr "" +msgstr "UART-Endgerät in Benutzung" #: ports/stm/common-hal/busio/UART.c msgid "UART re-init" @@ -2220,12 +2228,12 @@ msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren" #: supervisor/shared/safe_mode.c msgid "Unable to allocate the heap." -msgstr "" +msgstr "Keine Allokation auf dem Heap möglich." #: ports/espressif/common-hal/analogbufio/BufferedIn.c #, c-format msgid "Unable to configure ADC DMA controller, ErrorCode:%d" -msgstr "" +msgstr "ADC-DMA-Controller konnte nicht konfiguriert werden, Fehlercode: %d" #: ports/espressif/common-hal/busio/I2C.c msgid "Unable to create lock" @@ -2248,7 +2256,7 @@ msgstr "Parser konnte nicht gestartet werden" #: ports/espressif/common-hal/analogbufio/BufferedIn.c #, c-format msgid "Unable to initialize ADC DMA controller, ErrorCode:%d" -msgstr "" +msgstr "ADC-DMA-Controller konnte nicht initialisiert werden, Fehlercode: %d" #: shared-module/displayio/OnDiskBitmap.c msgid "Unable to read color palette data" @@ -2257,7 +2265,7 @@ msgstr "Konnte Farbpalettendaten nicht lesen" #: ports/espressif/common-hal/analogbufio/BufferedIn.c #, c-format msgid "Unable to start ADC DMA controller, ErrorCode:%d" -msgstr "" +msgstr "ADC-DMA-Controller konnte nicht gestartet werden, Fehlercode: %d" #: ports/espressif/common-hal/mdns/Server.c #: ports/raspberrypi/common-hal/mdns/Server.c @@ -2298,7 +2306,7 @@ msgstr "Unbekannter BLE-Fehler: %d" #: ports/raspberrypi/common-hal/wifi/__init__.c #, c-format msgid "Unknown error code %d" -msgstr "" +msgstr "Unbekannter Fehlercode %d" #: shared-bindings/wifi/Radio.c #, c-format @@ -2376,7 +2384,7 @@ msgstr "Update fehlgeschlagen" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" -msgstr "Wert Länge != Erforderliche feste Länge" +msgstr "Länge des Wertes != Erforderliche feste Länge" #: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/espressif/common-hal/_bleio/Descriptor.c @@ -2437,11 +2445,11 @@ msgstr "Wi-Fi: " #: ports/raspberrypi/common-hal/wifi/Radio.c msgid "Wifi is in access point mode." -msgstr "" +msgstr "Das Wifi ist im Accesspoint-Modus." #: ports/raspberrypi/common-hal/wifi/Radio.c msgid "Wifi is in station mode." -msgstr "" +msgstr "Das Wifi ist im Station-Modus." #: ports/raspberrypi/common-hal/wifi/Radio.c msgid "Wifi is not enabled" @@ -2454,59 +2462,59 @@ msgstr "Aufgeweckt durch Alarm.\n" #: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" -msgstr "Schreiben nicht unterstüzt für diese Charakteristik" +msgstr "Schreiben für diese Charakteristik nicht unterstützt" #: ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h #: ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h #: ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h #: ports/atmel-samd/boards/meowmeow/mpconfigboard.h msgid "You pressed both buttons at start up." -msgstr "" +msgstr "Beide Knöpfe wurden beim Starten gedrückt." #: ports/espressif/boards/m5stack_core_basic/mpconfigboard.h #: ports/espressif/boards/m5stack_core_fire/mpconfigboard.h #: ports/espressif/boards/m5stack_stick_c/mpconfigboard.h msgid "You pressed button A at start up." -msgstr "" +msgstr "Knopf A wurde beim Starten gedrückt." #: supervisor/shared/safe_mode.c msgid "You pressed the BOOT button at start up" -msgstr "" +msgstr "Der BOOT-Knopf wurde beim Starten gedrückt." #: ports/espressif/boards/adafruit_huzzah32_breakout/mpconfigboard.h msgid "You pressed the GPIO0 button at start up." -msgstr "" +msgstr "Der GPIO0-Knopf wurde beim Starten gedrückt." #: ports/espressif/boards/espressif_esp32_lyrat/mpconfigboard.h msgid "You pressed the Rec button at start up." -msgstr "" +msgstr "Der Rec-Knopf wurde beim Starten gedrückt." #: ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h msgid "You pressed the SW38 button at start up." -msgstr "" +msgstr "Der SW38-Knopf wurde beim Starten gedrückt." #: ports/espressif/boards/hardkernel_odroid_go/mpconfigboard.h msgid "You pressed the VOLUME button at start up." -msgstr "" +msgstr "Der VOLUME-Knopf wurde beim Starten gedrückt." #: ports/espressif/boards/m5stack_atom_echo/mpconfigboard.h #: ports/espressif/boards/m5stack_atom_lite/mpconfigboard.h #: ports/espressif/boards/m5stack_atom_matrix/mpconfigboard.h #: ports/espressif/boards/m5stack_atom_u/mpconfigboard.h msgid "You pressed the central button at start up." -msgstr "" +msgstr "Der zentrale Knopf wurde beim Starten gedrückt." #: ports/nrf/boards/aramcon2_badge/mpconfigboard.h msgid "You pressed the left button at start up." -msgstr "" +msgstr "Der linke Knopf wurde beim Starten gedrückt." #: supervisor/shared/safe_mode.c msgid "You pressed the reset button during boot." -msgstr "" +msgstr "Der Reset-Knopf wurde beim Booten gedrückt." #: supervisor/shared/micropython.c msgid "[truncated due to length]" -msgstr "" +msgstr "[abgeschnitten wegen der Länge]" #: py/objtype.c msgid "__init__() should return None" @@ -2579,7 +2587,7 @@ msgstr "Das Array hat zu viele Dimensionen" #: extmod/ulab/code/ndarray.c msgid "array is too big" -msgstr "" +msgstr "Array ist zu groß" #: py/objarray.c shared-bindings/alarm/SleepMemory.c #: shared-bindings/memorymap/AddressRange.c shared-bindings/nvm/ByteArray.c @@ -2794,8 +2802,8 @@ msgstr "kann keinen relativen Import durchführen" #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" -"Nicht \"None\" Werte können nicht an einen gerade gestarteten Generator " -"gesendet werden" +"Nicht-None-Wert kann nicht an einen gerade gestarteten Generator gesendet " +"werden" #: shared-module/sdcardio/SDCard.c msgid "can't set 512 block size" @@ -2807,7 +2815,7 @@ msgstr "kann Attribut nicht setzen" #: py/runtime.c shared-bindings/supervisor/Runtime.c msgid "can't set attribute '%q'" -msgstr "" +msgstr "Attribut '%q' kann nicht gesetzt werden" #: py/emitnative.c msgid "can't store '%q'" @@ -2877,7 +2885,7 @@ msgstr "Kanal wird erneut initialisiert" #: shared-bindings/_stage/Text.c msgid "chars buffer too small" -msgstr "(char) Zeichenpuffer zu klein" +msgstr "Zeichenpuffer zu klein" #: py/modbuiltins.c msgid "chr() arg not in range(0x110000)" @@ -2943,7 +2951,7 @@ msgstr "Convolve-Argumente müssen ndarrays sein" #: extmod/ulab/code/numpy/filter.c msgid "convolve arguments must not be empty" -msgstr "Convolve Argumente dürfen nicht leer sein" +msgstr "Faltungsargumente dürfen nicht leer sein" #: extmod/ulab/code/numpy/io/io.c msgid "corrupted file" @@ -2994,8 +3002,8 @@ msgstr "default ist keine Funktion" msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" msgstr "" -"Der Zielbuffer muss ein Bytearray oder ein Array vom Typ 'B' für bit_depth = " -"8 sein" +"Zielpuffer muss ein Bytearray oder ein Array vom Typ 'B' für bit_depth = 8 " +"sein" #: shared-bindings/audiobusio/PDMIn.c msgid "destination buffer must be an array of type 'H' for bit_depth = 16" @@ -3055,7 +3063,7 @@ msgstr "leere Sequenz" #: py/objstr.c msgid "end of format while looking for conversion specifier" -msgstr "Ende des Formats wärend der Suche nach einem conversion specifier" +msgstr "Ende des Formats bei der Suche nach einem Konvertierungsspezifizierer" #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" @@ -3071,6 +3079,8 @@ msgid "" "espcamera.Camera requires reserved PSRAM to be configured. See the " "documentation for instructions." msgstr "" +"espcamera.Camera benötigt reservierten PSRAM um konfiguriert zu werden. " +"Siehe Dokumentation für Anweisungen." #: py/runtime.c msgid "exceptions must derive from BaseException" @@ -3290,7 +3300,7 @@ msgstr "Index ist außerhalb der Grenzen" #: shared-bindings/_pixelmap/PixelMap.c msgid "index must be tuple or int" -msgstr "" +msgstr "Index muss tuple oder int sein" #: extmod/ulab/code/numpy/numerical.c extmod/ulab/code/ulab_tools.c #: ports/espressif/common-hal/pulseio/PulseIn.c @@ -3482,7 +3492,7 @@ msgstr "issubclass() arg 2 muss eine Klasse oder ein Tupel von Klassen sein" #: extmod/ulab/code/numpy/linalg/linalg.c msgid "iterations did not converge" -msgstr "Iterationen sind nicht konvergiert (converged)" +msgstr "Iterationen sind nicht konvergiert" #: py/objstr.c msgid "join expects a list of str/bytes objects consistent with self object" @@ -3550,7 +3560,7 @@ msgstr "mDNS funktioniert nur mit integriertem WiFi" #: py/parse.c msgid "malformed f-string" -msgstr "fehlformatierter f-string" +msgstr "fehlerhafter F-String" #: shared-bindings/_stage/Layer.c msgid "map buffer too small" @@ -3634,7 +3644,7 @@ msgstr "Mehrfache Vererbung nicht unterstützt" #: py/emitnative.c msgid "must raise an object" -msgstr "muss ein Objekt verursachen (raise)" +msgstr "muss ein Objekt aufwerfen (raise)" #: py/modbuiltins.c msgid "must use keyword argument for key function" @@ -3654,7 +3664,7 @@ msgstr "native Methode zu groß" #: py/emitnative.c msgid "native yield" -msgstr "native Ausbeute (yield)" +msgstr "natives yield" #: py/runtime.c #, c-format @@ -3667,15 +3677,15 @@ msgstr "negative Fakultät" #: py/objint_longlong.c py/objint_mpz.c py/runtime.c msgid "negative power with no float support" -msgstr "negative Potenz ohne Gleitkomma (float) Unterstützung" +msgstr "negative Potenz ohne Gleitkomma(float)-Unterstützung" #: py/objint_mpz.c py/runtime.c msgid "negative shift count" -msgstr "Negative shift Anzahl" +msgstr "Negative Anzahl an Verschiebungen" #: shared-bindings/_pixelmap/PixelMap.c msgid "nested index must be int" -msgstr "" +msgstr "verschachtelter Index muss int sein" #: shared-module/sdcardio/SDCard.c msgid "no SD card" @@ -3683,11 +3693,11 @@ msgstr "keine SD-Karte" #: py/vm.c msgid "no active exception to reraise" -msgstr "Keine aktive Ausnahme zu verusachen (raise)" +msgstr "Keine aktive Ausnahme zum Wiederaufwerfen (reraise)" #: py/compile.c msgid "no binding for nonlocal found" -msgstr "Kein Binding für nonlocal gefunden" +msgstr "Keine Bindung für nichtlokale Variable gefunden" #: shared-module/msgpack/__init__.c msgid "no default packer" @@ -3717,7 +3727,7 @@ msgstr "kein solches Attribut" #: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" -msgstr "non-UUID gefunden in service_uuids_whitelist" +msgstr "Nicht-UUID in service_uuids_whitelist gefunden" #: py/compile.c msgid "non-default argument follows default argument" @@ -3733,7 +3743,7 @@ msgstr "Nicht-Schlüsselwort arg nach * / **" #: py/compile.c msgid "non-keyword arg after keyword arg" -msgstr "Nicht-Schlüsselwort Argument nach Schlüsselwort Argument" +msgstr "Nicht-Schlüsselwort-Argument nach Schlüsselwort-Argument" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "non-zero timeout must be > 0.01" @@ -3750,11 +3760,12 @@ msgstr "keine 128-bit UUID" #: py/objstr.c msgid "not all arguments converted during string formatting" msgstr "" -"Nicht alle Argumente wurden während der Formatierung des Strings konvertiert" +"Nicht alle Argumente wurden während der Formatierung der Zeichenfolge " +"konvertiert" #: py/objstr.c msgid "not enough arguments for format string" -msgstr "Nicht genügend Argumente für den Formatierungs-String" +msgstr "Nicht genügend Argumente für die Formatzeichenfolge" #: extmod/ulab/code/numpy/carray/carray_tools.c msgid "not implemented for complex dtype" @@ -3850,11 +3861,11 @@ msgstr "nur Mono wird unterstützt" #: extmod/ulab/code/numpy/create.c msgid "only ndarrays can be concatenated" -msgstr "" +msgstr "nur ndarrays können aneinandergehängt werden" #: ports/stm/common-hal/audiobusio/PDMIn.c msgid "only oversample=64 is supported" -msgstr "" +msgstr "nur oversample=64 wird unterstützt" #: ports/nrf/common-hal/audiobusio/PDMIn.c #: ports/stm/common-hal/audiobusio/PDMIn.c @@ -3891,7 +3902,7 @@ msgstr "Operation wird nur für boolesche 1D-Arrays implementiert" #: extmod/ulab/code/numpy/numerical.c msgid "operation is not implemented on ndarrays" -msgstr "Die Operation ist für ndarrays nicht implementiert" +msgstr "Operation ist auf ndarrays nicht implementiert" #: extmod/ulab/code/ndarray.c msgid "operation is not supported for given type" @@ -3943,7 +3954,7 @@ msgstr "Die Parameter müssen Register der Reihenfolge a2 bis a5 sein" #: py/emitinlinethumb.c msgid "parameters must be registers in sequence r0 to r3" -msgstr "Die Parameter müssen Register der Reihenfolge r0 bis r3 sein" +msgstr "Parameter müssen Register im Bereich von r0 bis r3 sein" #: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c msgid "pixel coordinates out of bounds" @@ -3984,7 +3995,7 @@ msgstr "pow() drittes Argument darf nicht 0 sein" #: py/objint_mpz.c msgid "pow() with 3 arguments requires integers" -msgstr "pow() mit 3 Argumenten erfordert Integer" +msgstr "pow() mit 3 Argumenten erfordert ganze Zahlen" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" @@ -4016,7 +4027,7 @@ msgstr "Rückgabewert-Beschreibung muss ein Identifier sein" #: py/emitnative.c msgid "return expected '%q' but got '%q'" -msgstr "Rückgabe erwartet '%q', aber '%q' erhalten" +msgstr "Rückgabe (return) erwartet '%q', hat aber '%q' erhalten" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format @@ -4026,7 +4037,7 @@ msgstr "rgb_pins[%d] dupliziert eine andere Pinbelegung" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] is not on the same port as clock" -msgstr "rgb_pins [%d] befindet sich nicht am selben Port wie clock" +msgstr "rgb_pins[%d] befindet sich nicht am selben Port wie clock" #: extmod/ulab/code/numpy/numerical.c msgid "roll argument must be an ndarray" @@ -4063,7 +4074,7 @@ msgstr "kurze Lektüre" #: py/objstr.c msgid "sign not allowed in string format specifier" -msgstr "Vorzeichen nicht erlaubt in einem String formatierungs specifier" +msgstr "Vorzeichen im Zeichenfolgenformatbezeichner nicht zulässig" #: py/objstr.c msgid "sign not allowed with integer format specifier 'c'" @@ -4095,7 +4106,7 @@ msgstr "weicher reboot\n" #: extmod/ulab/code/numpy/numerical.c msgid "sort argument must be an ndarray" -msgstr "sortierungs Argument muss ein ndarray sein" +msgstr "Sortierungsargument muss ein ndarray sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "sos array must be of shape (n_section, 6)" @@ -4215,7 +4226,7 @@ msgstr "zu viele Lokale für die native Methode" #: py/runtime.c #, c-format msgid "too many values to unpack (expected %d)" -msgstr "zu viele Werte zum Auspacken (erwartet %d)" +msgstr "zu viele Werte zum Auspacken (%d erwartet)" #: extmod/ulab/code/numpy/approx.c msgid "trapz is defined for 1D arrays of equal length" @@ -4249,7 +4260,7 @@ msgstr "Typ ist kein akzeptierter Basis-Typ" #: py/objgenerator.c py/runtime.c msgid "type object '%q' has no attribute '%q'" -msgstr "Typ vom Objekt '%q' hat kein Attribut '%q'" +msgstr "Typ-Objekt '%q' hat kein Attribut '%q'" #: py/objtype.c msgid "type takes 1 or 3 arguments" @@ -4279,7 +4290,7 @@ msgstr "unerwartetes Schlüsselwort-Argument '%q'" #: py/lexer.c msgid "unicode name escapes" -msgstr "Unicode Name ausgebrochen (escaped)" +msgstr "Escaping von Unicode-Namen" #: py/parse.c msgid "unindent doesn't match any outer indent level" @@ -4288,7 +4299,7 @@ msgstr "unindent stimmt mit keiner äußeren Einrückungsebene überein" #: py/objstr.c #, c-format msgid "unknown conversion specifier %c" -msgstr "unbekannter Konvertierungs specifier %c" +msgstr "unbekannter Konvertierungsspezifizierer %c" #: py/objstr.c msgid "unknown format code '%c' for object of type '%q'" @@ -4305,7 +4316,7 @@ msgstr "unbekannter Typ '%q'" #: py/objstr.c #, c-format msgid "unmatched '%c' in format" -msgstr "" +msgstr "'%c' in Format konnte nicht zugeordnet werden" #: py/objtype.c py/runtime.c msgid "unreadable attribute" From 128a4f9697de2c86668f4f3087536feca29f088c Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 28 Mar 2023 16:18:27 +0200 Subject: [PATCH 145/225] 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 | 8 ++++---- locale/cs.po | 11 +++++++---- locale/de_DE.po | 15 +++++++++------ locale/el.po | 13 ++++++++----- locale/en_GB.po | 11 +++++++---- locale/es.po | 11 +++++++---- locale/fil.po | 8 ++++---- locale/fr.po | 11 +++++++---- locale/hi.po | 8 ++++---- locale/it_IT.po | 11 +++++++---- locale/ja.po | 8 ++++---- locale/ko.po | 8 ++++---- locale/nl.po | 8 ++++---- locale/pl.po | 8 ++++---- locale/pt_BR.po | 11 +++++++---- locale/ru.po | 11 +++++++---- locale/sv.po | 11 +++++++---- locale/tr.po | 11 +++++++---- locale/zh_Latn_pinyin.po | 11 +++++++---- 19 files changed, 115 insertions(+), 79 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 0affac3ed4..21d3e4a4c2 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -403,10 +403,6 @@ msgstr "0.0 ke kompleks berpangkat" msgid "3-arg pow() not supported" msgstr "pow() 3-arg tidak didukung" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1283,6 +1279,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Ukuran potongan format tidak valid" diff --git a/locale/cs.po b/locale/cs.po index 7af7d489b1..a8d09ade34 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -404,10 +404,6 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "pow() nepodporuje 3 argumenty" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "64 bit typy" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1283,6 +1279,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "Chybný data_pin[%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Neplatná velikost bloku" @@ -4382,6 +4382,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "64 bit types" +#~ msgstr "64 bit typy" + #~ msgid "No key was specified" #~ msgstr "Nebyl zadán klíč" diff --git a/locale/de_DE.po b/locale/de_DE.po index 98d4f651de..ab543ccea4 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -38,8 +38,8 @@ msgid "" "circuitpython/issues." msgstr "" "\n" -"Bitte erstellen Sie ein Problem (Issue) für Ihr Programm unter https://github" -".com/adafruit/circuitpython/issues." +"Bitte erstellen Sie ein Problem (Issue) für Ihr Programm unter https://" +"github.com/adafruit/circuitpython/issues." #: supervisor/shared/safe_mode.c msgid "" @@ -414,10 +414,6 @@ msgstr "0.0 zu einer komplexen Potenz" msgid "3-arg pow() not supported" msgstr "3-arg pow() wird nicht unterstützt" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "64 bit-Typen" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1307,6 +1303,10 @@ msgstr "Ungültiges Byte %.*s" msgid "Invalid data_pins[%d]" msgstr "Ungültige data_pins[%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Ungültige format chunk size" @@ -4469,6 +4469,9 @@ msgstr "zi muss eine Gleitkommazahl sein" msgid "zi must be of shape (n_section, 2)" msgstr "zi muss die Form (n_section, 2) haben" +#~ msgid "64 bit types" +#~ msgstr "64 bit-Typen" + #~ msgid "No key was specified" #~ msgstr "Es wurde kein Schlüssel angegeben" diff --git a/locale/el.po b/locale/el.po index ab4b2d9b90..3336cbae67 100644 --- a/locale/el.po +++ b/locale/el.po @@ -408,11 +408,6 @@ msgstr "0.0 σε μία σύνθετη δύναμη" msgid "3-arg pow() not supported" msgstr "pow() με 3 παραμέτρους δεν υποστηρίζεται" -#: shared-module/msgpack/__init__.c -#, fuzzy -msgid "64 bit types" -msgstr "64 bit τύποι" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1292,6 +1287,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" @@ -4390,6 +4389,10 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#, fuzzy +#~ msgid "64 bit types" +#~ msgstr "64 bit τύποι" + #~ msgid "%q pin invalid" #~ msgstr "%q άκυρο pin" diff --git a/locale/en_GB.po b/locale/en_GB.po index e2d9cd9f13..9c26f47d45 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -407,10 +407,6 @@ msgstr "0.0 to a complex power" msgid "3-arg pow() not supported" msgstr "3-arg pow() not supported" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "64 bit types" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1284,6 +1280,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "Invalid data_pins[%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Invalid format chunk size" @@ -4393,6 +4393,9 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "64 bit types" +#~ msgstr "64 bit types" + #~ msgid "No key was specified" #~ msgstr "No key was specified" diff --git a/locale/es.po b/locale/es.po index 9578e4048a..d5db9c0c88 100644 --- a/locale/es.po +++ b/locale/es.po @@ -415,10 +415,6 @@ msgstr "0.0 a una potencia compleja" msgid "3-arg pow() not supported" msgstr "pow() con 3 argumentos no soportado" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "tipos de 64 bit" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1317,6 +1313,10 @@ msgstr "byte %.*s Inválido" msgid "Invalid data_pins[%d]" msgstr "Inválidos los data_pins[%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Formato de fragmento de formato no válido" @@ -4466,6 +4466,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 "64 bit types" +#~ msgstr "tipos de 64 bit" + #~ msgid "No key was specified" #~ msgstr "No se especificó ninguna llave" diff --git a/locale/fil.po b/locale/fil.po index 86677af69b..f83cfb1173 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -402,10 +402,6 @@ msgstr "0.0 para sa complex power" msgid "3-arg pow() not supported" msgstr "3-arg pow() hindi suportado" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1283,6 +1279,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Mali ang format ng chunk size" diff --git a/locale/fr.po b/locale/fr.po index 812f09b454..e536cbd346 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -412,10 +412,6 @@ msgstr "0.0 à une puissance complexe" msgid "3-arg pow() not supported" msgstr "pow() non supporté avec 3 paramètres" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "types à 64 bit" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1323,6 +1319,10 @@ msgstr "Octet invalide %.*s" msgid "Invalid data_pins[%d]" msgstr "data_pins[%d] invalide" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Taille de bloc de formatage invalide" @@ -4485,6 +4485,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 "64 bit types" +#~ msgstr "types à 64 bit" + #~ msgid "No key was specified" #~ msgstr "Aucune clé n'a été spécifiée" diff --git a/locale/hi.po b/locale/hi.po index 75efddc294..977cd4986a 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -400,10 +400,6 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1271,6 +1267,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index e8d32b163e..b4e998f698 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -405,10 +405,6 @@ msgstr "0.0 elevato alla potenza di un numero complesso" msgid "3-arg pow() not supported" msgstr "pow() con tre argmomenti non supportata" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "Tipo 64 bits" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1285,6 +1281,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" @@ -4415,6 +4415,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "64 bit types" +#~ msgstr "Tipo 64 bits" + #~ msgid "too many arguments provided with the given format" #~ msgstr "troppi argomenti forniti con il formato specificato" diff --git a/locale/ja.po b/locale/ja.po index f90abd66da..ab8ca26d28 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -407,10 +407,6 @@ msgstr "0.0を複素数でべき乗" msgid "3-arg pow() not supported" msgstr "引数3つのpow()は非対応" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1284,6 +1280,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "フォーマットチャンクのサイズが不正" diff --git a/locale/ko.po b/locale/ko.po index fbb45ed195..21b5cdecd6 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -401,10 +401,6 @@ msgstr "" msgid "3-arg pow() not supported" msgstr "" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1274,6 +1270,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "형식 청크 크기가 잘못되었습니다" diff --git a/locale/nl.po b/locale/nl.po index f9faf2a6a5..50a0ab6d99 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -400,10 +400,6 @@ msgstr "0.0 tot een complexe macht" msgid "3-arg pow() not supported" msgstr "3-arg pow() niet ondersteund" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1279,6 +1275,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Ongeldig formaat stuk grootte" diff --git a/locale/pl.po b/locale/pl.po index 4fc4337a55..e873e45a51 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -402,10 +402,6 @@ msgstr "0.0 do potęgi zespolonej" msgid "3-arg pow() not supported" msgstr "3-argumentowy pow() jest niewspierany" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1279,6 +1275,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Zła wielkość fragmentu formatu" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index a684aacfb1..6968cfbb84 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -417,10 +417,6 @@ msgstr "0,0 para uma potência complexa" msgid "3-arg pow() not supported" msgstr "3-arg pow() não compatível" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "Tipos 64 bit" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1313,6 +1309,10 @@ msgstr "Byte %.*s inválido" msgid "Invalid data_pins[%d]" msgstr "data_pins[%d] inválido" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Tamanho do pedaço de formato inválido" @@ -4466,6 +4466,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 "64 bit types" +#~ msgstr "Tipos 64 bit" + #~ msgid "No key was specified" #~ msgstr "Nenhuma chave foi definida" diff --git a/locale/ru.po b/locale/ru.po index c2e6ccc265..e2c1eae4f1 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -407,10 +407,6 @@ msgstr "0.0 в комплексную степень" msgid "3-arg pow() not supported" msgstr "3-аргументный pow() не поддерживается" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "64-битные типы" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1316,6 +1312,10 @@ msgstr "Неверный байт %.*s" msgid "Invalid data_pins[%d]" msgstr "Неверный data_pins[%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Неверный размер блока формата" @@ -4430,6 +4430,9 @@ msgstr "zi должно быть типа float" msgid "zi must be of shape (n_section, 2)" msgstr "zi должен иметь форму (n_section, 2)" +#~ msgid "64 bit types" +#~ msgstr "64-битные типы" + #~ msgid "No key was specified" #~ msgstr "Ключ не был указан" diff --git a/locale/sv.po b/locale/sv.po index bbbe1ad4fb..1cef8c6d7a 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -414,10 +414,6 @@ msgstr "0,0 till ett komplext nummer" msgid "3-arg pow() not supported" msgstr "3-arguments pow() stöds inte" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "64-bitars typer" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1298,6 +1294,10 @@ msgstr "Ogiltig byte %.*s" msgid "Invalid data_pins[%d]" msgstr "Ogiltig data_pins[%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Ogiltig formatsegmentstorlek" @@ -4428,6 +4428,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 "64 bit types" +#~ msgstr "64-bitars typer" + #~ msgid "No key was specified" #~ msgstr "Ingen nyckel angavs" diff --git a/locale/tr.po b/locale/tr.po index 62c5fc9dc2..f785cff4fc 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -409,10 +409,6 @@ msgstr "0.0'dan bir karmaşık güce" msgid "3-arg pow() not supported" msgstr "3-argümanlı pow() desteklenmemektedir" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "64 bit tipler" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1290,6 +1286,10 @@ msgstr "" msgid "Invalid data_pins[%d]" msgstr "Geçersiz veri_pini [%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Geçersiz biçim yığın boyutu" @@ -4389,6 +4389,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "64 bit types" +#~ msgstr "64 bit tipler" + #~ msgid "%q pin invalid" #~ msgstr "%q pini geçersiz" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 98876f3cdb..2246687ef3 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -416,10 +416,6 @@ msgstr "0.0 de fùshù cì mì" msgid "3-arg pow() not supported" msgstr "bù zhī chí 3-arg pow()" -#: shared-module/msgpack/__init__.c -msgid "64 bit types" -msgstr "64 wèi lèixíng" - #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -1305,6 +1301,10 @@ msgstr "wú xiào zì jié %.*s" msgid "Invalid data_pins[%d]" msgstr "wú xiào data_pins[%d]" +#: shared-module/msgpack/__init__.c +msgid "Invalid format" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Géshì kuài dàxiǎo wúxiào" @@ -4434,6 +4434,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 "64 bit types" +#~ msgstr "64 wèi lèixíng" + #~ msgid "No key was specified" #~ msgstr "Wèi zhǐdìng mì yào" From cb5e1a1e981a970744d0a53626addfb608c9091d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 28 Mar 2023 09:20:54 -0500 Subject: [PATCH 146/225] mimxrt: Fix output frequency for samples that don't divide 192kHz This makes all the samples from Dan's collection register as 440Hz when playing on pwmio or i2sout, using https://webaudiodemos.appspot.com/pitchdetect/index.html to detect the frequency played (all should show as A 440Hz; an error of up to 20 "cents" should be treated as OK) There's an audible carrier with PWM output and the 8kHz samples. This is probably a limitation of the peripheral which is documented as being for input signals of 44 kHz or 48 kHz; the carrier frequency is a fixed multiple of the sample frequency. Closes #7800 --- .../common-hal/audiobusio/__init__.c | 59 +++++++++++++++++-- shared-bindings/audiopwmio/PWMAudioOut.c | 4 ++ 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c index 515c39a268..13ae64d27c 100644 --- a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c +++ b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c @@ -42,18 +42,23 @@ /* * AUDIO PLL setting: Frequency = Fref * (DIV_SELECT + NUM / DENOM) - * = 24 * (32 + 77/100) - * = 786.48 MHz + * = 24 * (32 + 96 / 125) = 24 * (32.768) + * = 786.432 MHz = 48kHz * 16384 + * + * This default clocking is used during initial configuration; it also works well for + * frequencies that evenly divide 192kHz, such as 8/12/24/48kHz. However, it doesn't work + * well for 44.1/22/11kHz, so there's the possibility of using a different + * setting when playing a particular sample. */ const clock_audio_pll_config_t audioPllConfig = { .loopDivider = 32, /* PLL loop divider. Valid range for DIV_SELECT divider value: 27~54. */ .postDivider = 1, /* Divider after the PLL, should only be 1, 2, 4, 8, 16. */ - .numerator = 77, /* 30 bit numerator of fractional loop divider. */ - .denominator = 100, /* 30 bit denominator of fractional loop divider */ + .numerator = 96, /* 30 bit numerator of fractional loop divider. */ + .denominator = 125, /* 30 bit denominator of fractional loop divider */ }; static I2S_Type *const i2s_instances[] = I2S_BASE_PTRS; -static uint8_t i2s_in_use; +static uint8_t i2s_in_use, i2s_playing; static I2S_Type *SAI_GetPeripheral(int idx) { if (idx < 0 || idx >= (int)MP_ARRAY_SIZE(i2s_instances)) { @@ -344,7 +349,11 @@ void port_i2s_deinit(i2s_t *self) { } SAI_TransferAbortSend(self->peripheral, &self->handle); i2s_clock_off(self->peripheral); - i2s_in_use &= ~(1 << SAI_GetInstance(self->peripheral)); + + uint32_t instance_mask = 1 << SAI_GetInstance(self->peripheral); + i2s_in_use &= ~instance_mask; + i2s_playing &= ~instance_mask; + if (!i2s_in_use) { CCM_ANALOG->PLL_AUDIO = CCM_ANALOG_PLL_AUDIO_BYPASS_MASK | CCM_ANALOG_PLL_AUDIO_POWERDOWN_MASK | CCM_ANALOG_PLL_AUDIO_BYPASS_CLK_SRC(kCLOCK_PllClkSrc24M); } @@ -354,13 +363,51 @@ void port_i2s_deinit(i2s_t *self) { } } +static uint32_t gcd(uint32_t a, uint32_t b) { + while (b) { + uint32_t tmp = a % b; + a = b; + b = tmp; + } + return a; +} + +static void set_sai_clocking_for_sample_rate(uint32_t sample_rate) { + mp_arg_validate_int_range((mp_uint_t)sample_rate, 4000, 192000, MP_QSTR_sample_rate); + + uint32_t target_rate = sample_rate; + // ensure the PWM rate of MQS will be adequately high + while (target_rate < 175000) { + target_rate <<= 1; + } + target_rate *= 4096; // various prescalers divide by this much + uint32_t div = gcd(target_rate % 24000000, 24000000); + clock_audio_pll_config_t config = { + .loopDivider = target_rate / 24000000, + .postDivider = 1, + .numerator = (target_rate % 24000000) / div, + .denominator = 24000000 / div, + }; + CLOCK_InitAudioPll(&config); +} + void port_i2s_play(i2s_t *self, mp_obj_t sample, bool loop) { self->sample = sample; self->loop = loop; self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8; self->channel_count = audiosample_channel_count(sample); + int instance = SAI_GetInstance(self->peripheral); + i2s_playing |= (1 << instance); uint32_t sample_rate = audiosample_sample_rate(sample); if (sample_rate != self->sample_rate) { + if (__builtin_popcount(i2s_playing) <= 1) { + // as this is the first/only i2s instance playing audio, we can + // safely change the overall clock used by the SAI peripheral, to + // get more accurate frequency reproduction. If another i2s + // instance is playing, then we can't touch the audio PLL and have + // to live with what we can get, which may be inaccurate + set_sai_clocking_for_sample_rate(sample_rate); + } SAI_TxSetBitClockRate(self->peripheral, SAI_CLOCK_FREQ, sample_rate, 16, 2); self->sample_rate = sample_rate; } diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 56c6412bc6..f05fbfdfe9 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -56,6 +56,10 @@ //| :param int quiescent_value: The output value when no signal is present. Samples should start //| and end with this value to prevent audible popping. //| +//| **Limitations:** On mimxrt10xx, low sample rates may have an audible +//| "carrier" frequency. The manufacturer datasheet states that the "MQS" peripheral +//| is intended for 44 kHz or 48kHz input signals. +//| //| Simple 8ksps 440 Hz sin wave:: //| //| import audiocore From d28932934482cd5df5871d8276adc1cc812e9fc4 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 28 Mar 2023 11:02:17 -0400 Subject: [PATCH 147/225] Handle HID OUT reports with no report ID --- shared-module/usb_hid/Device.c | 44 +++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index 680bb83893..6f530bfef8 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -293,24 +293,40 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t // Callback invoked when we receive Set_Report request through control endpoint void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize) { (void)itf; - if (report_type == HID_REPORT_TYPE_INVALID) { - report_id = buffer[0]; - buffer++; - bufsize--; + + usb_hid_device_obj_t *hid_device = NULL; + size_t id_idx; + + if (report_id == 0 && report_type == HID_REPORT_TYPE_INVALID) { + // This could be a report with a non-zero report ID in the first byte, or + // it could be for report ID 0. + // Heuristic: see if there's a device with report ID 0, and if its report length matches + // the size of the incoming buffer. In that case, assume the first byte is not the report ID, + // but is data. Otherwise use the first byte as the report id. + if (usb_hid_get_device_with_report_id(0, &hid_device, &id_idx) && + hid_device && + hid_device->out_report_buffers[id_idx] && + hid_device->out_report_lengths[id_idx] == bufsize) { + // Use as is, with report_id 0. + } else { + // No matching report ID 0, so use the first byte as the report ID. + report_id = buffer[0]; + buffer++; + bufsize--; + } } else if (report_type != HID_REPORT_TYPE_OUTPUT && report_type != HID_REPORT_TYPE_FEATURE) { return; } - usb_hid_device_obj_t *hid_device; - size_t id_idx; - // Find device with this report id, and get the report id index. - if (usb_hid_get_device_with_report_id(report_id, &hid_device, &id_idx)) { + // report_id might be changed due to parsing above, so test again. + if ((report_id == 0 && report_type == HID_REPORT_TYPE_INVALID) || + // Fetch the matching device if we don't already have the report_id 0 device. + (usb_hid_get_device_with_report_id(report_id, &hid_device, &id_idx) && + hid_device && + hid_device->out_report_buffers[id_idx] && + hid_device->out_report_lengths[id_idx] == bufsize)) { // If a report of the correct size has been read, save it in the proper OUT report buffer. - if (hid_device && - hid_device->out_report_buffers[id_idx] && - hid_device->out_report_lengths[id_idx] >= bufsize) { - memcpy(hid_device->out_report_buffers[id_idx], buffer, bufsize); - hid_device->out_report_buffers_updated[id_idx] = true; - } + memcpy(hid_device->out_report_buffers[id_idx], buffer, bufsize); + hid_device->out_report_buffers_updated[id_idx] = true; } } From 2a4383e633766e01c4c07149161def59c11a576e Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Tue, 28 Mar 2023 15:23:19 -0400 Subject: [PATCH 148/225] Add Feather RP2040 RFM, update DVI. --- .../mpconfigboard.h | 2 +- .../boards/adafruit_feather_rp2040_dvi/pins.c | 32 ++++++----- .../adafruit_feather_rp2040_rfm/board.c | 29 ++++++++++ .../mpconfigboard.h | 14 +++++ .../mpconfigboard.mk | 9 +++ .../pico-sdk-configboard.h | 4 ++ .../boards/adafruit_feather_rp2040_rfm/pins.c | 57 +++++++++++++++++++ 7 files changed, 131 insertions(+), 16 deletions(-) create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/board.c create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pins.c diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h index 06cfaf37f6..55b69b4ad8 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/mpconfigboard.h @@ -1,7 +1,7 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040 DVI" #define MICROPY_HW_MCU_NAME "rp2040" -#define MICROPY_HW_NEOPIXEL (&pin_GPIO16) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO4) #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c index 368f96b6fe..c8b4e3474f 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_dvi/pins.c @@ -9,22 +9,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO24) }, { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, - - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, - - { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO7) }, - { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, - { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, - - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, @@ -32,6 +17,23 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/board.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/board.c new file mode 100644 index 0000000000..331653173e --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/board.c @@ -0,0 +1,29 @@ +/* + * 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" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.h new file mode 100644 index 0000000000..fff88cc1fa --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.h @@ -0,0 +1,14 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040 RFM" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO4) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO8) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.mk new file mode 100644 index 0000000000..161a2b5c2e --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x812E +USB_PRODUCT = "Feather RP2040 RFM" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pico-sdk-configboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pins.c new file mode 100644 index 0000000000..71679fb53b --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_rfm/pins.c @@ -0,0 +1,57 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { 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_D24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_RFM_CS), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_RFM_RST), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_RFM_IO5), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_RFM_IO3), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_RFM_IO4), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_RFM_IO0), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_RFM_IO1), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_RFM_IO2), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); From 11082435f1d6c916d6274e77e842c0d10cbbff6a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 28 Mar 2023 16:05:17 -0400 Subject: [PATCH 149/225] shrink SAMD21 builds by a few hundred bytes --- ports/atmel-samd/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 343dcf7d63..31e69f36c9 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -116,12 +116,12 @@ else # -finline-limit=80 or so is similar to not having it on. # There is no simple default value, though. ifeq ($(SHRINK_BUILD), 1) - CFLAGS += -finline-limit=45 + CFLAGS += -finline-limit=45 --param max-inline-insns-auto=110 endif # We used to do this but it seems to not reduce space any more, at least in gcc 11. # Leave it here, commented out, just for reference. - # --param inline-unit-growth=15 --param max-inline-insns-auto=20 + # --param inline-unit-growth=15 ifdef CFLAGS_BOARD CFLAGS += $(CFLAGS_BOARD) From b2535496b08849d93cec582d5894a748b60cbb96 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 28 Mar 2023 16:28:31 -0400 Subject: [PATCH 150/225] use max-inline-insns-auto=110 only on SAMD21 --- ports/atmel-samd/Makefile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 31e69f36c9..ca906ab98f 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -104,19 +104,16 @@ else CFLAGS += -DNDEBUG # Do a default shrink for small builds, including all SAMD21 builds. - ifeq ($(CIRCUITPY_FULL_BUILD),0) - SHRINK_BUILD = 1 - else - ifeq ($(CHIP_FAMILY), samd21) - SHRINK_BUILD = 1 - endif - endif - # -finline-limit can shrink the image size. # -finline-limit=80 or so is similar to not having it on. # There is no simple default value, though. - ifeq ($(SHRINK_BUILD), 1) - CFLAGS += -finline-limit=45 --param max-inline-insns-auto=110 + ifeq ($(CIRCUITPY_FULL_BUILD),0) + CFLAGS += -finline-limit=45 + else + ifeq ($(CHIP_FAMILY), samd21) + # max-inline-insns-auto increases the size of SAMD51 builds. + CFLAGS += -finline-limit=45 --param max-inline-insns-auto=110 + endif endif # We used to do this but it seems to not reduce space any more, at least in gcc 11. From f14861c2457f3f9d3c8610ca48c080f63c787b66 Mon Sep 17 00:00:00 2001 From: MicroDev <70126934+MicroDev1@users.noreply.github.com> Date: Wed, 29 Mar 2023 09:49:35 +0530 Subject: [PATCH 151/225] fix espnow reinit, remove todos and improve docs --- ports/espressif/bindings/espidf/__init__.c | 14 ++++++++++---- ports/espressif/bindings/espnow/ESPNow.c | 10 +++++++--- ports/espressif/bindings/espnow/Peer.c | 5 +---- ports/espressif/bindings/espnow/Peers.c | 2 -- ports/espressif/bindings/espnow/__init__.c | 5 ++--- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ports/espressif/bindings/espidf/__init__.c b/ports/espressif/bindings/espidf/__init__.c index c1ef9da1e0..65b7f12a18 100644 --- a/ports/espressif/bindings/espidf/__init__.c +++ b/ports/espressif/bindings/espidf/__init__.c @@ -34,6 +34,8 @@ #include "nvs_flash.h" #include "components/heap/include/esp_heap_caps.h" +//| import builtins +//| //| """Direct access to a few ESP-IDF details. This module *should not* include any functionality //| that could be implemented by other frameworks. It should only include ESP-IDF specific //| things.""" @@ -95,6 +97,13 @@ STATIC void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr mp_obj_exception_print(print, o_in, kind); } +//| class IDFError(builtins.OSError): +//| """Raised when an ``ESP-IDF`` function returns an error code. +//| `esp_err_t `_ +//| """ +//| +//| ... +//| const mp_obj_type_t mp_type_espidf_IDFError = { { &mp_type_type }, .name = MP_QSTR_IDFError, @@ -104,11 +113,8 @@ const mp_obj_type_t mp_type_espidf_IDFError = { .parent = &mp_type_OSError, }; - -//| import builtins -//| //| class MemoryError(builtins.MemoryError): -//| """Raised when an ESP IDF memory allocation fails.""" +//| """Raised when an ``ESP-IDF`` memory allocation fails.""" //| //| ... //| diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 32676bc9be..78d80924fd 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -57,7 +57,9 @@ static void espnow_check_for_deinit(espnow_obj_t *self) { //| """Allocate and initialize `ESPNow` instance as a singleton. //| //| :param int buffer_size: The size of the internal ring buffer. Default: 526 bytes. -//| :param int phy_rate: The ESP-NOW physical layer rate. Default: 1 Mbps.""" +//| :param int phy_rate: The ESP-NOW physical layer rate. Default: 1 Mbps. +//| `wifi_phy_rate_t `_ +//| """ //| ... STATIC mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer_size, ARG_phy_rate }; @@ -71,7 +73,7 @@ STATIC mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t espnow_obj_t *self = MP_STATE_PORT(espnow_singleton); - if (self != NULL) { + if (!common_hal_espnow_deinited(self)) { mp_raise_RuntimeError(translate("Already running")); } @@ -244,7 +246,9 @@ MP_PROPERTY_GETTER(espnow_buffer_size_obj, (mp_obj_t)&espnow_get_buffer_size_obj); //| phy_rate: int -//| """The ESP-NOW physical layer rate.""" +//| """The ESP-NOW physical layer rate. +//| `wifi_phy_rate_t `_ +//| """ //| STATIC mp_obj_t espnow_get_phy_rate(const mp_obj_t self_in) { espnow_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index 5c21dafc4c..f69bec01e6 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -31,9 +31,6 @@ #include "bindings/espnow/Peer.h" #include "common-hal/espnow/__init__.h" -// TODO: check peer already exist -// TODO: check peer doesn't exist - //| class Peer: //| """A data class to store parameters specific to a peer.""" //| @@ -62,7 +59,7 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s { MP_QSTR_lmk, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, { MP_QSTR_channel, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, { MP_QSTR_interface,MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, - { MP_QSTR_encrypted,MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, + { MP_QSTR_encrypted,MP_ARG_BOOL | MP_ARG_KW_ONLY,{ .u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; diff --git a/ports/espressif/bindings/espnow/Peers.c b/ports/espressif/bindings/espnow/Peers.c index 15d07c09d0..6fda9aed7a 100644 --- a/ports/espressif/bindings/espnow/Peers.c +++ b/ports/espressif/bindings/espnow/Peers.c @@ -35,8 +35,6 @@ #include "esp_now.h" -// TODO: Check for deinit - //| class Peers: //| """Maintains a `list` of `Peer` internally and only exposes a subset of `list` methods.""" //| diff --git a/ports/espressif/bindings/espnow/__init__.c b/ports/espressif/bindings/espnow/__init__.c index da15be49ea..3135858601 100644 --- a/ports/espressif/bindings/espnow/__init__.c +++ b/ports/espressif/bindings/espnow/__init__.c @@ -33,9 +33,8 @@ //| """ESP-NOW Module //| //| The `espnow` module provides an interface to the -//| `ESP-NOW `_ -//| protocol provided by Espressif on its SoCs -//| (`API docs `_). +//| `ESP-NOW `_ +//| protocol provided by Espressif on its SoCs. //| //| **Sender** //| From cc3d0f6fa15bf3532ad99f289db29555a9e37858 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 29 Mar 2023 10:03:56 -0500 Subject: [PATCH 152/225] getenv: treat a read error like eof Otherwise, the following would occur: * settings.toml is in the process of being written by host computer * soft-reset begins * web workflow tries to grab CIRCUITPY_WIFI_SSID, but loops forever because FAT filesystem is in inconsistent state and file reads error * settings.toml write by host computer never completes and the filesystem remains corrupt * restarting yields a soft-bricked device, because startup reads CIRCUITPY_WIFI_SSID again --- shared-module/os/getenv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/os/getenv.c b/shared-module/os/getenv.c index 870973c5d2..6585aeb88c 100644 --- a/shared-module/os/getenv.c +++ b/shared-module/os/getenv.c @@ -72,7 +72,7 @@ STATIC void close_file(file_arg *active_file) { // nothing } STATIC bool is_eof(file_arg *active_file) { - return f_eof(active_file); + return f_eof(active_file) | f_error(active_file); } // Return 0 if there is no next character (EOF). From a8bbb21eeb5bcdab5eb71be3793c6efd3dd0622d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 29 Mar 2023 10:09:01 -0500 Subject: [PATCH 153/225] Use short-circuiting or (also may save some code size) Co-authored-by: Dan Halbert --- shared-module/os/getenv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/os/getenv.c b/shared-module/os/getenv.c index 6585aeb88c..76cbf48dae 100644 --- a/shared-module/os/getenv.c +++ b/shared-module/os/getenv.c @@ -72,7 +72,7 @@ STATIC void close_file(file_arg *active_file) { // nothing } STATIC bool is_eof(file_arg *active_file) { - return f_eof(active_file) | f_error(active_file); + return f_eof(active_file) || f_error(active_file); } // Return 0 if there is no next character (EOF). From 173bc198c604aa9d3475bed79acdaaf57f47f5dc Mon Sep 17 00:00:00 2001 From: Gregory Neverov <42853258+gneverov@users.noreply.github.com> Date: Wed, 29 Mar 2023 11:49:32 -0700 Subject: [PATCH 154/225] don't set tcp_err callback for listen sockets --- ports/raspberrypi/common-hal/socketpool/Socket.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/raspberrypi/common-hal/socketpool/Socket.c b/ports/raspberrypi/common-hal/socketpool/Socket.c index fe12f461fb..0696cc7ae9 100644 --- a/ports/raspberrypi/common-hal/socketpool/Socket.c +++ b/ports/raspberrypi/common-hal/socketpool/Socket.c @@ -706,8 +706,6 @@ bool socketpool_socket(socketpool_socketpool_obj_t *self, case MOD_NETWORK_SOCK_STREAM: { // Register the socket object as our callback argument. tcp_arg(socket->pcb.tcp, (void *)socket); - // Register our error callback. - tcp_err(socket->pcb.tcp, _lwip_tcp_error); break; } case MOD_NETWORK_SOCK_DGRAM: { @@ -916,10 +914,11 @@ void socketpool_socket_close(socketpool_socket_obj_t *socket) { case SOCKETPOOL_SOCK_STREAM: { // Deregister callback (pcb.tcp is set to NULL below so must deregister now) tcp_arg(socket->pcb.tcp, NULL); - tcp_err(socket->pcb.tcp, NULL); - tcp_recv(socket->pcb.tcp, NULL); if (socket->pcb.tcp->state != LISTEN) { + tcp_err(socket->pcb.tcp, NULL); + tcp_recv(socket->pcb.tcp, NULL); + // Schedule a callback to abort the connection if it's not cleanly closed after // the given timeout. The callback must be set before calling tcp_close since // the latter may free the pcb; if it doesn't then the callback will be active. @@ -977,6 +976,7 @@ void common_hal_socketpool_socket_connect(socketpool_socket_obj_t *socket, // Register our receive callback. MICROPY_PY_LWIP_ENTER tcp_recv(socket->pcb.tcp, _lwip_tcp_recv); + tcp_err(socket->pcb.tcp, _lwip_tcp_error); socket->state = STATE_CONNECTING; err = tcp_connect(socket->pcb.tcp, &dest, port, _lwip_tcp_connected); if (err != ERR_OK) { From 1a5afd485bfa5aa5269a25d0ab40ab47413cf3f6 Mon Sep 17 00:00:00 2001 From: Ted Hess Date: Wed, 29 Mar 2023 15:47:17 -0400 Subject: [PATCH 155/225] Allow web_workflow to startup after deep sleep alarm wakeup --- supervisor/shared/web_workflow/web_workflow.c | 1 + 1 file changed, 1 insertion(+) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 2caacbd39b..75ab78bf03 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -261,6 +261,7 @@ void supervisor_start_web_workflow(void) { const mcu_reset_reason_t reset_reason = common_hal_mcu_processor_get_reset_reason(); if (reset_reason != RESET_REASON_POWER_ON && reset_reason != RESET_REASON_RESET_PIN && + reset_reason != RESET_REASON_DEEP_SLEEP_ALARM && reset_reason != RESET_REASON_UNKNOWN && reset_reason != RESET_REASON_SOFTWARE) { return; From b746fd05baad4daf776366d7cf9e833c159cd075 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Wed, 29 Mar 2023 23:58:54 +0300 Subject: [PATCH 156/225] 24Mhz -> 240Mhz --- ports/espressif/common-hal/microcontroller/Processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/common-hal/microcontroller/Processor.c b/ports/espressif/common-hal/microcontroller/Processor.c index 1f09742955..c0e72c85b9 100644 --- a/ports/espressif/common-hal/microcontroller/Processor.c +++ b/ports/espressif/common-hal/microcontroller/Processor.c @@ -64,7 +64,7 @@ float common_hal_mcu_processor_get_voltage(void) { uint32_t common_hal_mcu_processor_get_frequency(void) { #if defined(CONFIG_IDF_TARGET_ESP32) - return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 100000; + return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000; #elif defined(CONFIG_IDF_TARGET_ESP32C3) return CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ * 1000000; #elif defined(CONFIG_IDF_TARGET_ESP32S2) From a10ce2170c26e532080f99ecaeb753267c8bb912 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 29 Mar 2023 17:16:39 -0400 Subject: [PATCH 157/225] doc typo fix in OnDiskGif --- shared-bindings/gifio/OnDiskGif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index a16cb92b4e..f6acccfabf 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -97,7 +97,7 @@ //| //| display_bus.send(42, struct.pack(">hh", 0, odg.bitmap.width - 1)) //| display_bus.send(43, struct.pack(">hh", 0, odg.bitmap.height - 1)) -//| display_bus.send(44, d.bitmap) +//| display_bus.send(44, odg.bitmap) //| //| # The following optional code will free the OnDiskGif and allocated resources //| # after use. This may be required before loading a new GIF in situations From 24ed20b1fcf5eaf2d3a99b2701402cd5a1afc90f Mon Sep 17 00:00:00 2001 From: CDario Date: Thu, 30 Mar 2023 09:06:34 +0000 Subject: [PATCH 158/225] Fixed boot led inverted status --- ports/espressif/boards/m5stack_stick_c/mpconfigboard.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h b/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h index c80dbc9ee2..1614a9ddad 100644 --- a/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h @@ -30,6 +30,7 @@ #define MICROPY_HW_MCU_NAME "ESP32" #define MICROPY_HW_LED_STATUS (&pin_GPIO10) +#define MICROPY_HW_LED_STATUS_INVERTED (1) #define CIRCUITPY_BOARD_I2C (2) #define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO22, .sda = &pin_GPIO21}, \ From 808df200ab658749e78caab83a6c27747da71b43 Mon Sep 17 00:00:00 2001 From: CDario Date: Thu, 30 Mar 2023 09:15:17 +0000 Subject: [PATCH 159/225] Added pin connected to AXP192 N_VBUSSEN --- ports/espressif/boards/m5stack_stick_c/pins.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/espressif/boards/m5stack_stick_c/pins.c b/ports/espressif/boards/m5stack_stick_c/pins.c index 65f0960382..5c8b897618 100644 --- a/ports/espressif/boards/m5stack_stick_c/pins.c +++ b/ports/espressif/boards/m5stack_stick_c/pins.c @@ -37,6 +37,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // internal devices interrupt { MP_ROM_QSTR(MP_QSTR_SYS_INT), MP_ROM_PTR(&pin_GPIO35) }, + // pmu AXP192 + { MP_ROM_QSTR(MP_QSTR_PMU_N_VBUSEN), MP_ROM_PTR(&pin_GPIO27) }, + // pdm microphone { MP_ROM_QSTR(MP_QSTR_PDM_MIC_CLK), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_PDM_MIC_DATA), MP_ROM_PTR(&pin_GPIO34) }, From 1ea6d7b9f4626028fdca2a6c46ffe8cc5b18f0a4 Mon Sep 17 00:00:00 2001 From: CDario Date: Thu, 30 Mar 2023 09:24:52 +0000 Subject: [PATCH 160/225] Updatate PMU initializaiton. Increased low battery waring levels and disabled some interrupts --- .../espressif/boards/m5stack_stick_c/axp192.h | 13 ++- .../espressif/boards/m5stack_stick_c/board.c | 80 ++++++++++++++++++- 2 files changed, 88 insertions(+), 5 deletions(-) mode change 100644 => 100755 ports/espressif/boards/m5stack_stick_c/axp192.h mode change 100644 => 100755 ports/espressif/boards/m5stack_stick_c/board.c diff --git a/ports/espressif/boards/m5stack_stick_c/axp192.h b/ports/espressif/boards/m5stack_stick_c/axp192.h old mode 100644 new mode 100755 index 78c2d253e4..aa8f6367a7 --- a/ports/espressif/boards/m5stack_stick_c/axp192.h +++ b/ports/espressif/boards/m5stack_stick_c/axp192.h @@ -144,21 +144,28 @@ #define AXP192_BATT_TEMP_HIGH_THRESH 0x39 #define AXP192_BATT_TEMP_HIGH_THRESH_DEFAULT 0b11111100 +#define AXP192_APS_LOW_BATT_LEVEL_1 0x3A +#define AXP192_APS_LOW_BATT_LEVEL_2 0x3B +#define AXP192_APS_LOW_BATT_VOLTAGE_3_695V 0b10010100 +#define AXP192_APS_LOW_BATT_VOLTAGE_3_600V 0b10000011 + #define AXP192_IRQ_1_ENABLE 0x40 #define AXP192_IRQ_2_ENABLE 0x41 #define AXP192_IRQ_3_ENABLE 0x42 +#define AXP192_IRQ_3_PEK_SHORT_PRESS 0b00000010 +#define AXP192_IRQ_3_PEK_LONG_PRESS 0b00000001 #define AXP192_IRQ_4_ENABLE 0x43 +#define AXP192_IRQ_4_LOW_VOLTAGE_WARNING 0b00000001 #define AXP192_IRQ_5_ENABLE 0x4a +#define AXP192_IRQ_X_DISABLE_ALL 0b00000000 + #define AXP192_IRQ_1_STATUS 0x44 #define AXP192_IRQ_2_STATUS 0x45 #define AXP192_IRQ_3_STATUS 0x46 #define AXP192_IRQ_4_STATUS 0x47 #define AXP192_IRQ_5_STATUS 0x4d -#define AXP192_IRQ_3_PEK_SHORT_PRESS 0b00000010 -#define AXP192_IRQ_3_PEK_LONG_PRESS 0b00000001 - #define AXP192_ADC_ACIN_VOLTAGE_H 0x56 #define AXP192_ADC_ACIN_VOLTAGE_L 0x57 #define AXP192_ADC_ACIN_CURRENT_H 0x58 diff --git a/ports/espressif/boards/m5stack_stick_c/board.c b/ports/espressif/boards/m5stack_stick_c/board.c old mode 100644 new mode 100755 index ae29c9fa76..2f993d4a05 --- a/ports/espressif/boards/m5stack_stick_c/board.c +++ b/ports/espressif/boards/m5stack_stick_c/board.c @@ -127,6 +127,24 @@ static bool pmic_init(void) { return false; } + // Reg: 3Ah + // APS Low battery warning level 1: 3.695V + write_buf[0] = AXP192_APS_LOW_BATT_LEVEL_1; + write_buf[1] = AXP192_APS_LOW_BATT_VOLTAGE_3_695V; + rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf)); + if (rc != 0) { + return false; + } + + // Reg: 3Bh + // APS Low battery warning level 2: 3.600V + write_buf[0] = AXP192_APS_LOW_BATT_LEVEL_2; + write_buf[1] = AXP192_APS_LOW_BATT_VOLTAGE_3_600V; + rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf)); + if (rc != 0) { + return false; + } + // Reg: 82h // ADC all on write_buf[0] = AXP192_ADC_ENABLE_1; @@ -204,7 +222,7 @@ static bool pmic_init(void) { return false; } - // Reg: 28h + // Reg: 26h // DCDC1 (ESP32 VDD): 3.350V write_buf[0] = AXP192_DCDC1_OUT_VOLTAGE; write_buf[1] = AXP192_DCDC1_OUT_VOLTAGE_3_350V; @@ -213,6 +231,54 @@ static bool pmic_init(void) { return false; } + // Reg: 40h + // IRQ enable control register 1 + write_buf[0] = AXP192_IRQ_1_ENABLE; + write_buf[1] = AXP192_IRQ_X_DISABLE_ALL; + rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf)); + if (rc != 0) { + return false; + } + + // Reg: 41h + // IRQ enable control register 2 + write_buf[0] = AXP192_IRQ_2_ENABLE; + write_buf[1] = AXP192_IRQ_X_DISABLE_ALL; + rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf)); + if (rc != 0) { + return false; + } + + // Reg: 42h + // IRQ enable control register 3 + // Enable power on key short and long press interrupt + write_buf[0] = AXP192_IRQ_2_ENABLE; + write_buf[1] = AXP192_IRQ_3_PEK_SHORT_PRESS | + AXP192_IRQ_3_PEK_LONG_PRESS; + rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf)); + if (rc != 0) { + return false; + } + + // Reg: 43h + // IRQ enable control register 4 + // Enable power on key short and long press interrupt + write_buf[0] = AXP192_IRQ_2_ENABLE; + write_buf[1] = AXP192_IRQ_4_LOW_VOLTAGE_WARNING; + rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf)); + if (rc != 0) { + return false; + } + + // Reg: 44h + // IRQ enable control register 5 + write_buf[0] = AXP192_IRQ_2_ENABLE; + write_buf[1] = AXP192_IRQ_X_DISABLE_ALL; + rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf)); + if (rc != 0) { + return false; + } + return true; } @@ -279,7 +345,17 @@ void board_init(void) { } if (!display_init()) { - mp_printf(&mp_plat_print, "could not initialize ili9342c LCD"); + mp_printf(&mp_plat_print, "could not initialize the display"); return; } } + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Set IR led gpio high to prevent power drain from the led + if (pin_number == 9) { + gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(pin_number, true); + return true; + } + return false; +} From 6ad053e40375169e907dc5f4949775bef3c6b332 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Thu, 30 Mar 2023 08:51:52 -0400 Subject: [PATCH 161/225] correcting feedback --- locale/circuitpython.pot | 23 +++++------ shared-bindings/bitmaptools/__init__.c | 53 ++++++++++++++++++++++---- shared-module/bitmaptools/__init__.c | 5 +++ 3 files changed, 59 insertions(+), 22 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b5026f7829..21196702f2 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -122,6 +122,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1217,6 +1218,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1224,6 +1226,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "" @@ -3827,11 +3830,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3856,14 +3855,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -3905,6 +3900,10 @@ msgstr "" msgid "queue overflow" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "radius must be greater than zero" +msgstr "" + #: py/parse.c msgid "raw f-strings are not supported" msgstr "" @@ -4276,10 +4275,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 2a23a2c05d..9aa7362269 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -871,20 +871,48 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_dither_obj, 0, bitmaptools_dither); // requires all 5 arguments //| def draw_circle( -//| dest_bitmap: displayio.Bitmap, x0: int, y0: int, radius: int, value: int +//| dest_bitmap: displayio.Bitmap, x: int, y: int, radius: int, value: int //| ) -> None: //| """Draws a circle into a bitmap specified using a center (x0,y0) and radius r. //| //| :param bitmap dest_bitmap: Destination bitmap that will be written into -//| :param int x0: x-pixel position of the circle's center -//| :param int y0: y-pixel position of the circle's center +//| :param int x: x-pixel position of the circle's center +//| :param int y: y-pixel position of the circle's center //| :param int radius: circle's radius //| :param int value: Bitmap palette index that will be written into the -//| circle in the destination bitmap""" +//| circle in the destination bitmap +//| +//| .. code-block:: Python +//| +//| import board +//| import displayio +//| import bitmaptools +//| +//| display = board.DISPLAY +//| main_group = displayio.Group() +//| display.root_group = main_group +//| +//| palette = displayio.Palette(2) +//| palette[0] = 0xffffff +//| palette[1] = 0x440044 +//| +//| bmp = displayio.Bitmap(128,128, 2) +//| bmp.fill(0) +//| +//| bitmaptools.circle(64,64, 32, 1) +//| +//| tilegrid = displayio.TileGrid(bitmap=bmp, pixel_shader=palette) +//| main_group.append(tilegrid) +//| +//| while True: +//| pass +//| +//| """ +//| //| ... //| STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum {ARG_dest_bitmap, ARG_x0, ARG_y0, ARG_radius, ARG_value}; + enum {ARG_dest_bitmap, ARG_x, ARG_y, ARG_radius, ARG_value}; static const mp_arg_t allowed_args[] = { {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, @@ -906,12 +934,21 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_a } - int16_t x0 = args[ARG_x0].u_int; - int16_t y0 = args[ARG_y0].u_int; + int16_t x = args[ARG_x].u_int; + int16_t y = args[ARG_y].u_int; int16_t radius = args[ARG_radius].u_int; + if (x < 0 || x >= destination->width) { + mp_raise_ValueError(translate("out of range of target")); + } + if (y < 0 || y >= destination->height) { + mp_raise_ValueError(translate("out of range of target")); + } + if (radius < 0) { + mp_raise_ValueError(translate("radius must be greater than zero")); + } - common_hal_bitmaptools_draw_circle(destination, x0, y0, radius, value); + common_hal_bitmaptools_draw_circle(destination, x, y, radius, value); return mp_const_none; } diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 449815533d..7809e5fc87 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -931,6 +931,11 @@ STATIC void draw_circle(displayio_bitmap_t *destination, mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x0); mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y0); + x0 = MIN(x0, destination->width); + x0 = MAX(0, x0); + y0 = MIN(y0, destination->height); + y0 = MIN(0, y0); + BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x0, y0, radius); y = radius; From 844ea2f60b1b4f8c6155a2cd8cea8c0d15b9e4af Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:28:15 -0400 Subject: [PATCH 162/225] Update shared-bindings/bitmaptools/__init__.c Co-authored-by: Dan Halbert --- shared-bindings/bitmaptools/__init__.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 9aa7362269..7754bf57eb 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -916,10 +916,10 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_a static const mp_arg_t allowed_args[] = { {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, - {MP_QSTR_x0, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, - {MP_QSTR_y0, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, - {MP_QSTR_radius, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, - {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT}, + {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT}, + {MP_QSTR_radius, MP_ARG_REQUIRED | MP_ARG_INT}, + {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT}, }; 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); From 4e332fb1c493d8498b7f71347eefcf2b9caacc95 Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:28:42 -0400 Subject: [PATCH 163/225] Update shared-bindings/bitmaptools/__init__.h Co-authored-by: Dan Halbert --- shared-bindings/bitmaptools/__init__.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/bitmaptools/__init__.h b/shared-bindings/bitmaptools/__init__.h index 3c356e761e..21fb1b50ab 100644 --- a/shared-bindings/bitmaptools/__init__.h +++ b/shared-bindings/bitmaptools/__init__.h @@ -65,7 +65,7 @@ void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination, uint32_t value); void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination, - int16_t x0, int16_t y0, + int16_t x, int16_t y, int16_t radius, uint32_t value); From 533f532ff24f70538b9891aef9c0c45ce46dbd96 Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:29:18 -0400 Subject: [PATCH 164/225] Update shared-module/bitmaptools/__init__.c Co-authored-by: Dan Halbert --- shared-module/bitmaptools/__init__.c | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 7809e5fc87..1ab9c72de9 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -923,39 +923,39 @@ void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitma } STATIC void draw_circle(displayio_bitmap_t *destination, - int16_t x0, int16_t y0, + int16_t x, int16_t y, int16_t radius, uint32_t value) { - int16_t d, y; + int16_t d, yb; - mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x0); - mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y0); + mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x); + mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y); - x0 = MIN(x0, destination->width); - x0 = MAX(0, x0); - y0 = MIN(y0, destination->height); - y0 = MIN(0, y0); + x = MIN(x, destination->width); + x = MAX(0, x); + y = MIN(y, destination->height); + y = MIN(0, y); - BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x0, y0, radius); + BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x, y, radius); - y = radius; + yb = radius; d = 3 - 2 * radius; // Bresenham's circle algorithm - for (int x = 0; x <= y; x++) { - displayio_bitmap_write_pixel(destination, x + x0, y + y0, value); - displayio_bitmap_write_pixel(destination, -x + x0, -y + y0, value); - displayio_bitmap_write_pixel(destination, -x + x0, y + y0, value); - displayio_bitmap_write_pixel(destination, x + x0, -y + y0, value); - displayio_bitmap_write_pixel(destination, y + x0, x + y0, value); - displayio_bitmap_write_pixel(destination, -y + x0, x + y0, value); - displayio_bitmap_write_pixel(destination, -y + x0, -x + y0, value); - displayio_bitmap_write_pixel(destination, y + x0, -x + y0, value); + for (int xb = 0; x <= yb; xb++) { + displayio_bitmap_write_pixel(destination, xb + x, yb + y, value); + displayio_bitmap_write_pixel(destination, -xb + x, -yb + y, value); + displayio_bitmap_write_pixel(destination, -xb + x, yb + y, value); + displayio_bitmap_write_pixel(destination, xb + x, -yb + y, value); + displayio_bitmap_write_pixel(destination, yb + x, xb + y, value); + displayio_bitmap_write_pixel(destination, -yb + x, xb + y, value); + displayio_bitmap_write_pixel(destination, -yb + x, -xb + y, value); + displayio_bitmap_write_pixel(destination, yb + x, -xb + y, value); if (d <= 0) { - d = d + (4 * x) + 6; + d = d + (4 * xb) + 6; } else { - d = d + 4 * (x - y) + 10; - y = y - 1; + d = d + 4 * (xb - yb) + 10; + yb = yb - 1; } } } From f6a0fb20f2d41d8378abb467f7822d057fe1c74f Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:29:39 -0400 Subject: [PATCH 165/225] Update shared-module/bitmaptools/__init__.c Co-authored-by: Dan Halbert --- shared-module/bitmaptools/__init__.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 1ab9c72de9..105a7c1e77 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -961,7 +961,7 @@ STATIC void draw_circle(displayio_bitmap_t *destination, } void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination, - int16_t x0, int16_t y0, + int16_t x, int16_t y, int16_t radius, uint32_t value) { @@ -969,10 +969,10 @@ void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination, // update the dirty area int16_t xbb0, xbb1, ybb0, ybb1; - xbb0 = x0 - radius; - xbb1 = x0 + radius; - ybb0 = y0 - radius; - ybb1 = y0 + radius; + xbb0 = x - radius; + xbb1 = x + radius; + ybb0 = y - radius; + ybb1 = y + radius; displayio_area_t area = { xbb0, ybb0, xbb1, ybb1, NULL }; displayio_area_t bitmap_area = { 0, 0, destination->width, destination->height, NULL }; @@ -980,5 +980,5 @@ void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination, displayio_bitmap_set_dirty_area(destination, &area); - draw_circle(destination, x0, y0, radius, value); + draw_circle(destination, x, y, radius, value); } From 9a77199f2e92512ab3c0dcc20ec2279040a1813c Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:43:48 -0400 Subject: [PATCH 166/225] Update shared-bindings/bitmaptools/__init__.c Co-authored-by: Dan Halbert --- shared-bindings/bitmaptools/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 7754bf57eb..5ae5182c59 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -915,7 +915,7 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_a enum {ARG_dest_bitmap, ARG_x, ARG_y, ARG_radius, ARG_value}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT}, {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT}, {MP_QSTR_radius, MP_ARG_REQUIRED | MP_ARG_INT}, From 4986ad6d6b0cdcbfd24031492986cd178522d6a0 Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:43:57 -0400 Subject: [PATCH 167/225] Update shared-module/bitmaptools/__init__.c Co-authored-by: Dan Halbert --- shared-module/bitmaptools/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 105a7c1e77..0c9d2a1f6a 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -928,8 +928,8 @@ STATIC void draw_circle(displayio_bitmap_t *destination, int16_t d, yb; - mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x); - mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y); + mp_arg_validate_int_range(x, SHRT_MIN, SHRT_MAX, MP_QSTR_x); + mp_arg_validate_int_range(y, SHRT_MIN, SHRT_MAX, MP_QSTR_y); x = MIN(x, destination->width); x = MAX(0, x); From 96b2604083837b896bb9060f5fbf93df81f58c9c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 30 Mar 2023 15:39:25 -0500 Subject: [PATCH 168/225] sort new boards & new languages lists in circuitpython.org update PR --- tools/build_board_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 01d935ac46..f73f83b5ee 100755 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -136,10 +136,10 @@ def create_pr(changes, updated, git_info, user): pr_title = "Automated website update for release {}".format(changes["new_release"]) boards = "" if changes["new_boards"]: - boards = "New boards:\n* " + "\n* ".join(changes["new_boards"]) + boards = "New boards:\n* " + "\n* ".join(sorted(changes["new_boards"])) languages = "" if changes["new_languages"]: - languages = "New languages:\n* " + "\n* ".join(changes["new_languages"]) + languages = "New languages:\n* " + "\n* ".join(sorted(changes["new_languages"])) message = "Automated website update for release {} by Blinka.\n\n{}\n\n{}\n".format( changes["new_release"], boards, languages ) From 1931b6c0424f8b8ed636321d31e87db96de53018 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Thu, 30 Mar 2023 18:08:17 -0400 Subject: [PATCH 169/225] fixing algorithm and MAX --- shared-module/bitmaptools/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 0c9d2a1f6a..0ded6d6abb 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -934,7 +934,7 @@ STATIC void draw_circle(displayio_bitmap_t *destination, x = MIN(x, destination->width); x = MAX(0, x); y = MIN(y, destination->height); - y = MIN(0, y); + y = MAX(0, y); BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x, y, radius); @@ -942,7 +942,7 @@ STATIC void draw_circle(displayio_bitmap_t *destination, d = 3 - 2 * radius; // Bresenham's circle algorithm - for (int xb = 0; x <= yb; xb++) { + for (int xb = 0; xb <= yb; xb++) { displayio_bitmap_write_pixel(destination, xb + x, yb + y, value); displayio_bitmap_write_pixel(destination, -xb + x, -yb + y, value); displayio_bitmap_write_pixel(destination, -xb + x, yb + y, value); From 2d48e9b0b7e81a9ddd735cc1d871cddb374fb7bb Mon Sep 17 00:00:00 2001 From: Dogus Cendek <55203951+DogushC@users.noreply.github.com> Date: Fri, 31 Mar 2023 11:44:23 +0300 Subject: [PATCH 170/225] Fix VID and Local_Hostname of DeneyapKart1A_v2 Fix VID and Local_Hostname of DeneyapKart1A_v2 --- ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk | 2 +- ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk b/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk index 1ec7c73185..5fa5d4822f 100644 --- a/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk +++ b/ports/espressif/boards/deneyap_kart_1a_v2/mpconfigboard.mk @@ -1,4 +1,4 @@ -USB_VID = 0x239A +USB_VID = 0x303A USB_PID = 0x8148 USB_PRODUCT = "Deneyap Kart 1A v2" diff --git a/ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig b/ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig index 4e99a09f2e..2cdb172e06 100644 --- a/ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig +++ b/ports/espressif/boards/deneyap_kart_1a_v2/sdkconfig @@ -41,7 +41,7 @@ CONFIG_SPIRAM_MEMTEST=y # # LWIP # -CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +CONFIG_LWIP_LOCAL_HOSTNAME="DeneyapKart1A_v2" # end of LWIP # end of Component config From dea5d1c4eaeea863f344af34f660082156c69708 Mon Sep 17 00:00:00 2001 From: Dogus Cendek <55203951+DogushC@users.noreply.github.com> Date: Fri, 31 Mar 2023 11:50:43 +0300 Subject: [PATCH 171/225] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87bd49027d..942a51afdc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.0.1 hooks: - id: check-yaml - id: end-of-file-fixer From 72614ed09e65af1c7ae6ddb0d7237a2a58abf9a5 Mon Sep 17 00:00:00 2001 From: Ettore Atalan Date: Wed, 29 Mar 2023 18:29:49 +0000 Subject: [PATCH 172/225] Translated using Weblate (German) Currently translated at 100.0% (1002 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/de/ --- locale/de_DE.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index ab543ccea4..3c0c0c8233 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -6,8 +6,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-03-28 14:18+0000\n" -"Last-Translator: Luc \n" +"PO-Revision-Date: 2023-03-31 14:39+0000\n" +"Last-Translator: Ettore Atalan \n" "Language: de_DE\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1305,7 +1305,7 @@ msgstr "Ungültige data_pins[%d]" #: shared-module/msgpack/__init__.c msgid "Invalid format" -msgstr "" +msgstr "Ungültiges Format" #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" From 3b60215ac9f3de327a22f613a85630436d706698 Mon Sep 17 00:00:00 2001 From: Jose David M Date: Thu, 30 Mar 2023 14:05:52 +0000 Subject: [PATCH 173/225] Translated using Weblate (Spanish) Currently translated at 100.0% (1002 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/es.po b/locale/es.po index d5db9c0c88..266ac9edea 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-03-25 02:42+0000\n" +"PO-Revision-Date: 2023-03-31 14:39+0000\n" "Last-Translator: Jose David M \n" "Language-Team: \n" "Language: es\n" @@ -1315,7 +1315,7 @@ msgstr "Inválidos los data_pins[%d]" #: shared-module/msgpack/__init__.c msgid "Invalid format" -msgstr "" +msgstr "Formato inválido" #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" From cef262fd5cbe8cbe13a842981e63bfd2fef7ca2d Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Tue, 28 Mar 2023 17:52:34 +0000 Subject: [PATCH 174/225] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1002 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 6968cfbb84..802966354a 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: 2023-03-25 02:42+0000\n" +"PO-Revision-Date: 2023-03-31 14:39+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -1311,7 +1311,7 @@ msgstr "data_pins[%d] inválido" #: shared-module/msgpack/__init__.c msgid "Invalid format" -msgstr "" +msgstr "Formato inválido" #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" From e4a002b96cfcbd54fe3e76294c0e2972a9e5420b Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Wed, 29 Mar 2023 08:58:07 +0000 Subject: [PATCH 175/225] Translated using Weblate (Swedish) Currently translated at 100.0% (1002 of 1002 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 1cef8c6d7a..a7dee9421d 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: 2023-03-25 02:42+0000\n" +"PO-Revision-Date: 2023-03-31 14:39+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -1296,7 +1296,7 @@ msgstr "Ogiltig data_pins[%d]" #: shared-module/msgpack/__init__.c msgid "Invalid format" -msgstr "" +msgstr "Ogiltigt format" #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" From 5c429320a8a2f7219e0f2c80689f3dbff4b84cab Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 26 Dec 2022 12:28:44 -0500 Subject: [PATCH 176/225] Add wifi.radio.connected, wifi.radio.ap_active --- ports/espressif/common-hal/wifi/Radio.c | 8 ++++ ports/raspberrypi/common-hal/wifi/Radio.c | 8 ++++ shared-bindings/wifi/Radio.c | 47 ++++++++++++++--------- shared-bindings/wifi/Radio.h | 2 + 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index acd6ae53bc..4ca3bf1a6c 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -242,6 +242,10 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_ esp_wifi_set_config(WIFI_IF_AP, config); } +bool common_hal_wifi_radio_get_ap_active(wifi_radio_obj_t *self) { + return self->ap_mode; +} + void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self) { set_mode_ap(self, false); } @@ -347,6 +351,10 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t return WIFI_RADIO_ERROR_NONE; } +bool common_hal_wifi_radio_get_connected(wifi_radio_obj_t *self) { + return self->sta_mode && esp_netif_is_netif_up(self->netif); +} + mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { if (!esp_netif_is_netif_up(self->netif)) { return mp_const_none; diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index 2ed19a96e7..0ef4f8bb76 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -186,6 +186,10 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_ bindings_cyw43_wifi_enforce_pm(); } +bool common_hal_wifi_radio_get_ap_active(wifi_radio_obj_t *self) { + return cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_AP) == CYW43_LINK_UP; +} + void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self) { if (!common_hal_wifi_radio_get_enabled(self)) { mp_raise_RuntimeError(translate("wifi is not enabled")); @@ -275,6 +279,10 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t return WIFI_RADIO_ERROR_UNSPECIFIED; } +bool common_hal_wifi_radio_get_connected(wifi_radio_obj_t *self) { + return cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA) == CYW43_LINK_UP; +} + mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { mp_raise_NotImplementedError(NULL); } diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index fc3cc345b8..9475ee3b31 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -310,7 +310,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station); //| authmode: Optional[AuthMode] = None, //| max_connections: Optional[int] = 4 //| ) -> None: -//| """Starts an Access Point with the specified ssid and password. +//| """Starts running an access point with the specified ssid and password. //| //| If ``channel`` is given, the access point will use that channel unless //| a station is already operating on a different channel. @@ -376,7 +376,7 @@ STATIC mp_obj_t wifi_radio_start_ap(size_t n_args, const mp_obj_t *pos_args, mp_ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_start_ap_obj, 1, wifi_radio_start_ap); //| def stop_ap(self) -> None: -//| """Stops the Access Point.""" +//| """Stops the access point.""" //| ... STATIC mp_obj_t wifi_radio_stop_ap(mp_obj_t self) { common_hal_wifi_radio_stop_ap(self); @@ -384,6 +384,16 @@ STATIC mp_obj_t wifi_radio_stop_ap(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_ap_obj, wifi_radio_stop_ap); +//| ap_active: bool +//| """True if running as an access point. (read-only)""" +STATIC mp_obj_t wifi_radio_get_ap_active(mp_obj_t self) { + return mp_obj_new_bool(common_hal_wifi_radio_get_ap_active(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_active_obj, wifi_radio_get_ap_active); + +MP_PROPERTY_GETTER(wifi_radio_ap_active_obj, + (mp_obj_t)&wifi_radio_get_ap_active_obj); + //| def connect( //| self, //| ssid: Union[str | ReadableBuffer], @@ -464,11 +474,20 @@ STATIC mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_m } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_connect_obj, 1, wifi_radio_connect); +//| connected: bool +//| """True if connected to an access point (read-only).""" +STATIC mp_obj_t wifi_radio_get_connected(mp_obj_t self) { + return mp_obj_new_bool(common_hal_wifi_radio_get_connected(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_connected_obj, wifi_radio_get_connected); + +MP_PROPERTY_GETTER(wifi_radio_connected_obj, + (mp_obj_t)&wifi_radio_get_connected_obj); + //| ipv4_gateway: Optional[ipaddress.IPv4Address] -//| """IP v4 Address of the station gateway when connected to an access point. None otherwise.""" +//| """IP v4 Address of the station gateway when connected to an access point. None otherwise. (read-only)""" STATIC mp_obj_t wifi_radio_get_ipv4_gateway(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_gateway(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_gateway_obj, wifi_radio_get_ipv4_gateway); @@ -476,10 +495,9 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_gateway_obj, (mp_obj_t)&wifi_radio_get_ipv4_gateway_obj); //| ipv4_gateway_ap: Optional[ipaddress.IPv4Address] -//| """IP v4 Address of the access point gateway, when enabled. None otherwise.""" +//| """IP v4 Address of the access point gateway, when enabled. None otherwise. (read-only)""" STATIC mp_obj_t wifi_radio_get_ipv4_gateway_ap(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_gateway_ap(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_gateway_ap_obj, wifi_radio_get_ipv4_gateway_ap); @@ -487,10 +505,9 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_gateway_ap_obj, (mp_obj_t)&wifi_radio_get_ipv4_gateway_ap_obj); //| ipv4_subnet: Optional[ipaddress.IPv4Address] -//| """IP v4 Address of the station subnet when connected to an access point. None otherwise.""" +//| """IP v4 Address of the station subnet when connected to an access point. None otherwise. (read-only)""" STATIC mp_obj_t wifi_radio_get_ipv4_subnet(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_subnet(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_subnet_obj, wifi_radio_get_ipv4_subnet); @@ -498,10 +515,9 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_subnet_obj, (mp_obj_t)&wifi_radio_get_ipv4_subnet_obj); //| ipv4_subnet_ap: Optional[ipaddress.IPv4Address] -//| """IP v4 Address of the access point subnet, when enabled. None otherwise.""" +//| """IP v4 Address of the access point subnet, when enabled. None otherwise. (read-only)""" STATIC mp_obj_t wifi_radio_get_ipv4_subnet_ap(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_subnet_ap(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_subnet_ap_obj, wifi_radio_get_ipv4_subnet_ap); @@ -538,10 +554,9 @@ STATIC mp_obj_t wifi_radio_set_ipv4_address(size_t n_args, const mp_obj_t *pos_a STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_set_ipv4_address_obj, 1, wifi_radio_set_ipv4_address); //| ipv4_address: Optional[ipaddress.IPv4Address] -//| """IP v4 Address of the station when connected to an access point. None otherwise.""" +//| """IP v4 Address of the station when connected to an access point. None otherwise. (read-only)""" STATIC mp_obj_t _wifi_radio_get_ipv4_address(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_address(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_address_obj, _wifi_radio_get_ipv4_address); @@ -552,7 +567,6 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_address_obj, //| """IP v4 Address of the access point, when enabled. None otherwise.""" STATIC mp_obj_t wifi_radio_get_ipv4_address_ap(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_address_ap(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_address_ap_obj, wifi_radio_get_ipv4_address_ap); @@ -563,7 +577,6 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_address_ap_obj, //| """IP v4 Address of the DNS server to be used.""" STATIC mp_obj_t wifi_radio_get_ipv4_dns(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_dns(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_dns_obj, wifi_radio_get_ipv4_dns); @@ -582,7 +595,6 @@ MP_PROPERTY_GETSET(wifi_radio_ipv4_dns_obj, //| """Network object containing BSSID, SSID, authmode, channel, country and RSSI when connected to an access point. None otherwise.""" STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) { return common_hal_wifi_radio_get_ap_info(self); - } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_info_obj, wifi_radio_get_ap_info); @@ -656,12 +668,14 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_start_ap), MP_ROM_PTR(&wifi_radio_start_ap_obj) }, { MP_ROM_QSTR(MP_QSTR_stop_ap), MP_ROM_PTR(&wifi_radio_stop_ap_obj) }, + { MP_ROM_QSTR(MP_QSTR_ap_active), MP_ROM_PTR(&wifi_radio_ap_active_obj) }, { MP_ROM_QSTR(MP_QSTR_start_dhcp), MP_ROM_PTR(&wifi_radio_start_dhcp_client_obj) }, { MP_ROM_QSTR(MP_QSTR_stop_dhcp), MP_ROM_PTR(&wifi_radio_stop_dhcp_client_obj) }, { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&wifi_radio_connect_obj) }, // { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) }, + { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&wifi_radio_connected_obj) }, { MP_ROM_QSTR(MP_QSTR_ap_info), MP_ROM_PTR(&wifi_radio_ap_info_obj) }, { MP_ROM_QSTR(MP_QSTR_ipv4_dns), MP_ROM_PTR(&wifi_radio_ipv4_dns_obj) }, @@ -674,9 +688,6 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_set_ipv4_address), MP_ROM_PTR(&wifi_radio_set_ipv4_address_obj) }, - // { MP_ROM_QSTR(MP_QSTR_access_point_active), MP_ROM_PTR(&wifi_radio_access_point_active_obj) }, - // { MP_ROM_QSTR(MP_QSTR_start_access_point), MP_ROM_PTR(&wifi_radio_start_access_point_obj) }, - { MP_ROM_QSTR(MP_QSTR_ping), MP_ROM_PTR(&wifi_radio_ping_obj) }, }; diff --git a/shared-bindings/wifi/Radio.h b/shared-bindings/wifi/Radio.h index dbaeb9cce8..1fb70ef818 100644 --- a/shared-bindings/wifi/Radio.h +++ b/shared-bindings/wifi/Radio.h @@ -95,11 +95,13 @@ extern void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, uint32_t authmodes, uint8_t max_connections); extern void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self); +extern bool common_hal_wifi_radio_get_ap_active(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_start_dhcp_client(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_stop_dhcp_client(wifi_radio_obj_t *self); extern wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t *bssid, size_t bssid_len); +extern bool common_hal_wifi_radio_get_connected(wifi_radio_obj_t *self); extern mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self); extern mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self); From df46636c5e699fd2e98f4897285fd221ee129488 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Fri, 31 Mar 2023 20:15:07 -0400 Subject: [PATCH 177/225] improving range validation --- locale/circuitpython.pot | 4 ---- shared-bindings/bitmaptools/__init__.c | 12 +++--------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 21196702f2..77d5aab1d3 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -3900,10 +3900,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/bitmaptools/__init__.c -msgid "radius must be greater than zero" -msgstr "" - #: py/parse.c msgid "raw f-strings are not supported" msgstr "" diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 5ae5182c59..629d602846 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -938,15 +938,9 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_a int16_t y = args[ARG_y].u_int; int16_t radius = args[ARG_radius].u_int; - if (x < 0 || x >= destination->width) { - mp_raise_ValueError(translate("out of range of target")); - } - if (y < 0 || y >= destination->height) { - mp_raise_ValueError(translate("out of range of target")); - } - if (radius < 0) { - mp_raise_ValueError(translate("radius must be greater than zero")); - } + mp_arg_validate_int_range(x, 0, destination->width, MP_QSTR_x) + mp_arg_validate_int_range(y, 0, destination->height, MP_QSTR_y) + mp_arg_validate_int_min(radius, 0, MP_QSTR_radius) common_hal_bitmaptools_draw_circle(destination, x, y, radius, value); From 2f3ea812776e6450a07710c32edeb78e72c525b3 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Fri, 31 Mar 2023 20:29:29 -0400 Subject: [PATCH 178/225] correcting --- shared-bindings/bitmaptools/__init__.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 629d602846..d0aea33ef9 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -938,9 +938,9 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_a int16_t y = args[ARG_y].u_int; int16_t radius = args[ARG_radius].u_int; - mp_arg_validate_int_range(x, 0, destination->width, MP_QSTR_x) - mp_arg_validate_int_range(y, 0, destination->height, MP_QSTR_y) - mp_arg_validate_int_min(radius, 0, MP_QSTR_radius) + mp_arg_validate_int_range(x, 0, destination->width, MP_QSTR_x); + mp_arg_validate_int_range(y, 0, destination->height, MP_QSTR_y); + mp_arg_validate_int_min(radius, 0, MP_QSTR_radius); common_hal_bitmaptools_draw_circle(destination, x, y, radius, value); From 0aacb146efd6a9618fda692096b62cf4911a0c29 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 31 Mar 2023 22:27:21 -0400 Subject: [PATCH 179/225] take wifi.radio.enabled into account --- ports/espressif/common-hal/wifi/Radio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 4ca3bf1a6c..0ce535899a 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -243,7 +243,7 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_ } bool common_hal_wifi_radio_get_ap_active(wifi_radio_obj_t *self) { - return self->ap_mode; + return self->ap_mode && esp_netif_is_netif_up(self->ap_netif); } void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self) { From 02f8a45dfad42dbaa9d1049e65eb4eefbc1cf5c0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 31 Mar 2023 10:51:03 -0500 Subject: [PATCH 180/225] synthio: allow increasing number of channels 12 channels works well on metro m7 --- ports/mimxrt10xx/mpconfigport.mk | 1 + py/circuitpy_mpconfig.mk | 4 + shared-bindings/audiocore/RawSample.c | 2 +- shared-module/synthio/MidiTrack.c | 105 +++++++++++++++----------- shared-module/synthio/MidiTrack.h | 2 +- 5 files changed, 68 insertions(+), 46 deletions(-) diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index b03535b6b2..ae22cb69f4 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -18,6 +18,7 @@ CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_AUDIOMP3 = 1 CIRCUITPY_AUDIOPWMIO = 1 +CIRCUITPY_SYNTHIO_MAX_CHANNELS = 12 CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index b8e2178870..3e5acd908c 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -437,6 +437,10 @@ CFLAGS += -DCIRCUITPY_SUPERVISOR=$(CIRCUITPY_SUPERVISOR) CIRCUITPY_SYNTHIO ?= $(CIRCUITPY_AUDIOCORE) CFLAGS += -DCIRCUITPY_SYNTHIO=$(CIRCUITPY_SYNTHIO) +CIRCUITPY_SYNTHIO_MAX_CHANNELS ?= 2 +CFLAGS += -DCIRCUITPY_SYNTHIO_MAX_CHANNELS=$(CIRCUITPY_SYNTHIO_MAX_CHANNELS) + + CIRCUITPY_SYS ?= 1 CFLAGS += -DCIRCUITPY_SYS=$(CIRCUITPY_SYS) diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index d185476f03..39992f87c1 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -40,7 +40,7 @@ //| def __init__( //| self, buffer: ReadableBuffer, *, channel_count: int = 1, sample_rate: int = 8000 //| ) -> None: -//| """Create a RawSample based on the given buffer of signed values. If channel_count is more than +//| """Create a RawSample based on the given buffer of values. If channel_count is more than //| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the //| first sample will be for channel 1, the second sample will be for channel two, the third for //| channel 1 and so on. diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index f02747d734..da810b99f3 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -27,7 +27,6 @@ #include "py/runtime.h" #include "shared-bindings/synthio/MidiTrack.h" -#define LOUDNESS 0x4000 // 0.5 #define BITS_PER_SAMPLE 16 #define BYTES_PER_SAMPLE (BITS_PER_SAMPLE / 8) #define SILENCE 0x80 @@ -47,36 +46,51 @@ STATIC uint8_t parse_note(const uint8_t *buffer, uint32_t len, uint32_t *pos) { return note; } -STATIC void terminate_span(synthio_miditrack_obj_t *self, uint16_t *dur, uint16_t *max_dur) { +STATIC void terminate_span(synthio_miditrack_obj_t *self, uint16_t *dur) { if (*dur) { self->track[self->total_spans - 1].dur = *dur; - if (*dur > *max_dur) { - *max_dur = *dur; - } *dur = 0; } else { self->total_spans--; } } -STATIC void add_span(synthio_miditrack_obj_t *self, uint8_t note1, uint8_t note2) { - synthio_midi_span_t span = { 0, {note1, note2} }; +STATIC void add_span(synthio_miditrack_obj_t *self, const synthio_midi_span_t *span) { self->track = m_realloc(self->track, (self->total_spans + 1) * sizeof(synthio_midi_span_t)); - self->track[self->total_spans++] = span; + self->track[self->total_spans++] = *span; +} + +STATIC int find_channel_with_note(const synthio_midi_span_t *span, uint8_t note) { + for (int i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { + if (span->note[i] == note) { + return i; + } + } + return -1; +} + +STATIC void change_span_note(synthio_miditrack_obj_t *self, uint8_t old_note, uint8_t new_note, uint16_t *dur) { + synthio_midi_span_t span = self->track[self->total_spans - 1]; + int channel = find_channel_with_note(&span, old_note); + if (channel != -1) { + terminate_span(self, dur); + span.note[channel] = new_note; + add_span(self, &span); + } } void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate) { - synthio_midi_span_t initial = { 0, {SILENCE, SILENCE} }; + synthio_midi_span_t initial = { 0, {[0 ... (CIRCUITPY_SYNTHIO_MAX_CHANNELS - 1)] = SILENCE} }; self->sample_rate = sample_rate; self->track = m_malloc(sizeof(synthio_midi_span_t), false); self->next_span = 0; self->total_spans = 1; *self->track = initial; - uint16_t dur = 0, max_dur = 0; + uint16_t dur = 0; uint32_t pos = 0; while (pos < len) { uint8_t c; @@ -91,37 +105,19 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, raise_midi_stream_error(pos); } + // dur is carried over here so that if a note on/off message doesn't actually produce a change, the + // underlying "span" is extended. Otherwise, it is zeroed out in the call to `terminate_span`. dur += delta * sample_rate / tempo; switch (buffer[pos++] >> 4) { case 8: { // Note Off uint8_t note = parse_note(buffer, len, &pos); - - // Ignore if not a note which is playing - synthio_midi_span_t last_span = self->track[self->total_spans - 1]; - if (last_span.note[0] == note || last_span.note[1] == note) { - terminate_span(self, &dur, &max_dur); - if (last_span.note[0] == note) { - add_span(self, last_span.note[1], SILENCE); - } else { - add_span(self, last_span.note[0], SILENCE); - } - } + change_span_note(self, note, SILENCE, &dur); break; } case 9: { // Note On uint8_t note = parse_note(buffer, len, &pos); - - // Ignore if two notes are already playing - synthio_midi_span_t last_span = self->track[self->total_spans - 1]; - if (last_span.note[1] == SILENCE) { - terminate_span(self, &dur, &max_dur); - if (last_span.note[0] == SILENCE) { - add_span(self, note, SILENCE); - } else { - add_span(self, last_span.note[0], note); - } - } + change_span_note(self, SILENCE, note, &dur); break; } case 10: @@ -142,8 +138,12 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, raise_midi_stream_error(pos); } } - terminate_span(self, &dur, &max_dur); + terminate_span(self, &dur); + uint16_t max_dur = 0; + for (int i = 0; i < self->total_spans; i++) { + max_dur = MAX(self->track[i].dur, max_dur); + } self->buffer_length = max_dur * BYTES_PER_SAMPLE; self->buffer = m_malloc(self->buffer_length, false); } @@ -177,6 +177,16 @@ void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self, STATIC const uint16_t notes[] = {8372, 8870, 9397, 9956, 10548, 11175, 11840, 12544, 13290, 14080, 14917, 15804}; // 9th octave +static int count_active_channels(synthio_midi_span_t *span) { + int result = 0; + for (int i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { + if (span->note[i] != SILENCE) { + result += 1; + } + } + return result; +} + audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { @@ -187,19 +197,26 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t synthio_midi_span_t span = self->track[self->next_span++]; *buffer_length = span.dur * BYTES_PER_SAMPLE; - uint8_t octave1 = span.note[0] / 12; // 0..10 - uint8_t octave2 = span.note[1] / 12; // 0..10 - int32_t base_freq1 = notes[span.note[0] % 12]; - int32_t base_freq2 = notes[span.note[1] % 12]; - int32_t sample_rate = self->sample_rate; + memset(self->buffer, 0, *buffer_length); - for (uint16_t i = 0; i < span.dur; i++) { - int16_t semiperiod1 = span.note[0] == SILENCE ? 0 : - ((base_freq1 * i * 2) / sample_rate) >> (10 - octave1); - int16_t semiperiod2 = span.note[1] == SILENCE ? semiperiod1 : - ((base_freq2 * i * 2) / sample_rate) >> (10 - octave2); - self->buffer[i] = ((semiperiod1 % 2 + semiperiod2 % 2) - 1) * LOUDNESS; + int32_t sample_rate = self->sample_rate; + int active_channels = count_active_channels(&span); + if (active_channels) { + int16_t loudness = 0x3fff / (1 + active_channels); + for (int chan = 0; chan < CIRCUITPY_SYNTHIO_MAX_CHANNELS; chan++) { + uint8_t octave = span.note[chan] / 12; + uint16_t base_freq = notes[span.note[chan] % 12]; + if (span.note[chan] == SILENCE) { + continue; + } + for (uint16_t i = 0; i < span.dur; i++) { + int16_t semiperiod = + ((base_freq * i * 2) / sample_rate) >> (10 - octave); + self->buffer[i] += semiperiod % 2 ? loudness : -loudness; + } + } } + *buffer = (uint8_t *)self->buffer; return self->next_span >= self->total_spans ? diff --git a/shared-module/synthio/MidiTrack.h b/shared-module/synthio/MidiTrack.h index 0af174ebc1..39e61b046e 100644 --- a/shared-module/synthio/MidiTrack.h +++ b/shared-module/synthio/MidiTrack.h @@ -33,7 +33,7 @@ typedef struct { uint16_t dur; - uint8_t note[2]; + uint8_t note[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; } synthio_midi_span_t; typedef struct { From 7f73ff1b2d7a5fb8d8e9f4312c92c165d5e53384 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 31 Mar 2023 10:51:03 -0500 Subject: [PATCH 181/225] hold accumulator phase across span this fixes grunk in held notes --- shared-module/synthio/MidiTrack.c | 12 ++++++++---- shared-module/synthio/MidiTrack.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index da810b99f3..dd36e7c454 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -204,16 +204,20 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t if (active_channels) { int16_t loudness = 0x3fff / (1 + active_channels); for (int chan = 0; chan < CIRCUITPY_SYNTHIO_MAX_CHANNELS; chan++) { - uint8_t octave = span.note[chan] / 12; - uint16_t base_freq = notes[span.note[chan] % 12]; if (span.note[chan] == SILENCE) { + self->accum[chan] = 0; continue; } + uint8_t octave = span.note[chan] / 12; + uint16_t base_freq = notes[span.note[chan] % 12]; + uint32_t accum = self->accum[chan]; + uint32_t rate = base_freq * 2; for (uint16_t i = 0; i < span.dur; i++) { - int16_t semiperiod = - ((base_freq * i * 2) / sample_rate) >> (10 - octave); + accum += rate; + int16_t semiperiod = (accum / sample_rate) >> (10 - octave); self->buffer[i] += semiperiod % 2 ? loudness : -loudness; } + self->accum[chan] = accum; } } diff --git a/shared-module/synthio/MidiTrack.h b/shared-module/synthio/MidiTrack.h index 39e61b046e..083392e608 100644 --- a/shared-module/synthio/MidiTrack.h +++ b/shared-module/synthio/MidiTrack.h @@ -44,6 +44,7 @@ typedef struct { synthio_midi_span_t *track; uint16_t next_span; uint16_t total_spans; + uint32_t accum[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; } synthio_miditrack_obj_t; From db1e01c462876846ae52ae98ca4da17d0b7f3208 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 31 Mar 2023 16:41:05 -0500 Subject: [PATCH 182/225] Don't require huge buffers for long-held notes --- shared-module/synthio/MidiTrack.c | 29 +++++++++++++++++++---------- shared-module/synthio/MidiTrack.h | 3 ++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index dd36e7c454..c745479c4a 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -27,9 +27,10 @@ #include "py/runtime.h" #include "shared-bindings/synthio/MidiTrack.h" -#define BITS_PER_SAMPLE 16 +#define BITS_PER_SAMPLE (16) #define BYTES_PER_SAMPLE (BITS_PER_SAMPLE / 8) -#define SILENCE 0x80 +#define MAX_DUR (512) +#define SILENCE (0x80) STATIC NORETURN void raise_midi_stream_error(uint32_t pos) { mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), pos); @@ -77,6 +78,7 @@ STATIC void change_span_note(synthio_miditrack_obj_t *self, uint8_t old_note, ui terminate_span(self, dur); span.note[channel] = new_note; add_span(self, &span); + *dur = 0; } } @@ -144,7 +146,7 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, for (int i = 0; i < self->total_spans; i++) { max_dur = MAX(self->track[i].dur, max_dur); } - self->buffer_length = max_dur * BYTES_PER_SAMPLE; + self->buffer_length = MIN(MAX_DUR, max_dur) * BYTES_PER_SAMPLE; self->buffer = m_malloc(self->buffer_length, false); } @@ -171,6 +173,7 @@ uint8_t common_hal_synthio_miditrack_get_channel_count(synthio_miditrack_obj_t * void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self, bool single_channel_output, uint8_t channel) { + self->remaining_dur = 0; self->next_span = 0; } @@ -189,14 +192,20 @@ static int count_active_channels(synthio_midi_span_t *span) { audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { + synthio_midi_span_t span = self->track[self->next_span - !!self->remaining_dur]; - if (self->next_span >= self->total_spans) { - *buffer_length = 0; - return GET_BUFFER_DONE; + if (self->remaining_dur == 0) { + if (self->next_span >= self->total_spans) { + *buffer_length = 0; + return GET_BUFFER_DONE; + } + self->next_span++; + self->remaining_dur = span.dur; } - synthio_midi_span_t span = self->track[self->next_span++]; - *buffer_length = span.dur * BYTES_PER_SAMPLE; + uint16_t dur = MIN(MAX_DUR, self->remaining_dur); + self->remaining_dur -= dur; + *buffer_length = dur * BYTES_PER_SAMPLE; memset(self->buffer, 0, *buffer_length); int32_t sample_rate = self->sample_rate; @@ -212,7 +221,7 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t uint16_t base_freq = notes[span.note[chan] % 12]; uint32_t accum = self->accum[chan]; uint32_t rate = base_freq * 2; - for (uint16_t i = 0; i < span.dur; i++) { + for (uint16_t i = 0; i < dur; i++) { accum += rate; int16_t semiperiod = (accum / sample_rate) >> (10 - octave); self->buffer[i] += semiperiod % 2 ? loudness : -loudness; @@ -223,7 +232,7 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *buffer = (uint8_t *)self->buffer; - return self->next_span >= self->total_spans ? + return (self->remaining_dur == 0 && self->next_span >= self->total_spans) ? GET_BUFFER_DONE : GET_BUFFER_MORE_DATA; } diff --git a/shared-module/synthio/MidiTrack.h b/shared-module/synthio/MidiTrack.h index 083392e608..42ef9c93ae 100644 --- a/shared-module/synthio/MidiTrack.h +++ b/shared-module/synthio/MidiTrack.h @@ -41,10 +41,11 @@ typedef struct { uint32_t sample_rate; uint16_t *buffer; uint16_t buffer_length; - synthio_midi_span_t *track; + uint16_t remaining_dur; uint16_t next_span; uint16_t total_spans; uint32_t accum[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; + synthio_midi_span_t *track; } synthio_miditrack_obj_t; From 13e17e6dcd7a3c73e7dbff49ef0c32160f563a28 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 1 Apr 2023 10:19:44 -0500 Subject: [PATCH 183/225] Make synthio debuggable in unix coverage port --- .../unix/variants/coverage/mpconfigvariant.mk | 16 ++++++- py/circuitpy_mpconfig.mk | 5 ++ shared-bindings/audiocore/WaveFile.c | 1 + shared-bindings/audiocore/__init__.c | 48 ++++++++++++++++++- shared-bindings/audiomixer/Mixer.h | 1 - shared-bindings/synthio/__init__.c | 5 ++ shared-module/synthio/MidiTrack.c | 7 ++- 7 files changed, 76 insertions(+), 7 deletions(-) diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index 20320916bc..fca9a99518 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -30,15 +30,23 @@ SRC_BITMAP := \ displayio_min.c \ shared-bindings/aesio/aes.c \ shared-bindings/aesio/__init__.c \ + shared-bindings/audiocore/__init__.c \ + shared-bindings/audiocore/RawSample.c \ + shared-bindings/audiocore/WaveFile.c \ shared-bindings/bitmaptools/__init__.c \ shared-bindings/displayio/Bitmap.c \ shared-bindings/rainbowio/__init__.c \ shared-bindings/struct/__init__.c \ + shared-bindings/synthio/__init__.c \ + shared-bindings/synthio/MidiTrack.c \ shared-bindings/traceback/__init__.c \ shared-bindings/util.c \ shared-bindings/zlib/__init__.c \ shared-module/aesio/aes.c \ shared-module/aesio/__init__.c \ + shared-module/audiocore/__init__.c \ + shared-module/audiocore/RawSample.c \ + shared-module/audiocore/WaveFile.c \ shared-module/bitmaptools/__init__.c \ shared-module/displayio/area.c \ shared-module/displayio/Bitmap.c \ @@ -47,6 +55,8 @@ SRC_BITMAP := \ shared-module/os/getenv.c \ shared-module/rainbowio/__init__.c \ shared-module/struct/__init__.c \ + shared-module/synthio/__init__.c \ + shared-module/synthio/MidiTrack.c \ shared-module/traceback/__init__.c \ shared-module/zlib/__init__.c \ @@ -54,12 +64,16 @@ SRC_C += $(SRC_BITMAP) CFLAGS += \ -DCIRCUITPY_AESIO=1 \ + -DCIRCUITPY_AUDIOCORE=1 \ + -DCIRCUITPY_AUDIOCORE_DEBUG=1 \ -DCIRCUITPY_BITMAPTOOLS=1 \ -DCIRCUITPY_DISPLAYIO_UNIX=1 \ - -DCIRCUITPY_OS_GETENV=1 \ -DCIRCUITPY_GIFIO=1 \ + -DCIRCUITPY_OS_GETENV=1 \ -DCIRCUITPY_RAINBOWIO=1 \ -DCIRCUITPY_STRUCT=1 \ + -DCIRCUITPY_SYNTHIO=1 \ + -DCIRCUITPY_SYNTHIO_MAX_CHANNELS=14 \ -DCIRCUITPY_TRACEBACK=1 \ -DCIRCUITPY_ZLIB=1 diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 3e5acd908c..dcd870597e 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -107,6 +107,11 @@ CFLAGS += -DCIRCUITPY_AUDIOCORE=$(CIRCUITPY_AUDIOCORE) CIRCUITPY_AUDIOMIXER ?= $(CIRCUITPY_AUDIOIO) CFLAGS += -DCIRCUITPY_AUDIOMIXER=$(CIRCUITPY_AUDIOMIXER) +ifndef CIRCUITPY_AUDIOCORE_DEBUG +CIRCUITPY_AUDIOCORE_DEBUG ?= 0 +endif +CFLAGS += -DCIRCUITPY_AUDIOCORE_DEBUG=$(CIRCUITPY_AUDIOCORE_DEBUG) + ifndef CIRCUITPY_AUDIOMP3 ifeq ($(CIRCUITPY_FULL_BUILD),1) CIRCUITPY_AUDIOMP3 = $(CIRCUITPY_AUDIOCORE) diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 36204fa2b2..3a13db72a0 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -32,6 +32,7 @@ #include "shared-bindings/audiocore/WaveFile.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate/translate.h" +#include "extmod/vfs_posix.h" //| class WaveFile: //| """Load a wave file for audio playback diff --git a/shared-bindings/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c index 2e3b479cf6..6f32979099 100644 --- a/shared-bindings/audiocore/__init__.c +++ b/shared-bindings/audiocore/__init__.c @@ -29,7 +29,6 @@ #include "py/obj.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiocore/__init__.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/audiocore/WaveFile.h" @@ -37,10 +36,57 @@ //| """Support for audio samples""" +#if CIRCUITPY_AUDIOCORE_DEBUG +// (no docstrings so that the debug functions are not shown on docs.circuitpython.org) +STATIC mp_obj_t audiocore_get_buffer(mp_obj_t sample_in) { + uint8_t *buffer = NULL; + uint32_t buffer_length = 0; + audioio_get_buffer_result_t gbr = audiosample_get_buffer(sample_in, false, 0, &buffer, &buffer_length); + + mp_obj_t result[2] = {mp_obj_new_int_from_uint(gbr), mp_const_none}; + + if (gbr != GET_BUFFER_ERROR) { + // copies the data because the gc semantics of get_buffer are unclear + result[1] = mp_obj_new_bytes(buffer, buffer_length); + } + + return mp_obj_new_tuple(2, result); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiocore_get_buffer_obj, audiocore_get_buffer); + +STATIC mp_obj_t audiocore_get_structure(mp_obj_t sample_in) { + bool single_buffer, samples_signed; + uint32_t max_buffer_length; + uint8_t spacing; + + audiosample_get_buffer_structure(sample_in, false, &single_buffer, &samples_signed, &max_buffer_length, &spacing); + mp_obj_t result[4] = { + mp_obj_new_int_from_uint(single_buffer), + mp_obj_new_int_from_uint(samples_signed), + mp_obj_new_int_from_uint(max_buffer_length), + mp_obj_new_int_from_uint(spacing), + }; + return mp_obj_new_tuple(4, result); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiocore_get_structure_obj, audiocore_get_structure); + +STATIC mp_obj_t audiocore_reset_buffer(mp_obj_t sample_in) { + audiosample_reset_buffer(sample_in, false, 0); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiocore_reset_buffer_obj, audiocore_reset_buffer); + +#endif + STATIC const mp_rom_map_elem_t audiocore_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiocore) }, { MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) }, { MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) }, + #if CIRCUITPY_AUDIOCORE_DEBUG + { MP_ROM_QSTR(MP_QSTR_get_buffer), MP_ROM_PTR(&audiocore_get_buffer_obj) }, + { MP_ROM_QSTR(MP_QSTR_reset_buffer), MP_ROM_PTR(&audiocore_reset_buffer_obj) }, + { MP_ROM_QSTR(MP_QSTR_get_structure), MP_ROM_PTR(&audiocore_get_structure_obj) }, + #endif }; STATIC MP_DEFINE_CONST_DICT(audiocore_module_globals, audiocore_module_globals_table); diff --git a/shared-bindings/audiomixer/Mixer.h b/shared-bindings/audiomixer/Mixer.h index 88592a1cb3..fd1154cc43 100644 --- a/shared-bindings/audiomixer/Mixer.h +++ b/shared-bindings/audiomixer/Mixer.h @@ -27,7 +27,6 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H #define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H -#include "common-hal/microcontroller/Pin.h" #include "shared-module/audiomixer/Mixer.h" #include "shared-bindings/audiocore/RawSample.h" diff --git a/shared-bindings/synthio/__init__.c b/shared-bindings/synthio/__init__.c index 106a073535..29a0c4d293 100644 --- a/shared-bindings/synthio/__init__.c +++ b/shared-bindings/synthio/__init__.c @@ -30,6 +30,7 @@ #include "py/obj.h" #include "py/runtime.h" #include "extmod/vfs_fat.h" +#include "extmod/vfs_posix.h" #include "shared-bindings/synthio/__init__.h" #include "shared-bindings/synthio/MidiTrack.h" @@ -115,7 +116,11 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma common_hal_synthio_miditrack_construct(result, buffer, track_size, tempo, args[ARG_sample_rate].u_int); + #if MICROPY_MALLOC_USES_ALLOCATED_SIZE + m_free(buffer, track_size); + #else m_free(buffer); + #endif return MP_OBJ_FROM_PTR(result); } diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index c745479c4a..dbc2d4ced1 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -57,8 +57,7 @@ STATIC void terminate_span(synthio_miditrack_obj_t *self, uint16_t *dur) { } STATIC void add_span(synthio_miditrack_obj_t *self, const synthio_midi_span_t *span) { - self->track = m_realloc(self->track, - (self->total_spans + 1) * sizeof(synthio_midi_span_t)); + self->track = m_renew(synthio_midi_span_t, self->track, self->total_spans, self->total_spans + 1); self->track[self->total_spans++] = *span; } @@ -151,9 +150,9 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, } void common_hal_synthio_miditrack_deinit(synthio_miditrack_obj_t *self) { - m_free(self->buffer); + m_del(uint8_t, self->buffer, self->buffer_length); self->buffer = NULL; - m_free(self->track); + m_del(synthio_midi_span_t, self->track, self->total_spans + 1); self->track = NULL; } bool common_hal_synthio_miditrack_deinited(synthio_miditrack_obj_t *self) { From e9e4ce9546806de4e9f4b1dd6bf37d825391b673 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 1 Apr 2023 10:21:22 -0500 Subject: [PATCH 184/225] add waveform support in synthio a waveform object (array of 'h') can be passed in, replacing the standard square wave. This waveform must be a 'single cycle waveform' and some obvious things to pass in are sine, triangle or sawtooth waves, but you can construct whatever you like. --- locale/circuitpython.pot | 23 +++++++++------------- shared-bindings/synthio/MidiTrack.c | 30 +++++++++++++++++++++++++---- shared-bindings/synthio/MidiTrack.h | 2 +- shared-bindings/synthio/__init__.c | 20 +++++++++++++++++-- shared-bindings/synthio/__init__.h | 9 ++------- shared-module/synthio/MidiTrack.c | 21 ++++++++++++++++---- shared-module/synthio/MidiTrack.h | 4 +++- 7 files changed, 76 insertions(+), 33 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b5026f7829..f87fc02975 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -122,6 +122,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -192,6 +193,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" @@ -1217,6 +1222,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1224,6 +1230,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "" @@ -3827,11 +3834,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3856,14 +3859,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4276,10 +4275,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index b987337eaa..727b9ba335 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -32,13 +32,19 @@ #include "py/runtime.h" #include "shared-bindings/util.h" #include "shared-bindings/synthio/MidiTrack.h" +#include "shared-bindings/synthio/__init__.h" #include "supervisor/shared/translate/translate.h" //| class MidiTrack: -//| """Simple square-wave MIDI synth""" +//| """Simple MIDI synth""" //| //| def __init__( -//| self, buffer: ReadableBuffer, tempo: int, *, sample_rate: int = 11025 +//| self, +//| buffer: ReadableBuffer, +//| tempo: int, +//| *, +//| sample_rate: int = 11025, +//| waveform: ReadableBuffer = None //| ) -> None: //| """Create a MidiTrack from the given stream of MIDI events. Only "Note On" and "Note Off" events //| are supported; channel numbers and key velocities are ignored. Up to two notes may be on at the @@ -47,6 +53,7 @@ //| :param ~circuitpython_typing.ReadableBuffer buffer: Stream of MIDI events, as stored in a MIDI file track chunk //| :param int tempo: Tempo of the streamed events, in MIDI ticks per second //| :param int sample_rate: The desired playback sample rate; higher sample rate requires more memory +//| :param ReadableBuffer waveform: A single-cycle waveform. Default is a 50% duty cycle square wave. If specified, must be a ReadableBuffer of type 'h' (signed 16 bit) //| //| Simple melody:: //| @@ -65,11 +72,12 @@ //| print("stopped")""" //| ... STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_buffer, ARG_tempo, ARG_sample_rate }; + enum { ARG_buffer, ARG_tempo, ARG_sample_rate, ARG_waveform }; static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_tempo, MP_ARG_INT | MP_ARG_REQUIRED }, { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 11025} }, + { MP_QSTR_waveform, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -77,13 +85,27 @@ STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_a mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); + mp_buffer_info_t bufinfo_waveform = { + .buf = shared_bindings_synthio_square_wave, + .len = 4 + }; + + if (args[ARG_waveform].u_obj != mp_const_none) { + mp_get_buffer_raise(args[ARG_waveform].u_obj, &bufinfo_waveform, MP_BUFFER_READ); + if (bufinfo_waveform.typecode != 'h') { + mp_raise_ValueError_varg(translate("%q must be array of type 'h'"), MP_QSTR_waveform); + } + } + synthio_miditrack_obj_t *self = m_new_obj(synthio_miditrack_obj_t); self->base.type = &synthio_miditrack_type; common_hal_synthio_miditrack_construct(self, (uint8_t *)bufinfo.buf, bufinfo.len, args[ARG_tempo].u_int, - args[ARG_sample_rate].u_int); + args[ARG_sample_rate].u_int, + bufinfo_waveform.buf, + bufinfo_waveform.len / 2); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/synthio/MidiTrack.h b/shared-bindings/synthio/MidiTrack.h index d44d4c3bb7..90ddab8728 100644 --- a/shared-bindings/synthio/MidiTrack.h +++ b/shared-bindings/synthio/MidiTrack.h @@ -32,7 +32,7 @@ extern const mp_obj_type_t synthio_miditrack_type; void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, - const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate); + const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate, const int16_t *waveform, uint16_t waveform_len); void common_hal_synthio_miditrack_deinit(synthio_miditrack_obj_t *self); bool common_hal_synthio_miditrack_deinited(synthio_miditrack_obj_t *self); diff --git a/shared-bindings/synthio/__init__.c b/shared-bindings/synthio/__init__.c index 29a0c4d293..dc627adb36 100644 --- a/shared-bindings/synthio/__init__.c +++ b/shared-bindings/synthio/__init__.c @@ -35,6 +35,8 @@ #include "shared-bindings/synthio/__init__.h" #include "shared-bindings/synthio/MidiTrack.h" +int16_t shared_bindings_synthio_square_wave[] = {-32768, 32767}; + //| """Support for MIDI synthesis""" //| //| def from_file(file: typing.BinaryIO, *, sample_rate: int = 11025) -> MidiTrack: @@ -43,6 +45,7 @@ //| //| :param typing.BinaryIO file: Already opened MIDI file //| :param int sample_rate: The desired playback sample rate; higher sample rate requires more memory +//| :param ReadableBuffer waveform: A single-cycle waveform. Default is a 50% duty cycle square wave. If specified, must be a ReadableBuffer of type 'h' (signed 16 bit) //| //| //| Playing a MIDI file from flash:: @@ -63,10 +66,11 @@ //| ... //| STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_file, ARG_sample_rate }; + enum { ARG_file, ARG_sample_rate, ARG_waveform }; static const mp_arg_t allowed_args[] = { { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 11025} }, + { MP_QSTR_waveform, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.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); @@ -75,6 +79,18 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma } pyb_file_obj_t *file = MP_OBJ_TO_PTR(args[ARG_file].u_obj); + mp_buffer_info_t bufinfo_waveform = { + .buf = shared_bindings_synthio_square_wave, + .len = 4 + }; + + if (args[ARG_waveform].u_obj != mp_const_none) { + mp_get_buffer_raise(args[ARG_waveform].u_obj, &bufinfo_waveform, MP_BUFFER_READ); + if (bufinfo_waveform.typecode != 'h') { + mp_raise_ValueError_varg(translate("%q must be array of type 'h'"), MP_QSTR_waveform); + } + } + uint8_t chunk_header[14]; f_rewind(&file->fp); UINT bytes_read; @@ -114,7 +130,7 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma result->base.type = &synthio_miditrack_type; common_hal_synthio_miditrack_construct(result, buffer, track_size, - tempo, args[ARG_sample_rate].u_int); + tempo, args[ARG_sample_rate].u_int, bufinfo_waveform.buf, bufinfo_waveform.len / 2); #if MICROPY_MALLOC_USES_ALLOCATED_SIZE m_free(buffer, track_size); diff --git a/shared-bindings/synthio/__init__.h b/shared-bindings/synthio/__init__.h index 14af1a5805..3b7d47db28 100644 --- a/shared-bindings/synthio/__init__.h +++ b/shared-bindings/synthio/__init__.h @@ -24,11 +24,6 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO___INIT___H +#pragma once -#include "py/obj.h" - -// Nothing now. - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO___INIT___H +extern int16_t shared_bindings_synthio_square_wave[]; diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index dbc2d4ced1..f7c17427d1 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -32,6 +32,7 @@ #define MAX_DUR (512) #define SILENCE (0x80) + STATIC NORETURN void raise_midi_stream_error(uint32_t pos) { mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), pos); } @@ -82,7 +83,8 @@ STATIC void change_span_note(synthio_miditrack_obj_t *self, uint8_t old_note, ui } void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, - const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate) { + const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate, + const int16_t *waveform, uint16_t waveform_length) { synthio_midi_span_t initial = { 0, {[0 ... (CIRCUITPY_SYNTHIO_MAX_CHANNELS - 1)] = SILENCE} }; self->sample_rate = sample_rate; @@ -90,6 +92,11 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, self->next_span = 0; self->total_spans = 1; *self->track = initial; + self->waveform = waveform; + self->waveform_length = waveform_length; + (void)mp_arg_validate_length_min(waveform_length, 2, MP_QSTR_waveform); + mp_printf(&mp_plat_print, "note: waveform_length = %d\n", waveform_length); + mp_printf(&mp_plat_print, "waveform[0:2] = %d %d\n", waveform[0], waveform[1]); uint16_t dur = 0; uint32_t pos = 0; @@ -209,6 +216,9 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t int32_t sample_rate = self->sample_rate; int active_channels = count_active_channels(&span); + const int16_t *waveform = self->waveform; + int16_t waveform_length = self->waveform_length; + int16_t *out_buffer = self->buffer; if (active_channels) { int16_t loudness = 0x3fff / (1 + active_channels); for (int chan = 0; chan < CIRCUITPY_SYNTHIO_MAX_CHANNELS; chan++) { @@ -219,11 +229,14 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t uint8_t octave = span.note[chan] / 12; uint16_t base_freq = notes[span.note[chan] % 12]; uint32_t accum = self->accum[chan]; - uint32_t rate = base_freq * 2; + uint32_t rate = base_freq * waveform_length; for (uint16_t i = 0; i < dur; i++) { accum += rate; - int16_t semiperiod = (accum / sample_rate) >> (10 - octave); - self->buffer[i] += semiperiod % 2 ? loudness : -loudness; + int16_t idx = ((accum / sample_rate) >> (10 - octave)) % waveform_length; + if (chan == 0 && i < 10) { + mp_printf(&mp_plat_print, "%d %d %d\n", accum, idx, waveform[idx]); + } + out_buffer[i] += (waveform[idx] * loudness) / 65536; } self->accum[chan] = accum; } diff --git a/shared-module/synthio/MidiTrack.h b/shared-module/synthio/MidiTrack.h index 42ef9c93ae..c9206c69bb 100644 --- a/shared-module/synthio/MidiTrack.h +++ b/shared-module/synthio/MidiTrack.h @@ -39,11 +39,13 @@ typedef struct { typedef struct { mp_obj_base_t base; uint32_t sample_rate; - uint16_t *buffer; + int16_t *buffer; uint16_t buffer_length; uint16_t remaining_dur; uint16_t next_span; uint16_t total_spans; + uint16_t waveform_length; + const int16_t *waveform; uint32_t accum[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; synthio_midi_span_t *track; } synthio_miditrack_obj_t; From e728a0c1b9eccb75d1c5edb452e75abb2931d57b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 1 Apr 2023 11:42:51 -0500 Subject: [PATCH 185/225] switch to 16.16 fixed point for synthesis --- shared-module/synthio/MidiTrack.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index f7c17427d1..e2614bd0a3 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -94,9 +94,7 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, *self->track = initial; self->waveform = waveform; self->waveform_length = waveform_length; - (void)mp_arg_validate_length_min(waveform_length, 2, MP_QSTR_waveform); - mp_printf(&mp_plat_print, "note: waveform_length = %d\n", waveform_length); - mp_printf(&mp_plat_print, "waveform[0:2] = %d %d\n", waveform[0], waveform[1]); + mp_arg_validate_length_range(waveform_length, 2, 1024, MP_QSTR_waveform); uint16_t dur = 0; uint32_t pos = 0; @@ -217,7 +215,7 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t int32_t sample_rate = self->sample_rate; int active_channels = count_active_channels(&span); const int16_t *waveform = self->waveform; - int16_t waveform_length = self->waveform_length; + uint32_t waveform_length = self->waveform_length; int16_t *out_buffer = self->buffer; if (active_channels) { int16_t loudness = 0x3fff / (1 + active_channels); @@ -229,13 +227,20 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t uint8_t octave = span.note[chan] / 12; uint16_t base_freq = notes[span.note[chan] % 12]; uint32_t accum = self->accum[chan]; - uint32_t rate = base_freq * waveform_length; +#define SHIFT (16) + // rate = base_freq * waveform_length + // den = sample_rate * 2 ^ (10 - octave) + // den = sample_rate * 2 ^ 10 / 2^octave + // dds_rate = 2^SHIFT * rate / den + // dds_rate = 2^(SHIFT-10+octave) * base_freq * waveform_length / sample_rate + uint32_t dds_rate = (sample_rate / 2 + ((uint64_t)(base_freq * waveform_length) << (SHIFT - 10 + octave))) / sample_rate; + for (uint16_t i = 0; i < dur; i++) { - accum += rate; - int16_t idx = ((accum / sample_rate) >> (10 - octave)) % waveform_length; - if (chan == 0 && i < 10) { - mp_printf(&mp_plat_print, "%d %d %d\n", accum, idx, waveform[idx]); + accum += dds_rate; + if (accum > waveform_length << SHIFT) { + accum -= waveform_length << SHIFT; } + int16_t idx = accum >> SHIFT; out_buffer[i] += (waveform[idx] * loudness) / 65536; } self->accum[chan] = accum; From 736af5b0c80e1ce79935c72e3bdf545ff3a38cc8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 1 Apr 2023 13:12:00 -0500 Subject: [PATCH 186/225] update expected result --- tests/unix/extra_coverage.py.exp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 8014dd3010..0baf8e1f44 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -30,20 +30,21 @@ ame__ mport builtins micropython _asyncio _thread -_uasyncio aesio array binascii -bitmaptools btree cexample cmath -collections cppexample displayio errno -ffi framebuf gc hashlib -json math qrio rainbowio -re struct sys termios -traceback ubinascii uctypes uerrno -uheapq uio ujson ulab -ulab.numpy ulab.numpy.fft ulab.numpy.linalg -ulab.scipy ulab.scipy.linalg -ulab.scipy.optimize ulab.scipy.signal -ulab.scipy.special ulab.utils uos -urandom ure uselect utime -utimeq uzlib zlib +_uasyncio aesio array audiocore +binascii bitmaptools btree cexample +cmath collections cppexample displayio +errno ffi framebuf gc +hashlib json math qrio +rainbowio re struct synthio +sys termios traceback ubinascii +uctypes uerrno uheapq uio +ujson ulab ulab.numpy ulab.numpy.fft +ulab.numpy.linalg ulab.scipy +ulab.scipy.linalg ulab.scipy.optimize +ulab.scipy.signal ulab.scipy.special +ulab.utils uos urandom ure +uselect utime utimeq uzlib +zlib ime utime utimeq From a24b12ee1084c113f6c73260c29de86119ac25cb Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sat, 1 Apr 2023 21:01:31 +0200 Subject: [PATCH 187/225] 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 | 19 +++++-------------- locale/cs.po | 19 +++++-------------- locale/de_DE.po | 28 ++++++++++++++-------------- locale/el.po | 19 +++++-------------- locale/en_GB.po | 28 ++++++++++++++-------------- locale/es.po | 28 ++++++++++++++-------------- locale/fil.po | 19 +++++-------------- locale/fr.po | 28 ++++++++++++++-------------- locale/hi.po | 19 +++++-------------- locale/it_IT.po | 19 +++++-------------- locale/ja.po | 25 +++++++++++-------------- locale/ko.po | 19 +++++-------------- locale/nl.po | 28 ++++++++++++++-------------- locale/pl.po | 25 +++++++++++-------------- locale/pt_BR.po | 28 ++++++++++++++-------------- locale/ru.po | 19 +++++-------------- locale/sv.po | 28 ++++++++++++++-------------- locale/tr.po | 19 +++++-------------- locale/zh_Latn_pinyin.po | 28 ++++++++++++++-------------- 19 files changed, 179 insertions(+), 266 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 21d3e4a4c2..99ed347bf5 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -125,6 +125,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1229,6 +1230,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1236,6 +1238,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "%q pada tidak valid" @@ -3856,11 +3859,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3885,14 +3884,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "parameter harus menjadi register dalam urutan r0 sampai r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4305,10 +4300,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index a8d09ade34..9f2917d396 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -126,6 +126,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1229,6 +1230,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1236,6 +1238,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Neplatný pin %q" @@ -3842,11 +3845,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3871,14 +3870,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4291,10 +4286,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 3c0c0c8233..30b1c8a6c7 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -134,6 +134,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "%q in %q muss von Typ %q sein, nicht %q" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1253,6 +1254,7 @@ msgstr "Der Interne WatchDog Timer ist abgelaufen." msgid "Interrupt error." msgstr "Interrupt Fehler." +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1260,6 +1262,7 @@ msgid "Invalid %q" msgstr "Ungültiger %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Ungültiger %q Pin" @@ -3927,11 +3930,7 @@ msgstr "Ausgabe-Array ist zu klein" msgid "out must be a float dense array" msgstr "Ausgabe muss ein floatdichtes Array sein" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "Außerhalb des Bereichs der Quelle" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "Außerhalb des Bereichs des Ziels" @@ -3956,14 +3955,10 @@ msgstr "Die Parameter müssen Register der Reihenfolge a2 bis a5 sein" msgid "parameters must be registers in sequence r0 to r3" msgstr "Parameter müssen Register im Bereich von r0 bis r3 sein" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "Pixelkoordinaten außerhalb der Grenzen" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "Der Pixelwert erfordert zu viele Bits" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader muss displayio.Palette oder displayio.ColorConverter sein" @@ -4378,10 +4373,6 @@ msgstr "Wert muss in %d Byte(s) passen" msgid "value out of range of target" msgstr "Wert außerhalb des Zielbereiches" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "value_count muss größer als 0 sein" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog nicht initialisiert" @@ -4469,6 +4460,15 @@ msgstr "zi muss eine Gleitkommazahl sein" msgid "zi must be of shape (n_section, 2)" msgstr "zi muss die Form (n_section, 2) haben" +#~ msgid "out of range of source" +#~ msgstr "Außerhalb des Bereichs der Quelle" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "Der Pixelwert erfordert zu viele Bits" + +#~ msgid "value_count must be > 0" +#~ msgstr "value_count muss größer als 0 sein" + #~ msgid "64 bit types" #~ msgstr "64 bit-Typen" diff --git a/locale/el.po b/locale/el.po index 3336cbae67..69d62af435 100644 --- a/locale/el.po +++ b/locale/el.po @@ -130,6 +130,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1237,6 +1238,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1244,6 +1246,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "" @@ -3849,11 +3852,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3878,14 +3877,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4298,10 +4293,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index 9c26f47d45..0f6abecec5 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -129,6 +129,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1230,6 +1231,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1237,6 +1239,7 @@ msgid "Invalid %q" msgstr "Invalid %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Invalid %q pin" @@ -3853,11 +3856,7 @@ msgstr "out array is too small" msgid "out must be a float dense array" msgstr "out must be a float dense array" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "out of range of source" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "out of range of target" @@ -3882,14 +3881,10 @@ msgstr "parameters must be registers in sequence a2 to a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "parameters must be registers in sequence r0 to r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "pixel coordinates out of bounds" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "pixel value requires too many bits" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader must be displayio.Palette or displayio.ColorConverter" @@ -4302,10 +4297,6 @@ msgstr "value must fit in %d byte(s)" msgid "value out of range of target" msgstr "value out of range of target" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "value_count must be > 0" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "WatchDog not initialised" @@ -4393,6 +4384,15 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "out of range of source" +#~ msgstr "out of range of source" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "pixel value requires too many bits" + +#~ msgid "value_count must be > 0" +#~ msgstr "value_count must be > 0" + #~ msgid "64 bit types" #~ msgstr "64 bit types" diff --git a/locale/es.po b/locale/es.po index 266ac9edea..3dd68ca430 100644 --- a/locale/es.po +++ b/locale/es.po @@ -137,6 +137,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "%q en %q debe ser del tipo %q, no %q" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1263,6 +1264,7 @@ msgstr "El temporizador interno watchdog terminó." msgid "Interrupt error." msgstr "Error de interrupción." +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1270,6 +1272,7 @@ msgid "Invalid %q" msgstr "%q inválido" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Pin %q inválido" @@ -3925,11 +3928,7 @@ msgstr "La matriz de salida es demasiado pequeña" msgid "out must be a float dense array" msgstr "la matriz de salida debe ser densa de números float" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "fuera de rango de fuente" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "fuera de rango del objetivo" @@ -3954,14 +3953,10 @@ msgstr "los parámetros deben ser registros en secuencia de a2 a a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "los parametros deben ser registros en secuencia del r0 al r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "coordenadas del pixel fuera de límites" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "valor del pixel require demasiado bits" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader debe ser displayio.Palette o displayio.ColorConverter" @@ -4375,10 +4370,6 @@ msgstr "el valor debe caber en %d byte(s)" msgid "value out of range of target" msgstr "valor fuera de alcance al blanco" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "value_count debe ser > 0" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog no inicializado" @@ -4466,6 +4457,15 @@ 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 "out of range of source" +#~ msgstr "fuera de rango de fuente" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "valor del pixel require demasiado bits" + +#~ msgid "value_count must be > 0" +#~ msgstr "value_count debe ser > 0" + #~ msgid "64 bit types" #~ msgstr "tipos de 64 bit" diff --git a/locale/fil.po b/locale/fil.po index f83cfb1173..7540377953 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -123,6 +123,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1229,6 +1230,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1236,6 +1238,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Mali ang %q pin" @@ -3862,11 +3865,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3891,15 +3890,11 @@ msgstr "ang mga parameter ay dapat na nagrerehistro sa sequence a2 hanggang a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "ang mga parameter ay dapat na nagrerehistro sa sequence r0 hanggang r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c #, fuzzy msgid "pixel coordinates out of bounds" msgstr "wala sa sakop ang address" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader ay dapat displayio.Palette o displayio.ColorConverter" @@ -4312,10 +4307,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index e536cbd346..3076df8d16 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -134,6 +134,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "%q dans %q doit être de type %q, pas %q" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1269,6 +1270,7 @@ msgstr "Le minuteur du watchdog interne a expiré." msgid "Interrupt error." msgstr "Erreur d'interruption." +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1276,6 +1278,7 @@ msgid "Invalid %q" msgstr "%q invalide" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Broche invalide pour '%q'" @@ -3943,11 +3946,7 @@ msgstr "matrice de sortie est trop petite" msgid "out must be a float dense array" msgstr "la matrice sortante doit être de type float" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "dépassement des bornes de source" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "dépassement des bornes de target" @@ -3972,14 +3971,10 @@ msgstr "les paramètres doivent être des registres dans la séquence a2 à a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "les paramètres doivent être des registres dans la séquence r0 à r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "coordonnées de pixel hors limites" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "la valeur du pixel requiet trop de bits" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4394,10 +4389,6 @@ msgstr "la valeur doit tenir dans %d octet(s)" msgid "value out of range of target" msgstr "valeur hors de porté de la cible" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "'value_count' doit être > 0" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "chien de garde (watchdog) non initialisé" @@ -4485,6 +4476,15 @@ 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 "out of range of source" +#~ msgstr "dépassement des bornes de source" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "la valeur du pixel requiet trop de bits" + +#~ msgid "value_count must be > 0" +#~ msgstr "'value_count' doit être > 0" + #~ msgid "64 bit types" #~ msgstr "types à 64 bit" diff --git a/locale/hi.po b/locale/hi.po index 977cd4986a..b0ede40028 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -122,6 +122,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1217,6 +1218,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1224,6 +1226,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "" @@ -3827,11 +3830,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3856,14 +3855,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4276,10 +4271,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index b4e998f698..f8037c8954 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -126,6 +126,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1231,6 +1232,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1238,6 +1240,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Pin %q non valido" @@ -3871,11 +3874,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3901,15 +3900,11 @@ msgstr "parametri devono essere i registri in sequenza da a2 a a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "parametri devono essere i registri in sequenza da a2 a a5" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c #, fuzzy msgid "pixel coordinates out of bounds" msgstr "indirizzo fuori limite" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader deve essere displayio.Palette o displayio.ColorConverter" @@ -4322,10 +4317,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index ab8ca26d28..8931beb108 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -129,6 +129,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1230,6 +1231,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1237,6 +1239,7 @@ msgid "Invalid %q" msgstr "不正な %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "不正な%qピン" @@ -3849,11 +3852,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "ソースが範囲外" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3878,14 +3877,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4300,10 +4295,6 @@ msgstr "値は%dバイトに収まらなければなりません" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "value_countは0より大きくなければなりません" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" @@ -4391,6 +4382,12 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "out of range of source" +#~ msgstr "ソースが範囲外" + +#~ msgid "value_count must be > 0" +#~ msgstr "value_countは0より大きくなければなりません" + #~ msgid "No key was specified" #~ msgstr "キーが指定されていません" diff --git a/locale/ko.po b/locale/ko.po index 21b5cdecd6..34d4ffcb5d 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -123,6 +123,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1220,6 +1221,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1227,6 +1229,7 @@ msgid "Invalid %q" msgstr "" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "" @@ -3831,11 +3834,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3860,14 +3859,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4280,10 +4275,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 50a0ab6d99..3232cc6f14 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -122,6 +122,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1225,6 +1226,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1232,6 +1234,7 @@ msgid "Invalid %q" msgstr "Ongeldige %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Ongeldige %q pin" @@ -3861,11 +3864,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "buiten bereik van bron" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "buiten bereik van doel" @@ -3890,14 +3889,10 @@ msgstr "parameters moeten registers zijn in de volgorde a2 tot a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "parameters moeten registers zijn in de volgorde r0 tot r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "pixel coördinaten buiten bereik" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "pixel waarde vereist te veel bits" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader moet displayio.Palette of displayio.ColorConverter zijn" @@ -4310,10 +4305,6 @@ msgstr "waarde moet in %d byte(s) passen" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "value_count moet groter dan 0 zijn" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog niet geïnitialiseerd" @@ -4401,6 +4392,15 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "out of range of source" +#~ msgstr "buiten bereik van bron" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "pixel waarde vereist te veel bits" + +#~ msgid "value_count must be > 0" +#~ msgstr "value_count moet groter dan 0 zijn" + #~ msgid "No key was specified" #~ msgstr "Een sleutel was niet gespecificeerd" diff --git a/locale/pl.po b/locale/pl.po index e873e45a51..e1bed87c6c 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -124,6 +124,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1225,6 +1226,7 @@ msgstr "" msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1232,6 +1234,7 @@ msgid "Invalid %q" msgstr "Nieprawidłowe %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Zła nóżka %q" @@ -3836,11 +3839,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3865,14 +3864,10 @@ msgstr "parametry muszą być rejestrami w kolejności a2 do a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "parametry muszą być rejestrami w kolejności r0 do r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "współrzędne piksela poza zakresem" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "wartość piksela wymaga zbyt wielu bitów" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4286,10 +4281,6 @@ msgstr "wartość musi mieścić się w %d bajtach" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "value_count musi być > 0" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" @@ -4377,6 +4368,12 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "pixel value requires too many bits" +#~ msgstr "wartość piksela wymaga zbyt wielu bitów" + +#~ msgid "value_count must be > 0" +#~ msgstr "value_count musi być > 0" + #~ msgid "No key was specified" #~ msgstr "Nie określono klucza" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 802966354a..85ca810b98 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -135,6 +135,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "%q em %q deve ser do tipo %q e não %q" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1259,6 +1260,7 @@ msgstr "O temporizador do watchdog interno expirou." msgid "Interrupt error." msgstr "Erro de interrupção." +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1266,6 +1268,7 @@ msgid "Invalid %q" msgstr "%q Inválido" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Pino do %q inválido" @@ -3924,11 +3927,7 @@ msgstr "a matriz externa é muito pequena" msgid "out must be a float dense array" msgstr "deve ser uma matriz densa flutuante" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "fora do alcance da fonte" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "fora do alcance do alvo" @@ -3955,14 +3954,10 @@ msgstr "os parâmetros devem ser registradores na sequência a2 até a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "os parâmetros devem ser registradores na sequência r0 até r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "as coordenadas do pixel estão fora dos limites" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "o valor do pixel requer bits demais" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "o pixel_shader deve ser displayio.Palette ou displayio.ColorConverter" @@ -4375,10 +4370,6 @@ msgstr "o valor deve caber em %d byte(s)" msgid "value out of range of target" msgstr "valor fora do alcance do alvo" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "o value_count deve ser > 0" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "o watchdog não foi inicializado" @@ -4466,6 +4457,15 @@ 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 "out of range of source" +#~ msgstr "fora do alcance da fonte" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "o valor do pixel requer bits demais" + +#~ msgid "value_count must be > 0" +#~ msgstr "o value_count deve ser > 0" + #~ msgid "64 bit types" #~ msgstr "Tipos 64 bit" diff --git a/locale/ru.po b/locale/ru.po index e2c1eae4f1..4d40fe946e 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -129,6 +129,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1262,6 +1263,7 @@ msgstr "Внутренний сторожевой таймер истек." msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1269,6 +1271,7 @@ msgid "Invalid %q" msgstr "Недопустимый %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Недопустимый пин %q" @@ -3890,11 +3893,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3919,14 +3918,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4339,10 +4334,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/sv.po b/locale/sv.po index a7dee9421d..8d3bed02f4 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -134,6 +134,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "%q i %q måste vara av typen %q, inte %q" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1244,6 +1245,7 @@ msgstr "Intern watchdog-timer har löpt ut." msgid "Interrupt error." msgstr "Interrupt-fel." +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1251,6 +1253,7 @@ msgid "Invalid %q" msgstr "Ogiltig %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Ogiltig %q-pinne" @@ -3887,11 +3890,7 @@ msgstr "matrisen för out är för liten" msgid "out must be a float dense array" msgstr "out måste vara en float dense array" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "utanför räckvidd för source" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "utanför räckvidd för target" @@ -3916,14 +3915,10 @@ msgstr "parametrarna måste registreras i följd a2-a5" msgid "parameters must be registers in sequence r0 to r3" msgstr "parametrarna måste registreras i följd r0-r3" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "pixelkoordinater utanför gränserna" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "pixelvärdet kräver för många bitar" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4337,10 +4332,6 @@ msgstr "värdet måste passa i %d byte(s)" msgid "value out of range of target" msgstr "värde utanför målintervall" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "value_count måste vara > 0" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog är inte initierad" @@ -4428,6 +4419,15 @@ 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 "out of range of source" +#~ msgstr "utanför räckvidd för source" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "pixelvärdet kräver för många bitar" + +#~ msgid "value_count must be > 0" +#~ msgstr "value_count måste vara > 0" + #~ msgid "64 bit types" #~ msgstr "64-bitars typer" diff --git a/locale/tr.po b/locale/tr.po index f785cff4fc..5f3882ca9e 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -130,6 +130,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1235,6 +1236,7 @@ msgstr "Dahili bekçi zamanlayıcısının süresi doldu." msgid "Interrupt error." msgstr "" +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1242,6 +1244,7 @@ msgid "Invalid %q" msgstr "Geçersiz %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Geersi %q pin" @@ -3849,11 +3852,7 @@ msgstr "" msgid "out must be a float dense array" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "" @@ -3878,14 +3877,10 @@ msgstr "" msgid "parameters must be registers in sequence r0 to r3" msgstr "" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" @@ -4298,10 +4293,6 @@ msgstr "" msgid "value out of range of target" msgstr "" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 2246687ef3..d149942d6a 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -137,6 +137,7 @@ msgid "%q in %q must be of type %q, not %q" msgstr "%q zhōng de %q bì xū shì %q lèi xíng, ér bù shì %q" #: ports/espressif/common-hal/espulp/ULP.c +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c @@ -1251,6 +1252,7 @@ msgstr "Nèibù kān mén gǒu dìngshí qì chāoshí." msgid "Interrupt error." msgstr "zhōng duàn cuò wù." +#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/displayio/EPaperDisplay.c @@ -1258,6 +1260,7 @@ msgid "Invalid %q" msgstr "wú xiào %q" #: ports/atmel-samd/common-hal/microcontroller/Pin.c +#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c msgid "Invalid %q pin" msgstr "Wúxiào de %q yǐn jiǎo" @@ -3891,11 +3894,7 @@ msgstr "chū zhèn liè tài xiǎo" msgid "out must be a float dense array" msgstr "chū bì xū shì yí gè fú dòng mì jí zhèn liè" -#: shared-bindings/displayio/Bitmap.c -msgid "out of range of source" -msgstr "yuán fàn wéi wài" - -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "out of range of target" msgstr "mù biāo fàn wéi wài" @@ -3920,14 +3919,10 @@ msgstr "cānshù bìxū shì xùliè a2 zhì a5 de dēngjì shù" msgid "parameters must be registers in sequence r0 to r3" msgstr "cānshù bìxū shì xùliè r0 zhì r3 de dēngjì qì" -#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +#: shared-bindings/bitmaptools/__init__.c msgid "pixel coordinates out of bounds" msgstr "xiàngsù zuòbiāo chāochū biānjiè" -#: shared-bindings/displayio/Bitmap.c -msgid "pixel value requires too many bits" -msgstr "xiàngsù zhí xūyào tài duō wèi" - #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader bìxū shì displayio.Palette huò displayio.ColorConverter" @@ -4343,10 +4338,6 @@ msgstr "Zhí bìxū fúhé %d zì jié" msgid "value out of range of target" msgstr "zhí fàn wéi wài de mù biāo" -#: shared-bindings/displayio/Bitmap.c -msgid "value_count must be > 0" -msgstr "zhí jìshù bìxū wèi > 0" - #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "wèi chū shǐ huà jiān shì qì" @@ -4434,6 +4425,15 @@ 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 "out of range of source" +#~ msgstr "yuán fàn wéi wài" + +#~ msgid "pixel value requires too many bits" +#~ msgstr "xiàngsù zhí xūyào tài duō wèi" + +#~ msgid "value_count must be > 0" +#~ msgstr "zhí jìshù bìxū wèi > 0" + #~ msgid "64 bit types" #~ msgstr "64 wèi lèixíng" From 05cf5213e20568f269f4fab678b307b06bf97fe3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 1 Apr 2023 19:22:52 -0500 Subject: [PATCH 188/225] Allow disabling each class in keypad .. for boards like pewpewm4 which need a specific kind. And need some space. --- ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk | 2 ++ py/circuitpy_mpconfig.mk | 9 +++++++++ shared-bindings/keypad/KeyMatrix.c | 10 ++++++++++ shared-bindings/keypad/Keys.c | 9 +++++++++ shared-bindings/keypad/ShiftRegisterKeys.c | 8 ++++++++ 5 files changed, 38 insertions(+) diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index f7e7be88d5..49be084ddf 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -44,6 +44,8 @@ CIRCUITPY_AUDIOIO = 1 CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_DISPLAYIO = 1 CIRCUITPY_KEYPAD = 1 +CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS = 0 +CIRCUITPY_KEYPAD_KEYMATRIX = 0 CIRCUITPY_MATH = 1 CIRCUITPY_STAGE = 1 CIRCUITPY_SYNTHIO = 1 diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index dcd870597e..0aec2ebe74 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -291,6 +291,15 @@ CFLAGS += -DCIRCUITPY_JSON=$(CIRCUITPY_JSON) CIRCUITPY_KEYPAD ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_KEYPAD=$(CIRCUITPY_KEYPAD) +CIRCUITPY_KEYPAD_KEYS ?= $(CIRCUITPY_KEYPAD) +CFLAGS += -DCIRCUITPY_KEYPAD_KEYS=$(CIRCUITPY_KEYPAD_KEYS) + +CIRCUITPY_KEYPAD_KEYMATRIX ?= $(CIRCUITPY_KEYPAD) +CFLAGS += -DCIRCUITPY_KEYPAD_KEYMATRIX=$(CIRCUITPY_KEYPAD_KEYMATRIX) + +CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS ?= $(CIRCUITPY_KEYPAD) +CFLAGS += -DCIRCUITPY_KEYPAD_SHIFTREGISTERKEYS=$(CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS) + CIRCUITPY_MATH ?= 1 CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) diff --git a/shared-bindings/keypad/KeyMatrix.c b/shared-bindings/keypad/KeyMatrix.c index 1c623f4bed..2209f3f68f 100644 --- a/shared-bindings/keypad/KeyMatrix.c +++ b/shared-bindings/keypad/KeyMatrix.c @@ -71,6 +71,7 @@ //| ... STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + #if CIRCUITPY_KEYPAD_KEYMATRIX keypad_keymatrix_obj_t *self = m_new_obj(keypad_keymatrix_obj_t); self->base.type = &keypad_keymatrix_type; enum { ARG_row_pins, ARG_column_pins, ARG_columns_to_anodes, ARG_interval, ARG_max_events }; @@ -114,8 +115,13 @@ STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_ar common_hal_keypad_keymatrix_construct(self, num_row_pins, row_pins_array, num_column_pins, column_pins_array, args[ARG_columns_to_anodes].u_bool, interval, max_events); return MP_OBJ_FROM_PTR(self); + #else + mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_KeyMatrix); + + #endif } +#if CIRCUITPY_KEYPAD_KEYMATRIX //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... @@ -228,9 +234,13 @@ STATIC const mp_rom_map_elem_t keypad_keymatrix_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(keypad_keymatrix_locals_dict, keypad_keymatrix_locals_dict_table); +#endif + const mp_obj_type_t keypad_keymatrix_type = { { &mp_type_type }, .name = MP_QSTR_KeyMatrix, .make_new = keypad_keymatrix_make_new, + #if CIRCUITPY_KEYPAD_KEYMATRIX .locals_dict = (mp_obj_t)&keypad_keymatrix_locals_dict, + #endif }; diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index 10519958c7..2481fedc6b 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -73,6 +73,7 @@ //| ... STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + #if CIRCUITPY_KEYPAD_KEYS keypad_keys_obj_t *self = m_new_obj(keypad_keys_obj_t); self->base.type = &keypad_keys_type; enum { ARG_pins, ARG_value_when_pressed, ARG_pull, ARG_interval, ARG_max_events }; @@ -106,8 +107,13 @@ STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, s common_hal_keypad_keys_construct(self, num_pins, pins_array, value_when_pressed, args[ARG_pull].u_bool, interval, max_events); return MP_OBJ_FROM_PTR(self); + #else + mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_Keys); + + #endif } +#if CIRCUITPY_KEYPAD_KEYS //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... @@ -162,10 +168,13 @@ STATIC const mp_rom_map_elem_t keypad_keys_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(keypad_keys_locals_dict, keypad_keys_locals_dict_table); +#endif const mp_obj_type_t keypad_keys_type = { { &mp_type_type }, .name = MP_QSTR_Keys, .make_new = keypad_keys_make_new, + #if CIRCUITPY_KEYPAD_KEYS .locals_dict = (mp_obj_t)&keypad_keys_locals_dict, + #endif }; diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index 9113be33d2..9c44717a41 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -82,6 +82,7 @@ //| ... STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + #if CIRCUITPY_KEYPAD_KEYMATRIX keypad_shiftregisterkeys_obj_t *self = m_new_obj(keypad_shiftregisterkeys_obj_t); self->base.type = &keypad_shiftregisterkeys_type; enum { ARG_clock, ARG_data, ARG_latch, ARG_value_to_latch, ARG_key_count, ARG_value_when_pressed, ARG_interval, ARG_max_events }; @@ -113,8 +114,12 @@ STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, siz self, clock, data, latch, value_to_latch, key_count, value_when_pressed, interval, max_events); return MP_OBJ_FROM_PTR(self); + #else + mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_ShiftRegisterKeys); + #endif } +#if CIRCUITPY_KEYPAD_KEYMATRIX //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... @@ -169,10 +174,13 @@ STATIC const mp_rom_map_elem_t keypad_shiftregisterkeys_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(keypad_shiftregisterkeys_locals_dict, keypad_shiftregisterkeys_locals_dict_table); +#endif const mp_obj_type_t keypad_shiftregisterkeys_type = { { &mp_type_type }, .name = MP_QSTR_ShiftRegisterKeys, .make_new = keypad_shiftregisterkeys_make_new, + #if CIRCUITPY_KEYPAD_KEYMATRIX .locals_dict = (mp_obj_t)&keypad_shiftregisterkeys_locals_dict, + #endif }; From 62636cf722bd7c775f217e6f80b10cc5eb35673a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 1 Apr 2023 19:24:06 -0500 Subject: [PATCH 189/225] Make a message more terse This matches a bunch of other NotImplementedErrors --- shared-bindings/audiobusio/I2SOut.c | 2 +- shared-bindings/audiobusio/PDMIn.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 3713caeb7b..e0d46de8e1 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -97,7 +97,7 @@ //| ... STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_I2SOUT - mp_raise_NotImplementedError(translate("I2SOut not available")); + mp_raise_NotImplementedError(translate("%q"), MP_QSTR_I2SOut); return NULL; // Not reachable. #else enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified }; diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index b6a316fadb..f26a5f4cc2 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -94,7 +94,7 @@ //| ... STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_PDMIN - mp_raise_NotImplementedError(translate("PDMIn not available")); + mp_raise_NotImplementedError(translate("%q"), MP_QSTR_PDMIn); #else enum { ARG_clock_pin, ARG_data_pin, ARG_sample_rate, ARG_bit_depth, ARG_mono, ARG_oversample, ARG_startup_delay }; static const mp_arg_t allowed_args[] = { From 8b05d11538cb45f8734274fedecc6a4bc4e98c4a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 1 Apr 2023 19:25:30 -0500 Subject: [PATCH 190/225] save 4 bytes memory since qstr constants are smol --- shared-bindings/keypad/Event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index 8264ebe612..52c574e692 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -167,9 +167,9 @@ STATIC mp_obj_t keypad_event_unary_op(mp_unary_op_t op, mp_obj_t self_in) { STATIC void keypad_event_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { keypad_event_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "", + mp_printf(print, "", common_hal_keypad_event_get_key_number(self), - common_hal_keypad_event_get_pressed(self) ? "pressed" : "released"); + common_hal_keypad_event_get_pressed(self) ? MP_QSTR_pressed : MP_QSTR_released); } STATIC const mp_rom_map_elem_t keypad_event_locals_dict_table[] = { From 975c981e4f32638051832973ba1f1c8a33cf021a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 2 Apr 2023 11:55:14 -0500 Subject: [PATCH 191/225] fix some calls that needed to be _varg --- shared-bindings/audiobusio/I2SOut.c | 2 +- shared-bindings/audiobusio/PDMIn.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index e0d46de8e1..8c6f1a3a7a 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -97,7 +97,7 @@ //| ... STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_I2SOUT - mp_raise_NotImplementedError(translate("%q"), MP_QSTR_I2SOut); + mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_I2SOut); return NULL; // Not reachable. #else enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified }; diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index f26a5f4cc2..1f0e500292 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -94,7 +94,7 @@ //| ... STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_PDMIN - mp_raise_NotImplementedError(translate("%q"), MP_QSTR_PDMIn); + mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_PDMIn); #else enum { ARG_clock_pin, ARG_data_pin, ARG_sample_rate, ARG_bit_depth, ARG_mono, ARG_oversample, ARG_startup_delay }; static const mp_arg_t allowed_args[] = { From 7bbb2ed898695a054cb1175e1743fbe33a9a73f3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 2 Apr 2023 13:48:23 -0500 Subject: [PATCH 192/225] add a basic acceptance test of MidiTrack --- tests/circuitpython/miditrack.py | 20 ++++++++++++++++++++ tests/circuitpython/miditrack.py.exp | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 tests/circuitpython/miditrack.py create mode 100644 tests/circuitpython/miditrack.py.exp diff --git a/tests/circuitpython/miditrack.py b/tests/circuitpython/miditrack.py new file mode 100644 index 0000000000..53a8ca631d --- /dev/null +++ b/tests/circuitpython/miditrack.py @@ -0,0 +1,20 @@ +import array + +try: + from synthio import MidiTrack + from audiocore import get_buffer, get_structure +except ImportError: + print("SKIP") + raise SystemExit + +SCORE = b"\0\x90@\0\x20\x90b\0\x20\x80@\0\0\x80\b\0" + +with MidiTrack(SCORE, sample_rate=8000, tempo=640) as m: + print(get_structure(m)) + print(get_buffer(m)) + +with MidiTrack( + SCORE, sample_rate=8000, tempo=640, waveform=array.array("h", [0, 32767, 0, -32768]) +) as m: + print(get_structure(m)) + print(get_buffer(m)) diff --git a/tests/circuitpython/miditrack.py.exp b/tests/circuitpython/miditrack.py.exp new file mode 100644 index 0000000000..c5dc447e74 --- /dev/null +++ b/tests/circuitpython/miditrack.py.exp @@ -0,0 +1,4 @@ +(1, 1, 800, 1) +(1, b'\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0') +(1, 1, 800, 1) +(1, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f') From e0984fa195c1a45de9e7774d4948467c397d1692 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 2 Apr 2023 18:54:07 -0500 Subject: [PATCH 193/225] Factor out the synthesizer from midi track --- shared-module/synthio/MidiTrack.c | 101 +++++------------------------- shared-module/synthio/MidiTrack.h | 13 +--- shared-module/synthio/__init__.c | 81 ++++++++++++++++++++++++ shared-module/synthio/__init__.h | 30 ++++++++- 4 files changed, 126 insertions(+), 99 deletions(-) diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index e2614bd0a3..9cc224d96b 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -27,11 +27,6 @@ #include "py/runtime.h" #include "shared-bindings/synthio/MidiTrack.h" -#define BITS_PER_SAMPLE (16) -#define BYTES_PER_SAMPLE (BITS_PER_SAMPLE / 8) -#define MAX_DUR (512) -#define SILENCE (0x80) - STATIC NORETURN void raise_midi_stream_error(uint32_t pos) { mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), pos); @@ -86,14 +81,13 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate, const int16_t *waveform, uint16_t waveform_length) { - synthio_midi_span_t initial = { 0, {[0 ... (CIRCUITPY_SYNTHIO_MAX_CHANNELS - 1)] = SILENCE} }; - self->sample_rate = sample_rate; + self->synth.sample_rate = sample_rate; self->track = m_malloc(sizeof(synthio_midi_span_t), false); + *self->track = ((synthio_midi_span_t) { 0, {[0 ... (CIRCUITPY_SYNTHIO_MAX_CHANNELS - 1)] = SYNTHIO_SILENCE} }); self->next_span = 0; self->total_spans = 1; - *self->track = initial; - self->waveform = waveform; - self->waveform_length = waveform_length; + self->synth.waveform = waveform; + self->synth.waveform_length = waveform_length; mp_arg_validate_length_range(waveform_length, 2, 1024, MP_QSTR_waveform); uint16_t dur = 0; @@ -118,12 +112,12 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, switch (buffer[pos++] >> 4) { case 8: { // Note Off uint8_t note = parse_note(buffer, len, &pos); - change_span_note(self, note, SILENCE, &dur); + change_span_note(self, note, SYNTHIO_SILENCE, &dur); break; } case 9: { // Note On uint8_t note = parse_note(buffer, len, &pos); - change_span_note(self, SILENCE, note, &dur); + change_span_note(self, SYNTHIO_SILENCE, note, &dur); break; } case 10: @@ -150,25 +144,23 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, for (int i = 0; i < self->total_spans; i++) { max_dur = MAX(self->track[i].dur, max_dur); } - self->buffer_length = MIN(MAX_DUR, max_dur) * BYTES_PER_SAMPLE; - self->buffer = m_malloc(self->buffer_length, false); + synthio_synth_init(&self->synth, max_dur); } void common_hal_synthio_miditrack_deinit(synthio_miditrack_obj_t *self) { - m_del(uint8_t, self->buffer, self->buffer_length); - self->buffer = NULL; + synthio_synth_deinit(&self->synth); m_del(synthio_midi_span_t, self->track, self->total_spans + 1); self->track = NULL; } bool common_hal_synthio_miditrack_deinited(synthio_miditrack_obj_t *self) { - return self->buffer == NULL; + return synthio_synth_deinited(&self->synth); } uint32_t common_hal_synthio_miditrack_get_sample_rate(synthio_miditrack_obj_t *self) { - return self->sample_rate; + return self->synth.sample_rate; } uint8_t common_hal_synthio_miditrack_get_bits_per_sample(synthio_miditrack_obj_t *self) { - return BITS_PER_SAMPLE; + return SYNTHIO_BITS_PER_SAMPLE; } uint8_t common_hal_synthio_miditrack_get_channel_count(synthio_miditrack_obj_t *self) { return 1; @@ -177,87 +169,28 @@ uint8_t common_hal_synthio_miditrack_get_channel_count(synthio_miditrack_obj_t * void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self, bool single_channel_output, uint8_t channel) { - self->remaining_dur = 0; + self->synth.span.dur = 0; self->next_span = 0; } -STATIC const uint16_t notes[] = {8372, 8870, 9397, 9956, 10548, 11175, 11840, - 12544, 13290, 14080, 14917, 15804}; // 9th octave - -static int count_active_channels(synthio_midi_span_t *span) { - int result = 0; - for (int i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { - if (span->note[i] != SILENCE) { - result += 1; - } - } - return result; -} - audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { - synthio_midi_span_t span = self->track[self->next_span - !!self->remaining_dur]; - if (self->remaining_dur == 0) { + if (self->synth.span.dur == 0) { if (self->next_span >= self->total_spans) { *buffer_length = 0; return GET_BUFFER_DONE; } - self->next_span++; - self->remaining_dur = span.dur; + self->synth.span = self->track[self->next_span++]; } - uint16_t dur = MIN(MAX_DUR, self->remaining_dur); - self->remaining_dur -= dur; - *buffer_length = dur * BYTES_PER_SAMPLE; - memset(self->buffer, 0, *buffer_length); + synthio_synth_synthesize(&self->synth, buffer, buffer_length); - int32_t sample_rate = self->sample_rate; - int active_channels = count_active_channels(&span); - const int16_t *waveform = self->waveform; - uint32_t waveform_length = self->waveform_length; - int16_t *out_buffer = self->buffer; - if (active_channels) { - int16_t loudness = 0x3fff / (1 + active_channels); - for (int chan = 0; chan < CIRCUITPY_SYNTHIO_MAX_CHANNELS; chan++) { - if (span.note[chan] == SILENCE) { - self->accum[chan] = 0; - continue; - } - uint8_t octave = span.note[chan] / 12; - uint16_t base_freq = notes[span.note[chan] % 12]; - uint32_t accum = self->accum[chan]; -#define SHIFT (16) - // rate = base_freq * waveform_length - // den = sample_rate * 2 ^ (10 - octave) - // den = sample_rate * 2 ^ 10 / 2^octave - // dds_rate = 2^SHIFT * rate / den - // dds_rate = 2^(SHIFT-10+octave) * base_freq * waveform_length / sample_rate - uint32_t dds_rate = (sample_rate / 2 + ((uint64_t)(base_freq * waveform_length) << (SHIFT - 10 + octave))) / sample_rate; - - for (uint16_t i = 0; i < dur; i++) { - accum += dds_rate; - if (accum > waveform_length << SHIFT) { - accum -= waveform_length << SHIFT; - } - int16_t idx = accum >> SHIFT; - out_buffer[i] += (waveform[idx] * loudness) / 65536; - } - self->accum[chan] = accum; - } - } - - *buffer = (uint8_t *)self->buffer; - - return (self->remaining_dur == 0 && self->next_span >= self->total_spans) ? + return (self->synth.span.dur == 0 && self->next_span >= self->total_spans) ? GET_BUFFER_DONE : GET_BUFFER_MORE_DATA; } void synthio_miditrack_get_buffer_structure(synthio_miditrack_obj_t *self, bool single_channel_output, bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing) { - - *single_buffer = true; - *samples_signed = true; - *max_buffer_length = self->buffer_length; - *spacing = 1; + return synthio_synth_get_buffer_structure(&self->synth, single_channel_output, single_buffer, samples_signed, max_buffer_length, spacing); } diff --git a/shared-module/synthio/MidiTrack.h b/shared-module/synthio/MidiTrack.h index c9206c69bb..e301ef355f 100644 --- a/shared-module/synthio/MidiTrack.h +++ b/shared-module/synthio/MidiTrack.h @@ -31,22 +31,11 @@ #include "shared-module/synthio/__init__.h" -typedef struct { - uint16_t dur; - uint8_t note[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; -} synthio_midi_span_t; - typedef struct { mp_obj_base_t base; - uint32_t sample_rate; - int16_t *buffer; - uint16_t buffer_length; - uint16_t remaining_dur; + synthio_synth_t synth; uint16_t next_span; uint16_t total_spans; - uint16_t waveform_length; - const int16_t *waveform; - uint32_t accum[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; synthio_midi_span_t *track; } synthio_miditrack_obj_t; diff --git a/shared-module/synthio/__init__.c b/shared-module/synthio/__init__.c index e69de29bb2..8c58d5b2da 100644 --- a/shared-module/synthio/__init__.c +++ b/shared-module/synthio/__init__.c @@ -0,0 +1,81 @@ +#include "shared-module/synthio/__init__.h" + +STATIC const uint16_t notes[] = {8372, 8870, 9397, 9956, 10548, 11175, 11840, + 12544, 13290, 14080, 14917, 15804}; // 9th octave + +STATIC int count_active_channels(synthio_midi_span_t *span) { + int result = 0; + for (int i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { + if (span->note[i] != SYNTHIO_SILENCE) { + result += 1; + } + } + return result; +} + + +void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t *buffer_length) { + uint16_t dur = MIN(SYNTHIO_MAX_DUR, synth->span.dur); + synth->span.dur -= dur; + memset(synth->buffer, 0, synth->buffer_length); + + int32_t sample_rate = synth->sample_rate; + int active_channels = count_active_channels(&synth->span); + const int16_t *waveform = synth->waveform; + uint32_t waveform_length = synth->waveform_length; + int16_t *out_buffer = synth->buffer; + if (active_channels) { + int16_t loudness = 0x3fff / (1 + active_channels); + for (int chan = 0; chan < CIRCUITPY_SYNTHIO_MAX_CHANNELS; chan++) { + if (synth->span.note[chan] == SYNTHIO_SILENCE) { + synth->accum[chan] = 0; + continue; + } + uint8_t octave = synth->span.note[chan] / 12; + uint16_t base_freq = notes[synth->span.note[chan] % 12]; + uint32_t accum = synth->accum[chan]; +#define SHIFT (16) + // rate = base_freq * waveform_length + // den = sample_rate * 2 ^ (10 - octave) + // den = sample_rate * 2 ^ 10 / 2^octave + // dds_rate = 2^SHIFT * rate / den + // dds_rate = 2^(SHIFT-10+octave) * base_freq * waveform_length / sample_rate + uint32_t dds_rate = (sample_rate / 2 + ((uint64_t)(base_freq * waveform_length) << (SHIFT - 10 + octave))) / sample_rate; + + for (uint16_t i = 0; i < dur; i++) { + accum += dds_rate; + if (accum > waveform_length << SHIFT) { + accum -= waveform_length << SHIFT; + } + int16_t idx = accum >> SHIFT; + out_buffer[i] += (waveform[idx] * loudness) / 65536; + } + synth->accum[chan] = accum; + } + } + + *buffer_length = dur * SYNTHIO_BYTES_PER_SAMPLE; + *buffer = (uint8_t *)synth->buffer; +} + +bool synthio_synth_deinited(synthio_synth_t *synth) { + return synth->buffer == NULL; +} + +void synthio_synth_deinit(synthio_synth_t *synth) { + m_del(uint8_t, synth->buffer, synth->buffer_length); + synth->buffer = NULL; +} + +void synthio_synth_init(synthio_synth_t *synth, uint16_t max_dur) { + synth->buffer_length = MIN(SYNTHIO_MAX_DUR, max_dur) * SYNTHIO_BYTES_PER_SAMPLE; + synth->buffer = m_malloc(synth->buffer_length, false); +} + +void synthio_synth_get_buffer_structure(synthio_synth_t *synth, bool single_channel_output, + bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing) { + *single_buffer = true; + *samples_signed = true; + *max_buffer_length = synth->buffer_length; + *spacing = 1; +} diff --git a/shared-module/synthio/__init__.h b/shared-module/synthio/__init__.h index d9d98a5341..88be7e689e 100644 --- a/shared-module/synthio/__init__.h +++ b/shared-module/synthio/__init__.h @@ -24,9 +24,33 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO__INIT__H -#define MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO__INIT__H +#pragma once + +#define SYNTHIO_BITS_PER_SAMPLE (16) +#define SYNTHIO_BYTES_PER_SAMPLE (SYNTHIO_BITS_PER_SAMPLE / 8) +#define SYNTHIO_MAX_DUR (512) +#define SYNTHIO_SILENCE (0x80) #include "shared-module/audiocore/__init__.h" -#endif // MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO__INIT__H +typedef struct { + uint16_t dur; + uint8_t note[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; +} synthio_midi_span_t; + +typedef struct { + uint32_t sample_rate; + int16_t *buffer; + const int16_t *waveform; + uint16_t buffer_length; + uint16_t waveform_length; + synthio_midi_span_t span; + uint32_t accum[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; +} synthio_synth_t; + +void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t *buffer_length); +void synthio_synth_deinit(synthio_synth_t *synth); +bool synthio_synth_deinited(synthio_synth_t *synth); +void synthio_synth_init(synthio_synth_t *synth, uint16_t max_dur); +void synthio_synth_get_buffer_structure(synthio_synth_t *synth, bool single_channel_output, + bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing); From b01146825175c5738de17fb8387124150eaba768 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 2 Apr 2023 20:37:23 -0500 Subject: [PATCH 194/225] Add synthio.Synthesizer In contrast to MidiTrack, this can be controlled from Python code, turning notes on/off as desired. Not tested on real HW yet, just the acceptance test based on checking which notes it thinks are held internally. --- .../unix/variants/coverage/mpconfigvariant.mk | 2 + py/circuitpy_defns.mk | 1 + shared-bindings/synthio/MidiTrack.c | 13 +- shared-bindings/synthio/Synthesizer.c | 211 ++++++++++++++++++ shared-bindings/synthio/Synthesizer.h | 45 ++++ shared-bindings/synthio/__init__.c | 16 +- shared-module/synthio/MidiTrack.c | 16 +- shared-module/synthio/Synthesizer.c | 104 +++++++++ shared-module/synthio/Synthesizer.h | 53 +++++ shared-module/synthio/__init__.c | 70 +++++- shared-module/synthio/__init__.h | 4 + tests/circuitpython/synthesizer.py | 24 ++ tests/circuitpython/synthesizer.py.exp | 8 + 13 files changed, 528 insertions(+), 39 deletions(-) create mode 100644 shared-bindings/synthio/Synthesizer.c create mode 100644 shared-bindings/synthio/Synthesizer.h create mode 100644 shared-module/synthio/Synthesizer.c create mode 100644 shared-module/synthio/Synthesizer.h create mode 100644 tests/circuitpython/synthesizer.py create mode 100644 tests/circuitpython/synthesizer.py.exp diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index fca9a99518..8b25ddb705 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -39,6 +39,7 @@ SRC_BITMAP := \ shared-bindings/struct/__init__.c \ shared-bindings/synthio/__init__.c \ shared-bindings/synthio/MidiTrack.c \ + shared-bindings/synthio/Synthesizer.c \ shared-bindings/traceback/__init__.c \ shared-bindings/util.c \ shared-bindings/zlib/__init__.c \ @@ -57,6 +58,7 @@ SRC_BITMAP := \ shared-module/struct/__init__.c \ shared-module/synthio/__init__.c \ shared-module/synthio/MidiTrack.c \ + shared-module/synthio/Synthesizer.c \ shared-module/traceback/__init__.c \ shared-module/zlib/__init__.c \ diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 94377238a0..fb5d745ebb 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -648,6 +648,7 @@ SRC_SHARED_MODULE_ALL = \ supervisor/__init__.c \ supervisor/StatusBar.c \ synthio/MidiTrack.c \ + synthio/Synthesizer.c \ synthio/__init__.c \ terminalio/Terminal.c \ terminalio/__init__.c \ diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index 727b9ba335..20a203ce9c 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -85,17 +85,8 @@ STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_a mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); - mp_buffer_info_t bufinfo_waveform = { - .buf = shared_bindings_synthio_square_wave, - .len = 4 - }; - - if (args[ARG_waveform].u_obj != mp_const_none) { - mp_get_buffer_raise(args[ARG_waveform].u_obj, &bufinfo_waveform, MP_BUFFER_READ); - if (bufinfo_waveform.typecode != 'h') { - mp_raise_ValueError_varg(translate("%q must be array of type 'h'"), MP_QSTR_waveform); - } - } + mp_buffer_info_t bufinfo_waveform; + synthio_synth_parse_waveform(&bufinfo_waveform, args[ARG_waveform].u_obj); synthio_miditrack_obj_t *self = m_new_obj(synthio_miditrack_obj_t); self->base.type = &synthio_miditrack_type; diff --git a/shared-bindings/synthio/Synthesizer.c b/shared-bindings/synthio/Synthesizer.c new file mode 100644 index 0000000000..2ad5cbcd42 --- /dev/null +++ b/shared-bindings/synthio/Synthesizer.c @@ -0,0 +1,211 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * Copyright (c) 2023 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 "shared/runtime/context_manager_helpers.h" +#include "py/binary.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/util.h" +#include "shared-bindings/synthio/Synthesizer.h" +#include "shared-bindings/synthio/__init__.h" +#include "supervisor/shared/translate/translate.h" + +//| class Synth: +//| def __init__(self, *, sample_rate: int = 11025, waveform: ReadableBuffer = None) -> None: +//| """Create a synthesizer object.""" +STATIC mp_obj_t synthio_synthesizer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_sample_rate, ARG_waveform }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 11025} }, + { MP_QSTR_waveform, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none } }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo_waveform; + synthio_synth_parse_waveform(&bufinfo_waveform, args[ARG_waveform].u_obj); + + synthio_synthesizer_obj_t *self = m_new_obj(synthio_synthesizer_obj_t); + self->base.type = &synthio_synthesizer_type; + + common_hal_synthio_synthesizer_construct(self, + args[ARG_sample_rate].u_int, + bufinfo_waveform.buf, + bufinfo_waveform.len / 2); + + return MP_OBJ_FROM_PTR(self); +} + +STATIC void check_for_deinit(synthio_synthesizer_obj_t *self) { + if (common_hal_synthio_synthesizer_deinited(self)) { + raise_deinited_error(); + } +} + +//| def press(self, /, press: Sequence[int] = ()) -> None: +//| """Turn some notes on. Notes use MIDI numbering, with 60 being middle C.""" +STATIC mp_obj_t synthio_synthesizer_press(mp_obj_t self_in, mp_obj_t press) { + synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + common_hal_synthio_synthesizer_press(self, press); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(synthio_synthesizer_press_obj, synthio_synthesizer_press); +// +//| def release_then_press( +//| self, release: Sequence[int] = (), press: Sequence[int] = () +//| ) -> None: +//| """Turn some notes on and/or off. Notes use MIDI numbering, with 60 being middle C.""" +STATIC mp_obj_t synthio_synthesizer_release_then_press(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_release, ARG_press }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_release, MP_ARG_OBJ, {.u_obj = mp_const_empty_tuple } }, + { MP_QSTR_press, MP_ARG_OBJ, {.u_obj = mp_const_empty_tuple } }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + check_for_deinit(self); + common_hal_synthio_synthesizer_release(self, args[ARG_release].u_obj); + common_hal_synthio_synthesizer_press(self, args[ARG_press].u_obj); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(synthio_synthesizer_release_then_press_obj, 1, synthio_synthesizer_release_then_press); + +// +//| def release_all_then_press(self, /, press: Sequence[int]) -> None: +//| """Turn any currently-playing notes off, then turn on the given notes""" +STATIC mp_obj_t synthio_synthesizer_release_all_then_press(mp_obj_t self_in, mp_obj_t press) { + synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + common_hal_synthio_synthesizer_release_all(self); + common_hal_synthio_synthesizer_press(self, press); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(synthio_synthesizer_release_all_then_press_obj, synthio_synthesizer_release_all_then_press); + +// +//| def release_all(self) -> None: +//| """Turn any currently-playing notes off""" +STATIC mp_obj_t synthio_synthesizer_release_all(mp_obj_t self_in) { + synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + common_hal_synthio_synthesizer_release_all(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(synthio_synthesizer_release_all_obj, synthio_synthesizer_release_all); + +//| def deinit(self) -> None: +//| """Deinitialises the object and releases any memory resources for reuse.""" +//| ... +STATIC mp_obj_t synthio_synthesizer_deinit(mp_obj_t self_in) { + synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_synthio_synthesizer_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(synthio_synthesizer_deinit_obj, synthio_synthesizer_deinit); + +//| def __enter__(self) -> MidiTrack: +//| """No-op used by Context Managers.""" +//| ... +// Provided by context manager helper. +//| +//| def __exit__(self) -> None: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +STATIC mp_obj_t synthio_synthesizer_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_synthio_synthesizer_deinit(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(synthio_synthesizer___exit___obj, 4, 4, synthio_synthesizer_obj___exit__); +//| sample_rate: int +//| """32 bit value that tells how quickly samples are played in Hertz (cycles per second).""" +STATIC mp_obj_t synthio_synthesizer_obj_get_sample_rate(mp_obj_t self_in) { + synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_synthio_synthesizer_get_sample_rate(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(synthio_synthesizer_get_sample_rate_obj, synthio_synthesizer_obj_get_sample_rate); + +MP_PROPERTY_GETTER(synthio_synthesizer_sample_rate_obj, + (mp_obj_t)&synthio_synthesizer_get_sample_rate_obj); + +//| pressed: Tuple[int] +//| """A sequence of the currently pressed notes (read-only property)""" +//| +STATIC mp_obj_t synthio_synthesizer_obj_get_pressed(mp_obj_t self_in) { + synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return common_hal_synthio_synthesizer_get_pressed_notes(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(synthio_synthesizer_get_pressed_obj, synthio_synthesizer_obj_get_pressed); + +MP_PROPERTY_GETTER(synthio_synthesizer_pressed_obj, + (mp_obj_t)&synthio_synthesizer_get_pressed_obj); + +STATIC const mp_rom_map_elem_t synthio_synthesizer_locals_dict_table[] = { + // Methods + { MP_ROM_QSTR(MP_QSTR_press), MP_ROM_PTR(&synthio_synthesizer_press_obj) }, + { MP_ROM_QSTR(MP_QSTR_release_all), MP_ROM_PTR(&synthio_synthesizer_release_all_obj) }, + { MP_ROM_QSTR(MP_QSTR_release_then_press), MP_ROM_PTR(&synthio_synthesizer_release_then_press_obj) }, + { MP_ROM_QSTR(MP_QSTR_release_all_then_press), MP_ROM_PTR(&synthio_synthesizer_release_all_then_press_obj) }, + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&synthio_synthesizer_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&synthio_synthesizer___exit___obj) }, + + // Properties + { MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&synthio_synthesizer_sample_rate_obj) }, + { MP_ROM_QSTR(MP_QSTR_pressed), MP_ROM_PTR(&synthio_synthesizer_pressed_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(synthio_synthesizer_locals_dict, synthio_synthesizer_locals_dict_table); + +STATIC const audiosample_p_t synthio_synthesizer_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) + .sample_rate = (audiosample_sample_rate_fun)common_hal_synthio_synthesizer_get_sample_rate, + .bits_per_sample = (audiosample_bits_per_sample_fun)common_hal_synthio_synthesizer_get_bits_per_sample, + .channel_count = (audiosample_channel_count_fun)common_hal_synthio_synthesizer_get_channel_count, + .reset_buffer = (audiosample_reset_buffer_fun)synthio_synthesizer_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)synthio_synthesizer_get_buffer, + .get_buffer_structure = (audiosample_get_buffer_structure_fun)synthio_synthesizer_get_buffer_structure, +}; + +const mp_obj_type_t synthio_synthesizer_type = { + { &mp_type_type }, + .name = MP_QSTR_Synthesizer, + .flags = MP_TYPE_FLAG_EXTENDED, + .make_new = synthio_synthesizer_make_new, + .locals_dict = (mp_obj_dict_t *)&synthio_synthesizer_locals_dict, + MP_TYPE_EXTENDED_FIELDS( + .protocol = &synthio_synthesizer_proto, + ), +}; diff --git a/shared-bindings/synthio/Synthesizer.h b/shared-bindings/synthio/Synthesizer.h new file mode 100644 index 0000000000..92e75a1c23 --- /dev/null +++ b/shared-bindings/synthio/Synthesizer.h @@ -0,0 +1,45 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * Copyright (c) 2023 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "shared-module/synthio/Synthesizer.h" + +extern const mp_obj_type_t synthio_synthesizer_type; + +void common_hal_synthio_synthesizer_construct(synthio_synthesizer_obj_t *self, + uint32_t sample_rate, const int16_t *waveform, uint16_t waveform_len); + +void common_hal_synthio_synthesizer_deinit(synthio_synthesizer_obj_t *self); +bool common_hal_synthio_synthesizer_deinited(synthio_synthesizer_obj_t *self); +uint32_t common_hal_synthio_synthesizer_get_sample_rate(synthio_synthesizer_obj_t *self); +uint8_t common_hal_synthio_synthesizer_get_bits_per_sample(synthio_synthesizer_obj_t *self); +uint8_t common_hal_synthio_synthesizer_get_channel_count(synthio_synthesizer_obj_t *self); +void common_hal_synthio_synthesizer_release(synthio_synthesizer_obj_t *self, mp_obj_t to_release); +void common_hal_synthio_synthesizer_press(synthio_synthesizer_obj_t *self, mp_obj_t to_press); +void common_hal_synthio_synthesizer_release_all(synthio_synthesizer_obj_t *self); +mp_obj_t common_hal_synthio_synthesizer_get_pressed_notes(synthio_synthesizer_obj_t *self); diff --git a/shared-bindings/synthio/__init__.c b/shared-bindings/synthio/__init__.c index dc627adb36..3c50377ff8 100644 --- a/shared-bindings/synthio/__init__.c +++ b/shared-bindings/synthio/__init__.c @@ -34,8 +34,7 @@ #include "shared-bindings/synthio/__init__.h" #include "shared-bindings/synthio/MidiTrack.h" - -int16_t shared_bindings_synthio_square_wave[] = {-32768, 32767}; +#include "shared-bindings/synthio/Synthesizer.h" //| """Support for MIDI synthesis""" //| @@ -79,17 +78,9 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma } pyb_file_obj_t *file = MP_OBJ_TO_PTR(args[ARG_file].u_obj); - mp_buffer_info_t bufinfo_waveform = { - .buf = shared_bindings_synthio_square_wave, - .len = 4 - }; - if (args[ARG_waveform].u_obj != mp_const_none) { - mp_get_buffer_raise(args[ARG_waveform].u_obj, &bufinfo_waveform, MP_BUFFER_READ); - if (bufinfo_waveform.typecode != 'h') { - mp_raise_ValueError_varg(translate("%q must be array of type 'h'"), MP_QSTR_waveform); - } - } + mp_buffer_info_t bufinfo_waveform; + synthio_synth_parse_waveform(&bufinfo_waveform, args[ARG_waveform].u_obj); uint8_t chunk_header[14]; f_rewind(&file->fp); @@ -146,6 +137,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(synthio_from_file_obj, 1, synthio_from_file); STATIC const mp_rom_map_elem_t synthio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_synthio) }, { MP_ROM_QSTR(MP_QSTR_MidiTrack), MP_ROM_PTR(&synthio_miditrack_type) }, + { MP_ROM_QSTR(MP_QSTR_Synthesizer), MP_ROM_PTR(&synthio_synthesizer_type) }, { MP_ROM_QSTR(MP_QSTR_from_file), MP_ROM_PTR(&synthio_from_file_obj) }, }; diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index 9cc224d96b..0d91ee6982 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -57,21 +57,10 @@ STATIC void add_span(synthio_miditrack_obj_t *self, const synthio_midi_span_t *s self->track[self->total_spans++] = *span; } -STATIC int find_channel_with_note(const synthio_midi_span_t *span, uint8_t note) { - for (int i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { - if (span->note[i] == note) { - return i; - } - } - return -1; -} - STATIC void change_span_note(synthio_miditrack_obj_t *self, uint8_t old_note, uint8_t new_note, uint16_t *dur) { synthio_midi_span_t span = self->track[self->total_spans - 1]; - int channel = find_channel_with_note(&span, old_note); - if (channel != -1) { + if (synthio_span_change_note(&span, old_note, new_note)) { terminate_span(self, dur); - span.note[channel] = new_note; add_span(self, &span); *dur = 0; } @@ -83,12 +72,11 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, self->synth.sample_rate = sample_rate; self->track = m_malloc(sizeof(synthio_midi_span_t), false); - *self->track = ((synthio_midi_span_t) { 0, {[0 ... (CIRCUITPY_SYNTHIO_MAX_CHANNELS - 1)] = SYNTHIO_SILENCE} }); + synthio_span_init(self->track); self->next_span = 0; self->total_spans = 1; self->synth.waveform = waveform; self->synth.waveform_length = waveform_length; - mp_arg_validate_length_range(waveform_length, 2, 1024, MP_QSTR_waveform); uint16_t dur = 0; uint32_t pos = 0; diff --git a/shared-module/synthio/Synthesizer.c b/shared-module/synthio/Synthesizer.c new file mode 100644 index 0000000000..8cfc73a980 --- /dev/null +++ b/shared-module/synthio/Synthesizer.c @@ -0,0 +1,104 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * 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 "py/runtime.h" +#include "shared-bindings/synthio/Synthesizer.h" + + + +void common_hal_synthio_synthesizer_construct(synthio_synthesizer_obj_t *self, + uint32_t sample_rate, const int16_t *waveform, uint16_t waveform_length) { + + self->synth.sample_rate = sample_rate; + self->synth.waveform = waveform; + self->synth.waveform_length = waveform_length; + synthio_synth_init(&self->synth, SYNTHIO_MAX_DUR); + common_hal_synthio_synthesizer_release_all(self); +} + +void common_hal_synthio_synthesizer_deinit(synthio_synthesizer_obj_t *self) { + synthio_synth_deinit(&self->synth); +} +bool common_hal_synthio_synthesizer_deinited(synthio_synthesizer_obj_t *self) { + return synthio_synth_deinited(&self->synth); +} + +uint32_t common_hal_synthio_synthesizer_get_sample_rate(synthio_synthesizer_obj_t *self) { + return self->synth.sample_rate; +} +uint8_t common_hal_synthio_synthesizer_get_bits_per_sample(synthio_synthesizer_obj_t *self) { + return SYNTHIO_BITS_PER_SAMPLE; +} +uint8_t common_hal_synthio_synthesizer_get_channel_count(synthio_synthesizer_obj_t *self) { + return 1; +} + +void synthio_synthesizer_reset_buffer(synthio_synthesizer_obj_t *self, + bool single_channel_output, uint8_t channel) { +} + +audioio_get_buffer_result_t synthio_synthesizer_get_buffer(synthio_synthesizer_obj_t *self, + bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { + self->synth.span.dur = SYNTHIO_MAX_DUR; + synthio_synth_synthesize(&self->synth, buffer, buffer_length); + return GET_BUFFER_MORE_DATA; +} + +void synthio_synthesizer_get_buffer_structure(synthio_synthesizer_obj_t *self, bool single_channel_output, + bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing) { + return synthio_synth_get_buffer_structure(&self->synth, single_channel_output, single_buffer, samples_signed, max_buffer_length, spacing); +} + +void common_hal_synthio_synthesizer_release_all(synthio_synthesizer_obj_t *self) { + synthio_span_init(&self->synth.span); +} +void common_hal_synthio_synthesizer_release(synthio_synthesizer_obj_t *self, mp_obj_t to_release) { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(to_release, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + synthio_span_change_note(&self->synth.span, mp_arg_validate_int_range(mp_obj_get_int(item), 0, 127, MP_QSTR_note), SYNTHIO_SILENCE); + } +} + +void common_hal_synthio_synthesizer_press(synthio_synthesizer_obj_t *self, mp_obj_t to_press) { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(to_press, &iter_buf); + mp_obj_t item; + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + synthio_span_change_note(&self->synth.span, SYNTHIO_SILENCE, mp_arg_validate_int_range(mp_obj_get_int(item), 0, 127, MP_QSTR_note)); + } +} + +mp_obj_t common_hal_synthio_synthesizer_get_pressed_notes(synthio_synthesizer_obj_t *self) { + mp_obj_tuple_t *result = MP_OBJ_TO_PTR(mp_obj_new_tuple(synthio_span_count_active_channels(&self->synth.span), NULL)); + for (size_t i = 0, j = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { + if (self->synth.span.note[i] != SYNTHIO_SILENCE) { + result->items[j++] = MP_OBJ_NEW_SMALL_INT(self->synth.span.note[i]); + } + } + return MP_OBJ_FROM_PTR(result); +} diff --git a/shared-module/synthio/Synthesizer.h b/shared-module/synthio/Synthesizer.h new file mode 100644 index 0000000000..256b6137f2 --- /dev/null +++ b/shared-module/synthio/Synthesizer.h @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * Copyright (c) 2023 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "py/obj.h" + +#include "shared-module/synthio/__init__.h" + +typedef struct { + mp_obj_base_t base; + synthio_synth_t synth; +} synthio_synthesizer_obj_t; + + +// These are not available from Python because it may be called in an interrupt. +void synthio_synthesizer_reset_buffer(synthio_synthesizer_obj_t *self, + bool single_channel_output, + uint8_t channel); + +audioio_get_buffer_result_t synthio_synthesizer_get_buffer(synthio_synthesizer_obj_t *self, + bool single_channel_output, + uint8_t channel, + uint8_t **buffer, + uint32_t *buffer_length); // length in bytes + +void synthio_synthesizer_get_buffer_structure(synthio_synthesizer_obj_t *self, bool single_channel_output, + bool *single_buffer, bool *samples_signed, + uint32_t *max_buffer_length, uint8_t *spacing); diff --git a/shared-module/synthio/__init__.c b/shared-module/synthio/__init__.c index 8c58d5b2da..0dee75deb7 100644 --- a/shared-module/synthio/__init__.c +++ b/shared-module/synthio/__init__.c @@ -1,9 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * Copyright (c) 2023 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #include "shared-module/synthio/__init__.h" +#include "py/runtime.h" + +STATIC const int16_t square_wave[] = {-32768, 32767}; STATIC const uint16_t notes[] = {8372, 8870, 9397, 9956, 10548, 11175, 11840, 12544, 13290, 14080, 14917, 15804}; // 9th octave -STATIC int count_active_channels(synthio_midi_span_t *span) { +int synthio_span_count_active_channels(synthio_midi_span_t *span) { int result = 0; for (int i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { if (span->note[i] != SYNTHIO_SILENCE) { @@ -20,7 +50,7 @@ void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t memset(synth->buffer, 0, synth->buffer_length); int32_t sample_rate = synth->sample_rate; - int active_channels = count_active_channels(&synth->span); + int active_channels = synthio_span_count_active_channels(&synth->span); const int16_t *waveform = synth->waveform; uint32_t waveform_length = synth->waveform_length; int16_t *out_buffer = synth->buffer; @@ -79,3 +109,39 @@ void synthio_synth_get_buffer_structure(synthio_synth_t *synth, bool single_chan *max_buffer_length = synth->buffer_length; *spacing = 1; } + +void synthio_synth_parse_waveform(mp_buffer_info_t *bufinfo_waveform, mp_obj_t waveform_obj) { + *bufinfo_waveform = ((mp_buffer_info_t) { .buf = (void *)square_wave, .len = 4 }); + + if (waveform_obj != mp_const_none) { + mp_get_buffer_raise(waveform_obj, bufinfo_waveform, MP_BUFFER_READ); + if (bufinfo_waveform->typecode != 'h') { + mp_raise_ValueError_varg(translate("%q must be array of type 'h'"), MP_QSTR_waveform); + } + } + mp_arg_validate_length_range(bufinfo_waveform->len / 2, 2, 1024, MP_QSTR_waveform); +} + +void synthio_span_init(synthio_midi_span_t *span) { + span->dur = 0; + for (size_t i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { span->note[i] = SYNTHIO_SILENCE; + } +} + +STATIC int find_channel_with_note(const synthio_midi_span_t *span, uint8_t note) { + for (int i = 0; i < CIRCUITPY_SYNTHIO_MAX_CHANNELS; i++) { + if (span->note[i] == note) { + return i; + } + } + return -1; +} + +bool synthio_span_change_note(synthio_midi_span_t *span, uint8_t old_note, uint8_t new_note) { + int channel = find_channel_with_note(span, old_note); + if (channel != -1) { + span->note[channel] = new_note; + return true; + } + return false; +} diff --git a/shared-module/synthio/__init__.h b/shared-module/synthio/__init__.h index 88be7e689e..9397495f98 100644 --- a/shared-module/synthio/__init__.h +++ b/shared-module/synthio/__init__.h @@ -48,9 +48,13 @@ typedef struct { uint32_t accum[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; } synthio_synth_t; +void synthio_span_init(synthio_midi_span_t *span); void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t *buffer_length); void synthio_synth_deinit(synthio_synth_t *synth); bool synthio_synth_deinited(synthio_synth_t *synth); void synthio_synth_init(synthio_synth_t *synth, uint16_t max_dur); void synthio_synth_get_buffer_structure(synthio_synth_t *synth, bool single_channel_output, bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing); +void synthio_synth_parse_waveform(mp_buffer_info_t *bufinfo_waveform, mp_obj_t waveform_obj); +bool synthio_span_change_note(synthio_midi_span_t *span, uint8_t old_note, uint8_t new_note); +int synthio_span_count_active_channels(synthio_midi_span_t *span); diff --git a/tests/circuitpython/synthesizer.py b/tests/circuitpython/synthesizer.py new file mode 100644 index 0000000000..bdb273f861 --- /dev/null +++ b/tests/circuitpython/synthesizer.py @@ -0,0 +1,24 @@ +import struct +import synthio +import audiocore + + +def dump_samples(): + print(struct.unpack("12h", audiocore.get_buffer(s)[1][:24])) + + +s = synthio.Synthesizer(sample_rate=8000) +print(s.pressed) +dump_samples() + +s.press((80,)) +print(s.pressed) +dump_samples() + +s.press((91,)) +print(s.pressed) +dump_samples() + +s.release_then_press((80,)) +print(s.pressed) +dump_samples() diff --git a/tests/circuitpython/synthesizer.py.exp b/tests/circuitpython/synthesizer.py.exp new file mode 100644 index 0000000000..aa2567641c --- /dev/null +++ b/tests/circuitpython/synthesizer.py.exp @@ -0,0 +1,8 @@ +() +(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) +(80,) +(-4095, -4095, -4095, -4095, 4095, 4095, 4095, 4095, 4095, -4095, -4095, -4095) +(80, 91) +(-5460, -5460, 0, 5460, 5460, 0, 0, 5460, 0, 0, -5460, -5460) +(91,) +(4095, 4095, 4095, -4095, -4095, 4095, 4095, 4095, -4095, -4095, 4095, 4095) From 60e12c5c1d40550ca8c5c97abd15305926e46777 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 3 Apr 2023 15:43:29 -0500 Subject: [PATCH 195/225] only add circuitpython_splash to display if it's not already in another group --- shared-module/displayio/Display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 5af97a4144..d0608cd532 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -136,7 +136,9 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self, // Set the group after initialization otherwise we may send pixels while we delay in // initialization. - common_hal_displayio_display_set_root_group(self, &circuitpython_splash); + if (!circuitpython_splash.in_group) { + common_hal_displayio_display_set_root_group(self, &circuitpython_splash); + } common_hal_displayio_display_set_auto_refresh(self, auto_refresh); } From 5d56ef06e7d526ee9f4f97dbe7704788cc353b18 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 4 Apr 2023 19:16:39 -0400 Subject: [PATCH 196/225] Add Adafruit Feather RP2040 CAN --- .../adafruit_feather_rp2040_can/board.c | 29 ++++++++++ .../mpconfigboard.h | 14 +++++ .../mpconfigboard.mk | 9 +++ .../pico-sdk-configboard.h | 4 ++ .../boards/adafruit_feather_rp2040_can/pins.c | 56 +++++++++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_can/board.c create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_can/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_can/pins.c diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_can/board.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/board.c new file mode 100644 index 0000000000..331653173e --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/board.c @@ -0,0 +1,29 @@ +/* + * 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" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h new file mode 100644 index 0000000000..519c784452 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h @@ -0,0 +1,14 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040 CAN" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO20) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO8) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.mk new file mode 100644 index 0000000000..543b5adcc0 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x8130 +USB_PRODUCT = "Feather RP2040 CAN" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_can/pico-sdk-configboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_can/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/pins.c new file mode 100644 index 0000000000..b64d007a0d --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/pins.c @@ -0,0 +1,56 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { 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_D24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_CAN_STANDBY), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_CAN_TX0_RTS), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_CAN_RESET), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_CAN_CS), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_CAN_INTERRUPT), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_CAN_RX0_BF), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); From 44d7f4e7e1c0bde0d794b5ece4b9a5298b35bba1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 4 Apr 2023 19:33:39 -0400 Subject: [PATCH 197/225] fix Neopixel for RP2040 CAN --- .../boards/adafruit_feather_rp2040_can/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h index 519c784452..a012abec22 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_can/mpconfigboard.h @@ -1,7 +1,7 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040 CAN" #define MICROPY_HW_MCU_NAME "rp2040" -#define MICROPY_HW_NEOPIXEL (&pin_GPIO20) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) From 85cc21adc0a890310f7d078d95717cccf9aa6d05 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 4 Apr 2023 19:40:37 -0400 Subject: [PATCH 198/225] add Adafruit Feather RP2040 USB Host --- .../adafruit_feather_rp2040_usb_host/board.c | 29 ++++++++++ .../mpconfigboard.h | 14 +++++ .../mpconfigboard.mk | 9 ++++ .../pico-sdk-configboard.h | 4 ++ .../adafruit_feather_rp2040_usb_host/pins.c | 53 +++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/board.c create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pins.c diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/board.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/board.c new file mode 100644 index 0000000000..331653173e --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/board.c @@ -0,0 +1,29 @@ +/* + * 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" + +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.h new file mode 100644 index 0000000000..f300bfe711 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.h @@ -0,0 +1,14 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040 USB Host" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO8) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.mk new file mode 100644 index 0000000000..d249861efb --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x812A +USB_PRODUCT = "Feather RP2040 USB Host" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pico-sdk-configboard.h b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pins.c new file mode 100644 index 0000000000..ab07688f4c --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040_usb_host/pins.c @@ -0,0 +1,53 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { 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_D24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DATA_PLUS), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DATA_MINUS), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_USB_HOST_5V_POWER), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_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_module_globals_table); From 8bf94d03e48a90d83da9eeeb7711c1038ce1873b Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 4 Apr 2023 20:31:42 -0500 Subject: [PATCH 199/225] try to fix multi-display reset --- shared-module/displayio/Display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index d0608cd532..01d8c544ad 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -439,7 +439,9 @@ void reset_display(displayio_display_obj_t *self) { circuitpython_splash.x = 0; // reset position in case someone moved it. circuitpython_splash.y = 0; supervisor_start_terminal(self->core.width, self->core.height); - common_hal_displayio_display_set_root_group(self, &circuitpython_splash); + if (!circuitpython_splash.in_group) { + common_hal_displayio_display_set_root_group(self, &circuitpython_splash); + } } void displayio_display_collect_ptrs(displayio_display_obj_t *self) { From b9dea05dbfaa9a55a429892b1cf87e1518083866 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 08:51:55 -0500 Subject: [PATCH 200/225] Enable audiomixer on unix port, for testing --- ports/unix/variants/coverage/mpconfigvariant.mk | 7 +++++++ shared-bindings/audiomixer/Mixer.c | 2 -- shared-bindings/audiomixer/Mixer.h | 1 - shared-bindings/audiomixer/MixerVoice.c | 4 +--- shared-bindings/audiomixer/MixerVoice.h | 7 ++----- shared-bindings/audiomixer/__init__.c | 1 - shared-module/audiomixer/Mixer.c | 6 +++++- shared-module/audiomixer/MixerVoice.c | 8 ++++---- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index 8b25ddb705..854d052c6c 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -33,6 +33,9 @@ SRC_BITMAP := \ shared-bindings/audiocore/__init__.c \ shared-bindings/audiocore/RawSample.c \ shared-bindings/audiocore/WaveFile.c \ + shared-bindings/audiomixer/__init__.c \ + shared-bindings/audiomixer/Mixer.c \ + shared-bindings/audiomixer/MixerVoice.c \ shared-bindings/bitmaptools/__init__.c \ shared-bindings/displayio/Bitmap.c \ shared-bindings/rainbowio/__init__.c \ @@ -48,6 +51,9 @@ SRC_BITMAP := \ shared-module/audiocore/__init__.c \ shared-module/audiocore/RawSample.c \ shared-module/audiocore/WaveFile.c \ + shared-module/audiomixer/__init__.c \ + shared-module/audiomixer/Mixer.c \ + shared-module/audiomixer/MixerVoice.c \ shared-module/bitmaptools/__init__.c \ shared-module/displayio/area.c \ shared-module/displayio/Bitmap.c \ @@ -67,6 +73,7 @@ SRC_C += $(SRC_BITMAP) CFLAGS += \ -DCIRCUITPY_AESIO=1 \ -DCIRCUITPY_AUDIOCORE=1 \ + -DCIRCUITPY_AUDIOMIXER=1 \ -DCIRCUITPY_AUDIOCORE_DEBUG=1 \ -DCIRCUITPY_BITMAPTOOLS=1 \ -DCIRCUITPY_DISPLAYIO_UNIX=1 \ diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 58c618fc11..83fcc06712 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -33,8 +33,6 @@ #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate/translate.h" diff --git a/shared-bindings/audiomixer/Mixer.h b/shared-bindings/audiomixer/Mixer.h index fd1154cc43..d04f793dde 100644 --- a/shared-bindings/audiomixer/Mixer.h +++ b/shared-bindings/audiomixer/Mixer.h @@ -28,7 +28,6 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H #include "shared-module/audiomixer/Mixer.h" -#include "shared-bindings/audiocore/RawSample.h" extern const mp_obj_type_t audiomixer_mixer_type; extern const mp_obj_type_t audiomixer_mixervoice_type; diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 16a1be520f..1d6cd7f39a 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -32,8 +32,6 @@ #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate/translate.h" @@ -115,7 +113,7 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_set_level(size_t n_args, const mp_obj_ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - float level = mp_obj_get_float(args[ARG_level].u_obj); + mp_float_t level = mp_obj_get_float(args[ARG_level].u_obj); if (level > 1 || level < 0) { mp_raise_ValueError(translate("level must be between 0 and 1")); diff --git a/shared-bindings/audiomixer/MixerVoice.h b/shared-bindings/audiomixer/MixerVoice.h index bce4632760..0ff8accee4 100644 --- a/shared-bindings/audiomixer/MixerVoice.h +++ b/shared-bindings/audiomixer/MixerVoice.h @@ -26,9 +26,6 @@ #ifndef SHARED_BINDINGS_AUDIOMIXER_MIXERVOICE_H_ #define SHARED_BINDINGS_AUDIOMIXER_MIXERVOICE_H_ -#include "common-hal/microcontroller/Pin.h" -#include "shared-bindings/audiocore/RawSample.h" - #include "shared-module/audiomixer/MixerVoice.h" #include "shared-module/audiomixer/Mixer.h" @@ -39,8 +36,8 @@ void common_hal_audiomixer_mixervoice_construct(audiomixer_mixervoice_obj_t *sel void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t *self, audiomixer_mixer_obj_t *parent); void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp_obj_t sample, bool loop); void common_hal_audiomixer_mixervoice_stop(audiomixer_mixervoice_obj_t *self); -float common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self); -void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, float gain); +mp_float_t common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self); +void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, mp_float_t gain); bool common_hal_audiomixer_mixervoice_get_playing(audiomixer_mixervoice_obj_t *self); diff --git a/shared-bindings/audiomixer/__init__.c b/shared-bindings/audiomixer/__init__.c index 8292be9e95..4c8068172b 100644 --- a/shared-bindings/audiomixer/__init__.c +++ b/shared-bindings/audiomixer/__init__.c @@ -29,7 +29,6 @@ #include "py/obj.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiomixer/Mixer.h" //| """Support for audio mixing""" diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index 1c5de4d934..ce39f88919 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -35,6 +35,10 @@ #include "shared-module/audiocore/__init__.h" #include "shared-module/audiocore/RawSample.h" +#if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) +#include "periph.h" +#endif + void common_hal_audiomixer_mixer_construct(audiomixer_mixer_obj_t *self, uint8_t voice_count, uint32_t buffer_size, @@ -140,7 +144,7 @@ static inline uint32_t mult16signed(uint32_t val, int32_t mul) { float mod_mul = (float)mul / (float)((1 << 15) - 1); for (int8_t i = 0; i < 2; i++) { int16_t ai = (val >> (sizeof(uint16_t) * 8 * i)); - int32_t intermediate = ai * mod_mul; + int32_t intermediate = (int32_t)(ai * mod_mul); if (intermediate > SHRT_MAX) { intermediate = SHRT_MAX; } else if (intermediate < SHRT_MIN) { diff --git a/shared-module/audiomixer/MixerVoice.c b/shared-module/audiomixer/MixerVoice.c index bb58b0c111..f4d2a6514e 100644 --- a/shared-module/audiomixer/MixerVoice.c +++ b/shared-module/audiomixer/MixerVoice.c @@ -42,12 +42,12 @@ void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t *se self->parent = parent; } -float common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self) { - return (float)self->level / (1 << 15); +mp_float_t common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self) { + return (mp_float_t)self->level / (1 << 15); } -void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, float level) { - self->level = level * (1 << 15); +void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, mp_float_t level) { + self->level = (uint16_t)(level * (1 << 15)); } void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp_obj_t sample, bool loop) { From 4c7b962d16f556a9fce9462289379fa243571ce3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 10:30:57 -0500 Subject: [PATCH 201/225] Increase synthio channels to 12 on rp2040 with the AudioMixer workaround for #7837 this appears to work even up to 48kHz. --- ports/raspberrypi/mpconfigport.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 21dde6d239..671d4669bf 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -19,6 +19,7 @@ CIRCUITPY_PWMIO ?= 1 CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_DISPLAYIO) CIRCUITPY_ROTARYIO ?= 1 CIRCUITPY_ROTARYIO_SOFTENCODER = 1 +CIRCUITPY_SYNTHIO_MAX_CHANNELS = 12 # Things that need to be implemented. # Use PWM internally From 685fdf29e32b5b62f43f037be4d9f1ae89e1df38 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 10:31:05 -0500 Subject: [PATCH 202/225] remove include directory that doesn't exist --- ports/mimxrt10xx/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index ff2b6c35c1..72f4d191ef 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -38,7 +38,6 @@ INC += \ -Iboards/$(BOARD) \ -Iperipherals/ \ -Iperipherals/mimxrt10xx/ \ - -Isdk/CMSIS/Include \ -Isdk/devices/$(CHIP_FAMILY) \ -Isdk/devices/$(CHIP_FAMILY)/drivers \ -Isdk/drivers/common From 3038b9a56055190d6a523065877caa08e876883b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 11:56:21 -0500 Subject: [PATCH 203/225] Update shared-bindings/keypad/ShiftRegisterKeys.c Co-authored-by: Scott Shawcroft --- shared-bindings/keypad/ShiftRegisterKeys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index 9c44717a41..465ff9542c 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -82,7 +82,7 @@ //| ... STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - #if CIRCUITPY_KEYPAD_KEYMATRIX + #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS keypad_shiftregisterkeys_obj_t *self = m_new_obj(keypad_shiftregisterkeys_obj_t); self->base.type = &keypad_shiftregisterkeys_type; enum { ARG_clock, ARG_data, ARG_latch, ARG_value_to_latch, ARG_key_count, ARG_value_when_pressed, ARG_interval, ARG_max_events }; From 9679aaa0be1a2b1943430b798c770b5e0377b83b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 11:57:06 -0500 Subject: [PATCH 204/225] Apply suggestions from code review Co-authored-by: Scott Shawcroft --- shared-bindings/keypad/ShiftRegisterKeys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index 465ff9542c..1fcf517ac3 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -119,7 +119,7 @@ STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, siz #endif } -#if CIRCUITPY_KEYPAD_KEYMATRIX +#if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... @@ -180,7 +180,7 @@ const mp_obj_type_t keypad_shiftregisterkeys_type = { { &mp_type_type }, .name = MP_QSTR_ShiftRegisterKeys, .make_new = keypad_shiftregisterkeys_make_new, - #if CIRCUITPY_KEYPAD_KEYMATRIX + #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS .locals_dict = (mp_obj_t)&keypad_shiftregisterkeys_locals_dict, #endif }; From 04f4092e110b50fc03dd55e8a5f1c2151c5d0035 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 11:55:54 -0500 Subject: [PATCH 205/225] synthio: support audio outputs that need double buffering closes #7837 tested on rp2040 pico w on pico dv shield --- shared-module/synthio/MidiTrack.c | 4 +-- shared-module/synthio/Synthesizer.c | 3 ++- shared-module/synthio/__init__.c | 42 ++++++++++++++++++++++------- shared-module/synthio/__init__.h | 10 ++++--- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c index 0d91ee6982..f8b39c29e3 100644 --- a/shared-module/synthio/MidiTrack.c +++ b/shared-module/synthio/MidiTrack.c @@ -156,7 +156,7 @@ uint8_t common_hal_synthio_miditrack_get_channel_count(synthio_miditrack_obj_t * void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self, bool single_channel_output, uint8_t channel) { - + synthio_synth_reset_buffer(&self->synth, single_channel_output, channel); self->synth.span.dur = 0; self->next_span = 0; } @@ -172,7 +172,7 @@ audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t self->synth.span = self->track[self->next_span++]; } - synthio_synth_synthesize(&self->synth, buffer, buffer_length); + synthio_synth_synthesize(&self->synth, buffer, buffer_length, single_channel_output ? 0 : channel); return (self->synth.span.dur == 0 && self->next_span >= self->total_spans) ? GET_BUFFER_DONE : GET_BUFFER_MORE_DATA; diff --git a/shared-module/synthio/Synthesizer.c b/shared-module/synthio/Synthesizer.c index 8cfc73a980..25c91ecbe0 100644 --- a/shared-module/synthio/Synthesizer.c +++ b/shared-module/synthio/Synthesizer.c @@ -58,12 +58,13 @@ uint8_t common_hal_synthio_synthesizer_get_channel_count(synthio_synthesizer_obj void synthio_synthesizer_reset_buffer(synthio_synthesizer_obj_t *self, bool single_channel_output, uint8_t channel) { + synthio_synth_reset_buffer(&self->synth, single_channel_output, channel); } audioio_get_buffer_result_t synthio_synthesizer_get_buffer(synthio_synthesizer_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { self->synth.span.dur = SYNTHIO_MAX_DUR; - synthio_synth_synthesize(&self->synth, buffer, buffer_length); + synthio_synth_synthesize(&self->synth, buffer, buffer_length, single_channel_output ? channel : 0); return GET_BUFFER_MORE_DATA; } diff --git a/shared-module/synthio/__init__.c b/shared-module/synthio/__init__.c index 0dee75deb7..7ac8e47746 100644 --- a/shared-module/synthio/__init__.c +++ b/shared-module/synthio/__init__.c @@ -44,16 +44,27 @@ int synthio_span_count_active_channels(synthio_midi_span_t *span) { } -void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t *buffer_length) { +void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **bufptr, uint32_t *buffer_length, uint8_t channel) { + + if (channel == synth->other_channel) { + *buffer_length = synth->last_buffer_length; + *bufptr = (uint8_t *)(synth->buffers[synth->other_buffer_index] + channel); + return; + } + + synth->buffer_index = !synth->buffer_index; + synth->other_channel = 1 - channel; + synth->other_buffer_index = synth->buffer_index; + int16_t *out_buffer = (int16_t *)(void *)synth->buffers[synth->buffer_index]; + uint16_t dur = MIN(SYNTHIO_MAX_DUR, synth->span.dur); synth->span.dur -= dur; - memset(synth->buffer, 0, synth->buffer_length); + memset(out_buffer, 0, synth->buffer_length); int32_t sample_rate = synth->sample_rate; int active_channels = synthio_span_count_active_channels(&synth->span); const int16_t *waveform = synth->waveform; uint32_t waveform_length = synth->waveform_length; - int16_t *out_buffer = synth->buffer; if (active_channels) { int16_t loudness = 0x3fff / (1 + active_channels); for (int chan = 0; chan < CIRCUITPY_SYNTHIO_MAX_CHANNELS; chan++) { @@ -84,27 +95,38 @@ void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t } } - *buffer_length = dur * SYNTHIO_BYTES_PER_SAMPLE; - *buffer = (uint8_t *)synth->buffer; + *buffer_length = synth->last_buffer_length = dur * SYNTHIO_BYTES_PER_SAMPLE; + *bufptr = (uint8_t *)out_buffer; +} + +void synthio_synth_reset_buffer(synthio_synth_t *synth, bool single_channel_output, uint8_t channel) { + if (single_channel_output && channel == 1) { + return; + } + synth->other_channel = -1; } bool synthio_synth_deinited(synthio_synth_t *synth) { - return synth->buffer == NULL; + return synth->buffers[0] == NULL; } void synthio_synth_deinit(synthio_synth_t *synth) { - m_del(uint8_t, synth->buffer, synth->buffer_length); - synth->buffer = NULL; + m_del(uint8_t, synth->buffers[0], synth->buffer_length); + m_del(uint8_t, synth->buffers[1], synth->buffer_length); + synth->buffers[0] = NULL; + synth->buffers[1] = NULL; } void synthio_synth_init(synthio_synth_t *synth, uint16_t max_dur) { synth->buffer_length = MIN(SYNTHIO_MAX_DUR, max_dur) * SYNTHIO_BYTES_PER_SAMPLE; - synth->buffer = m_malloc(synth->buffer_length, false); + synth->buffers[0] = m_malloc(synth->buffer_length, false); + synth->buffers[1] = m_malloc(synth->buffer_length, false); + synth->other_channel = -1; } void synthio_synth_get_buffer_structure(synthio_synth_t *synth, bool single_channel_output, bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing) { - *single_buffer = true; + *single_buffer = false; *samples_signed = true; *max_buffer_length = synth->buffer_length; *spacing = 1; diff --git a/shared-module/synthio/__init__.h b/shared-module/synthio/__init__.h index 9397495f98..e14e5ead10 100644 --- a/shared-module/synthio/__init__.h +++ b/shared-module/synthio/__init__.h @@ -28,7 +28,7 @@ #define SYNTHIO_BITS_PER_SAMPLE (16) #define SYNTHIO_BYTES_PER_SAMPLE (SYNTHIO_BITS_PER_SAMPLE / 8) -#define SYNTHIO_MAX_DUR (512) +#define SYNTHIO_MAX_DUR (256) #define SYNTHIO_SILENCE (0x80) #include "shared-module/audiocore/__init__.h" @@ -40,21 +40,25 @@ typedef struct { typedef struct { uint32_t sample_rate; - int16_t *buffer; + int16_t *buffers[2]; const int16_t *waveform; uint16_t buffer_length; + uint16_t last_buffer_length; + uint8_t other_channel, buffer_index, other_buffer_index; uint16_t waveform_length; synthio_midi_span_t span; uint32_t accum[CIRCUITPY_SYNTHIO_MAX_CHANNELS]; } synthio_synth_t; void synthio_span_init(synthio_midi_span_t *span); -void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t *buffer_length); +void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **buffer, uint32_t *buffer_length, uint8_t channel); void synthio_synth_deinit(synthio_synth_t *synth); bool synthio_synth_deinited(synthio_synth_t *synth); void synthio_synth_init(synthio_synth_t *synth, uint16_t max_dur); void synthio_synth_get_buffer_structure(synthio_synth_t *synth, bool single_channel_output, bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing); +void synthio_synth_reset_buffer(synthio_synth_t *synth, bool single_channel_output, uint8_t channel); void synthio_synth_parse_waveform(mp_buffer_info_t *bufinfo_waveform, mp_obj_t waveform_obj); + bool synthio_span_change_note(synthio_midi_span_t *span, uint8_t old_note, uint8_t new_note); int synthio_span_count_active_channels(synthio_midi_span_t *span); From 14637cd75ad2d5d7e61fa6272dafc0ce0671c648 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 12:00:05 -0500 Subject: [PATCH 206/225] update tests with new expected results --- tests/circuitpython/miditrack.py.exp | 8 ++++---- tests/circuitpython/synthesizer.py.exp | 4 ++-- tests/unix/extra_coverage.py.exp | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/circuitpython/miditrack.py.exp b/tests/circuitpython/miditrack.py.exp index c5dc447e74..be5eef1d0b 100644 --- a/tests/circuitpython/miditrack.py.exp +++ b/tests/circuitpython/miditrack.py.exp @@ -1,4 +1,4 @@ -(1, 1, 800, 1) -(1, b'\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0') -(1, 1, 800, 1) -(1, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f') +(0, 1, 512, 1) +(1, b'\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f') +(0, 1, 512, 1) +(1, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00') diff --git a/tests/circuitpython/synthesizer.py.exp b/tests/circuitpython/synthesizer.py.exp index aa2567641c..4296662d60 100644 --- a/tests/circuitpython/synthesizer.py.exp +++ b/tests/circuitpython/synthesizer.py.exp @@ -3,6 +3,6 @@ (80,) (-4095, -4095, -4095, -4095, 4095, 4095, 4095, 4095, 4095, -4095, -4095, -4095) (80, 91) -(-5460, -5460, 0, 5460, 5460, 0, 0, 5460, 0, 0, -5460, -5460) +(0, 0, 5460, 5460, 0, -5460, -5460, 0, 5460, 5460, 0, 0) (91,) -(4095, 4095, 4095, -4095, -4095, 4095, 4095, 4095, -4095, -4095, 4095, 4095) +(-4095, 4095, 4095, 4095, -4095, -4095, 4095, 4095, 4095, -4095, -4095, 4095) diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 0baf8e1f44..c750ca0e95 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -31,15 +31,15 @@ mport builtins micropython _asyncio _thread _uasyncio aesio array audiocore -binascii bitmaptools btree cexample -cmath collections cppexample displayio -errno ffi framebuf gc -hashlib json math qrio -rainbowio re struct synthio -sys termios traceback ubinascii -uctypes uerrno uheapq uio -ujson ulab ulab.numpy ulab.numpy.fft -ulab.numpy.linalg ulab.scipy +audiomixer binascii bitmaptools btree +cexample cmath collections cppexample +displayio errno ffi framebuf +gc hashlib json math +qrio rainbowio re struct +synthio sys termios traceback +ubinascii uctypes uerrno uheapq +uio ujson ulab ulab.numpy +ulab.numpy.fft ulab.numpy.linalg ulab.scipy ulab.scipy.linalg ulab.scipy.optimize ulab.scipy.signal ulab.scipy.special ulab.utils uos urandom ure From 9825b7fbb7bf260485e66e66b0f38fb76f32f0ad Mon Sep 17 00:00:00 2001 From: Ted Hess Date: Tue, 4 Apr 2023 15:07:04 -0400 Subject: [PATCH 207/225] Web Workflow sockets and threads handling improvements. Fixes polling thread looping forever hangs preventing new connections. Don't lose listening sockets on mp resets and re-init. Keep better separation of "system" and "user" sockets. Track socket states to prevent re-use of sockets before closed. Close REST socket when transaction completes. No post-init. Remove unnecessary state flags. --- .../espressif/common-hal/socketpool/Socket.c | 235 ++++++++++-------- .../espressif/common-hal/socketpool/Socket.h | 2 + .../common-hal/socketpool/Socket.h | 3 + supervisor/shared/web_workflow/web_workflow.c | 85 ++++--- supervisor/shared/web_workflow/web_workflow.h | 2 +- supervisor/shared/web_workflow/websocket.c | 14 +- supervisor/shared/workflow.c | 40 +-- 7 files changed, 199 insertions(+), 182 deletions(-) diff --git a/ports/espressif/common-hal/socketpool/Socket.c b/ports/espressif/common-hal/socketpool/Socket.c index 19e83e717f..5af3cdbbc3 100644 --- a/ports/espressif/common-hal/socketpool/Socket.c +++ b/ports/espressif/common-hal/socketpool/Socket.c @@ -45,70 +45,79 @@ StackType_t socket_select_stack[2 * configMINIMAL_STACK_SIZE]; -STATIC int open_socket_fds[CONFIG_LWIP_MAX_SOCKETS]; +/* Socket state table: + * 0 := Closed (unused) + * 1 := Open + * 2 := Closing (remove from rfds) + * Index into socket_fd_state is calculated from actual lwip fd. idx := fd - LWIP_SOCKET_OFFSET +*/ +#define FDSTATE_CLOSED 0 +#define FDSTATE_OPEN 1 +#define FDSTATE_CLOSING 2 +STATIC uint8_t socket_fd_state[CONFIG_LWIP_MAX_SOCKETS]; + STATIC socketpool_socket_obj_t *user_socket[CONFIG_LWIP_MAX_SOCKETS]; -StaticTask_t socket_select_task_handle; +StaticTask_t socket_select_task_buffer; +TaskHandle_t socket_select_task_handle; STATIC int socket_change_fd = -1; STATIC void socket_select_task(void *arg) { uint64_t signal; + fd_set readfds; + fd_set excptfds; while (true) { - fd_set readfds; - fd_set errfds; FD_ZERO(&readfds); - FD_ZERO(&errfds); + FD_ZERO(&excptfds); FD_SET(socket_change_fd, &readfds); - FD_SET(socket_change_fd, &errfds); int max_fd = socket_change_fd; - for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_fds); i++) { - int sockfd = open_socket_fds[i]; - if (sockfd < 0) { - continue; + for (size_t i = 0; i < MP_ARRAY_SIZE(socket_fd_state); i++) { + if ((socket_fd_state[i] == FDSTATE_OPEN) && (user_socket[i] == NULL)) { + int sockfd = i + LWIP_SOCKET_OFFSET; + max_fd = MAX(max_fd, sockfd); + FD_SET(sockfd, &readfds); + FD_SET(sockfd, &excptfds); } - max_fd = MAX(max_fd, sockfd); - FD_SET(sockfd, &readfds); - FD_SET(sockfd, &errfds); } - int num_triggered = select(max_fd + 1, &readfds, NULL, &errfds, NULL); - // Check for bad file descriptor and queue up the background task before - // circling around. - if (num_triggered == -1 && errno == EBADF) { - // One for the change fd and one for the closed socket. - num_triggered = 2; + int num_triggered = select(max_fd + 1, &readfds, NULL, &excptfds, NULL); + // Hard error (or someone closed a socket on another thread) + if (num_triggered == -1) { + assert(errno == EBADF); + continue; } - // Try and find the bad file and remove it from monitoring. - for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_fds); i++) { - int sockfd = open_socket_fds[i]; - if (sockfd < 0) { - continue; - } - int err; - int optlen = sizeof(int); - int ret = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &err, (socklen_t *)&optlen); - if (ret < 0) { - open_socket_fds[i] = -1; - // Raise num_triggered so that we skip the assert and queue the background task. - num_triggered = 2; - } - } - assert(num_triggered >= 0); + assert(num_triggered > 0); + assert(!FD_ISSET(socket_change_fd, &excptfds)); + + // Notice event trigger if (FD_ISSET(socket_change_fd, &readfds)) { read(socket_change_fd, &signal, sizeof(signal)); - num_triggered -= 1; + num_triggered--; } + + // Handle active FDs, close the dead ones + for (size_t i = 0; i < MP_ARRAY_SIZE(socket_fd_state); i++) { + int sockfd = i + LWIP_SOCKET_OFFSET; + if (socket_fd_state[i] != FDSTATE_CLOSED) { + if (FD_ISSET(sockfd, &readfds) || FD_ISSET(sockfd, &excptfds)) { + if (socket_fd_state[i] == FDSTATE_CLOSING) { + socket_fd_state[i] = FDSTATE_CLOSED; + num_triggered--; + } + } + } + } + if (num_triggered > 0) { + // Wake up CircuitPython by queuing request supervisor_workflow_request_background(); - - // Wake up CircuitPython. We know it is asleep because we are lower - // priority. - port_wake_main_task(); + ulTaskNotifyTake(pdTRUE, portMAX_DELAY); } - } + close(socket_change_fd); + socket_change_fd = -1; vTaskDelete(NULL); } @@ -117,75 +126,62 @@ void socket_user_reset(void) { esp_vfs_eventfd_config_t config = ESP_VFS_EVENTD_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_vfs_eventfd_register(&config)); - for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_fds); i++) { - open_socket_fds[i] = -1; + // Clear initial socket states + for (size_t i = 0; i < MP_ARRAY_SIZE(socket_fd_state); i++) { + socket_fd_state[i] = FDSTATE_CLOSED; user_socket[i] = NULL; } socket_change_fd = eventfd(0, 0); // Run this at the same priority as CP so that the web workflow background task can be // queued while CP is running. Both tasks can still sleep and, therefore, sleep overall. - (void)xTaskCreateStaticPinnedToCore(socket_select_task, + socket_select_task_handle = xTaskCreateStaticPinnedToCore(socket_select_task, "socket_select", 2 * configMINIMAL_STACK_SIZE, NULL, uxTaskPriorityGet(NULL), socket_select_stack, - &socket_select_task_handle, + &socket_select_task_buffer, xPortGetCoreID()); - } - - for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_fds); i++) { - if (open_socket_fds[i] >= 0 && user_socket[i]) { - common_hal_socketpool_socket_close(user_socket[i]); - int num = open_socket_fds[i]; - // Close automatically clears socket handle - lwip_shutdown(num, SHUT_RDWR); - lwip_close(num); - open_socket_fds[i] = -1; - user_socket[i] = NULL; + } else { + // Not init - close open user sockets + for (size_t i = 0; i < MP_ARRAY_SIZE(socket_fd_state); i++) { + if ((socket_fd_state[i] == FDSTATE_OPEN) && user_socket[i]) { + common_hal_socketpool_socket_close(user_socket[i]); + } } } } +// Unblock select task (ok if not blocked yet) +void socketpool_socket_poll_resume(void) { + if (socket_select_task_handle) { + xTaskNotifyGive(socket_select_task_handle); + } +} + // The writes below send an event to the socket select task so that it redoes the // select with the new open socket set. STATIC bool register_open_socket(int fd) { - for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_fds); i++) { - if (open_socket_fds[i] == -1) { - open_socket_fds[i] = fd; - user_socket[i] = false; - uint64_t signal = 1; - write(socket_change_fd, &signal, sizeof(signal)); - return true; - } + if (fd < FD_SETSIZE) { + socket_fd_state[fd - LWIP_SOCKET_OFFSET] = FDSTATE_OPEN; + user_socket[fd - LWIP_SOCKET_OFFSET] = NULL; + + uint64_t signal = 1; + write(socket_change_fd, &signal, sizeof(signal)); + socketpool_socket_poll_resume(); + return true; } return false; } -STATIC void unregister_open_socket(int fd) { - for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_fds); i++) { - if (open_socket_fds[i] == fd) { - open_socket_fds[i] = -1; - user_socket[i] = false; - // Write must be 8 bytes for an eventfd. - uint64_t signal = 1; - write(socket_change_fd, &signal, sizeof(signal)); - return; - } - } -} - STATIC void mark_user_socket(int fd, socketpool_socket_obj_t *obj) { - for (size_t i = 0; i < MP_ARRAY_SIZE(open_socket_fds); i++) { - if (open_socket_fds[i] == fd) { - user_socket[i] = obj; - return; - } - } + socket_fd_state[fd - LWIP_SOCKET_OFFSET] = FDSTATE_OPEN; + user_socket[fd - LWIP_SOCKET_OFFSET] = obj; + // No need to wakeup select task } -bool socketpool_socket(socketpool_socketpool_obj_t *self, +STATIC bool _socketpool_socket(socketpool_socketpool_obj_t *self, socketpool_socketpool_addressfamily_t family, socketpool_socketpool_sock_t type, socketpool_socket_obj_t *sock) { int addr_family; @@ -193,9 +189,11 @@ bool socketpool_socket(socketpool_socketpool_obj_t *self, if (family == SOCKETPOOL_AF_INET) { addr_family = AF_INET; ipproto = IPPROTO_IP; + #if LWIP_IPV6 } else { // INET6 addr_family = AF_INET6; ipproto = IPPROTO_IPV6; + #endif } int socket_type; @@ -218,14 +216,28 @@ bool socketpool_socket(socketpool_socketpool_obj_t *self, if (socknum < 0) { return false; } - // This shouldn't happen since we have room for the same number of sockets as LWIP. - if (!register_open_socket(socknum)) { - lwip_close(socknum); - return false; - } + sock->num = socknum; // Sockets should be nonblocking in most cases lwip_fcntl(socknum, F_SETFL, O_NONBLOCK); + + return true; +} + +// special entry for workflow listener (register system socket) +bool socketpool_socket(socketpool_socketpool_obj_t *self, + socketpool_socketpool_addressfamily_t family, socketpool_socketpool_sock_t type, + socketpool_socket_obj_t *sock) { + + if (!_socketpool_socket(self, family, type, sock)) { + return false; + } + + // This shouldn't happen since we have room for the same number of sockets as LWIP. + if (!register_open_socket(sock->num)) { + lwip_close(sock->num); + return false; + } return true; } @@ -238,7 +250,7 @@ socketpool_socket_obj_t *common_hal_socketpool_socket(socketpool_socketpool_obj_ socketpool_socket_obj_t *sock = m_new_obj_with_finaliser(socketpool_socket_obj_t); sock->base.type = &socketpool_socket_type; - if (!socketpool_socket(self, family, type, sock)) { + if (!_socketpool_socket(self, family, type, sock)) { mp_raise_RuntimeError(translate("Out of sockets")); } mark_user_socket(sock->num, sock); @@ -279,17 +291,16 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_ // We got a socket. New client socket will not be non-blocking by default, so make it non-blocking. lwip_fcntl(newsoc, F_SETFL, O_NONBLOCK); - if (!register_open_socket(newsoc)) { - lwip_close(newsoc); - return -MP_EBADF; - } - - if (accepted != NULL) { - // Close the active socket because we have another we accepted. - if (!common_hal_socketpool_socket_get_closed(accepted)) { - common_hal_socketpool_socket_close(accepted); + // Error if called with open socket object. + assert(common_hal_socketpool_socket_get_closed(accepted)); + + // Register if system socket + if (!register_open_socket(newsoc)) { + lwip_close(newsoc); + return -MP_EBADF; } + // Replace the old accepted socket with the new one. accepted->num = newsoc; accepted->pool = self->pool; @@ -353,12 +364,21 @@ void socketpool_socket_close(socketpool_socket_obj_t *self) { return; } self->connected = false; - if (self->num >= 0) { - lwip_shutdown(self->num, SHUT_RDWR); - lwip_close(self->num); - unregister_open_socket(self->num); - self->num = -1; + int fd = self->num; + // Ignore bogus/closed sockets + if (fd >= LWIP_SOCKET_OFFSET) { + if (user_socket[fd - LWIP_SOCKET_OFFSET] == NULL) { + socket_fd_state[fd - LWIP_SOCKET_OFFSET] = FDSTATE_CLOSING; + lwip_shutdown(fd, SHUT_RDWR); + lwip_close(fd); + } else { + lwip_shutdown(fd, SHUT_RDWR); + lwip_close(fd); + socket_fd_state[fd - LWIP_SOCKET_OFFSET] = FDSTATE_CLOSED; + user_socket[fd - LWIP_SOCKET_OFFSET] = NULL; + } } + self->num = -1; } void common_hal_socketpool_socket_close(socketpool_socket_obj_t *self) { @@ -420,7 +440,7 @@ bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t *self) { } bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t *self, int backlog) { - return lwip_listen(self->num, backlog); + return lwip_listen(self->num, backlog) == 0; } mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t *self, @@ -479,10 +499,9 @@ int socketpool_socket_recv_into(socketpool_socket_obj_t *self, } RUN_BACKGROUND_TASKS; received = lwip_recv(self->num, (void *)buf, len, 0); - // In non-blocking mode, fail instead of looping - if (received == -1 && self->timeout_ms == 0) { - if (errno == ENOTCONN) { + if (received < 1 && self->timeout_ms == 0) { + if ((received == 0) || (errno == ENOTCONN)) { self->connected = false; return -MP_ENOTCONN; } diff --git a/ports/espressif/common-hal/socketpool/Socket.h b/ports/espressif/common-hal/socketpool/Socket.h index 45e36e58ca..dfd1cbfc11 100644 --- a/ports/espressif/common-hal/socketpool/Socket.h +++ b/ports/espressif/common-hal/socketpool/Socket.h @@ -48,3 +48,5 @@ typedef struct { } socketpool_socket_obj_t; void socket_user_reset(void); +// Unblock workflow socket select thread (platform specific) +void socketpool_socket_poll_resume(void); diff --git a/ports/raspberrypi/common-hal/socketpool/Socket.h b/ports/raspberrypi/common-hal/socketpool/Socket.h index 6e26087674..c2306d201a 100644 --- a/ports/raspberrypi/common-hal/socketpool/Socket.h +++ b/ports/raspberrypi/common-hal/socketpool/Socket.h @@ -75,4 +75,7 @@ typedef struct _lwip_socket_obj_t { socketpool_socketpool_obj_t *pool; } socketpool_socket_obj_t; +// Not required for RPi socket positive callbacks +#define socketpool_socket_poll_resume(x) + void socket_user_reset(void); diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 75ab78bf03..468787269a 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -303,15 +303,12 @@ void supervisor_start_web_workflow(void) { return; } - mp_int_t new_port = web_api_port; // (leaves new_port unchanged on any failure) - (void)common_hal_os_getenv_int("CIRCUITPY_WEB_API_PORT", &new_port); + (void)common_hal_os_getenv_int("CIRCUITPY_WEB_API_PORT", &web_api_port); bool first_start = pool.base.type != &socketpool_socketpool_type; - bool port_changed = new_port != web_api_port; if (first_start) { - port_changed = false; pool.base.type = &socketpool_socketpool_type; common_hal_socketpool_socketpool_construct(&pool, &common_hal_wifi_radio_obj); @@ -320,6 +317,11 @@ void supervisor_start_web_workflow(void) { websocket_init(); } + + if (!common_hal_socketpool_socket_get_closed(&active)) { + common_hal_socketpool_socket_close(&active); + } + #if CIRCUITPY_MDNS // Try to start MDNS if the user deinited it. if (mdns.base.type != &mdns_server_type || @@ -330,24 +332,10 @@ void supervisor_start_web_workflow(void) { common_hal_mdns_server_set_instance_name(&mdns, MICROPY_HW_BOARD_NAME); } } + if (!common_hal_mdns_server_deinited(&mdns)) { + common_hal_mdns_server_advertise_service(&mdns, "_circuitpython", "_tcp", web_api_port); + } #endif - if (port_changed) { - common_hal_socketpool_socket_close(&listening); - } - if (first_start || port_changed) { - web_api_port = new_port; - #if CIRCUITPY_MDNS - if (!common_hal_mdns_server_deinited(&mdns)) { - common_hal_mdns_server_advertise_service(&mdns, "_circuitpython", "_tcp", web_api_port); - } - #endif - socketpool_socket(&pool, SOCKETPOOL_AF_INET, SOCKETPOOL_SOCK_STREAM, &listening); - common_hal_socketpool_socket_settimeout(&listening, 0); - // Bind to any ip. - common_hal_socketpool_socket_bind(&listening, "", 0, web_api_port); - common_hal_socketpool_socket_listen(&listening, 1); - } - const size_t api_password_len = sizeof(_api_password) - 1; result = common_hal_os_getenv_str("CIRCUITPY_WEB_API_PASSWORD", _api_password + 1, api_password_len); @@ -355,6 +343,16 @@ void supervisor_start_web_workflow(void) { _api_password[0] = ':'; _base64_in_place(_api_password, strlen(_api_password), sizeof(_api_password) - 1); } + + if (common_hal_socketpool_socket_get_closed(&listening)) { + socketpool_socket(&pool, SOCKETPOOL_AF_INET, SOCKETPOOL_SOCK_STREAM, &listening); + common_hal_socketpool_socket_settimeout(&listening, 0); + // Bind to any ip. (Not checking for failures) + common_hal_socketpool_socket_bind(&listening, "", 0, web_api_port); + common_hal_socketpool_socket_listen(&listening, 1); + } + // Wake polling thread (maybe) + socketpool_socket_poll_resume(); #endif } @@ -513,7 +511,7 @@ static void _cors_header(socketpool_socket_obj_t *socket, _request *request) { _send_strs(socket, "Access-Control-Allow-Credentials: true\r\n", "Vary: Origin, Accept, Upgrade\r\n", - "Access-Control-Allow-Origin: ", request->origin, "\r\n", + "Access-Control-Allow-Origin: *\r\n", NULL); } @@ -1080,6 +1078,10 @@ static bool _reply(socketpool_socket_obj_t *socket, _request *request) { #else _reply_missing(socket, request); #endif + +// For now until CORS is sorted, allow always the origin requester. +// Note: caller knows who we are better than us. CORS is not security +// unless browser cooperates. Do not rely on mDNS or IP. } else if (strlen(request->origin) > 0 && !_origin_ok(request->origin)) { _reply_forbidden(socket, request); } else if (strncmp(request->path, "/fs/", 4) == 0) { @@ -1323,9 +1325,14 @@ static void _process_request(socketpool_socket_obj_t *socket, _request *request) uint8_t c; // This code assumes header lines are terminated with \r\n while (more && !error) { + int len = socketpool_socket_recv_into(socket, &c, 1); if (len != 1) { more = false; + if (len == 0 || len == -MP_ENOTCONN) { + // Disconnect - clear 'in-progress' + _reset_request(request); + } break; } if (!request->in_progress) { @@ -1452,6 +1459,7 @@ static void _process_request(socketpool_socket_obj_t *socket, _request *request) } bool reload = _reply(socket, request); _reset_request(request); + common_hal_socketpool_socket_close(socket); autoreload_resume(AUTORELOAD_SUSPEND_WEB); if (reload) { autoreload_trigger(); @@ -1459,45 +1467,52 @@ static void _process_request(socketpool_socket_obj_t *socket, _request *request) } -void supervisor_web_workflow_background(void) { - // Track if we have more to do. For example, we should start processing a - // request immediately after we accept the socket. - bool more_to_do = true; - while (more_to_do) { - more_to_do = false; +void supervisor_web_workflow_background(void *data) { + while (true) { // If we have a request in progress, continue working on it. Do this first // so that we can accept another socket after finishing this request. if (common_hal_socketpool_socket_get_connected(&active)) { _process_request(&active, &active_request); + if (active_request.in_progress) { + break; + } } else { - // Close the active socket if it is no longer connected. - common_hal_socketpool_socket_close(&active); + // Close the active socket if necessary + if (!common_hal_socketpool_socket_get_closed(&active)) { + common_hal_socketpool_socket_close(&active); + } } - // Otherwise, see if we have another socket to accept. if ((!common_hal_socketpool_socket_get_connected(&active) || (!active_request.in_progress && !active_request.new_socket)) && !common_hal_socketpool_socket_get_closed(&listening)) { uint32_t ip; uint32_t port; + if (!common_hal_socketpool_socket_get_closed(&active)) { + common_hal_socketpool_socket_close(&active); + } int newsoc = socketpool_socket_accept(&listening, (uint8_t *)&ip, &port, &active); if (newsoc == -EBADF) { common_hal_socketpool_socket_close(&listening); - return; + break; } if (newsoc > 0) { common_hal_socketpool_socket_settimeout(&active, 0); - _reset_request(&active_request); // Mark new sockets, otherwise we may accept another before the first // could start its request. active_request.new_socket = true; - more_to_do = true; + continue; } + break; } - websocket_background(); + break; } + // Resume polling + socketpool_socket_poll_resume(); + + return; } void supervisor_stop_web_workflow(void) { diff --git a/supervisor/shared/web_workflow/web_workflow.h b/supervisor/shared/web_workflow/web_workflow.h index a76490aba2..85205b04d6 100644 --- a/supervisor/shared/web_workflow/web_workflow.h +++ b/supervisor/shared/web_workflow/web_workflow.h @@ -33,7 +33,7 @@ // This background function should be called repeatedly. It cannot be done based // on events. -void supervisor_web_workflow_background(void); +void supervisor_web_workflow_background(void *data); bool supervisor_web_workflow_status_dirty(void); void supervisor_web_workflow_status(void); void supervisor_start_web_workflow(void); diff --git a/supervisor/shared/web_workflow/websocket.c b/supervisor/shared/web_workflow/websocket.c index e55e09b3e7..0b829bb6f8 100644 --- a/supervisor/shared/web_workflow/websocket.c +++ b/supervisor/shared/web_workflow/websocket.c @@ -42,7 +42,6 @@ typedef struct { uint8_t frame_len; uint8_t payload_len_size; bool masked; - bool closed; uint8_t mask[4]; int frame_index; size_t payload_remaining; @@ -59,17 +58,16 @@ static _websocket cp_serial; void websocket_init(void) { socketpool_socket_reset(&cp_serial.socket); - cp_serial.closed = true; ringbuf_init(&_incoming_ringbuf, _buf, sizeof(_buf) - 1); } void websocket_handoff(socketpool_socket_obj_t *socket) { - if (!cp_serial.closed) { + if (!common_hal_socketpool_socket_get_closed(&cp_serial.socket)) { common_hal_socketpool_socket_close(&cp_serial.socket); } + socketpool_socket_move(socket, &cp_serial.socket); - cp_serial.closed = false; cp_serial.opcode = 0; cp_serial.frame_index = 0; cp_serial.frame_len = 2; @@ -81,12 +79,14 @@ void websocket_handoff(socketpool_socket_obj_t *socket) { } bool websocket_connected(void) { - return _incoming_ringbuf.size > 0 && !cp_serial.closed && common_hal_socketpool_socket_get_connected(&cp_serial.socket); + return _incoming_ringbuf.size > 0 && + !common_hal_socketpool_socket_get_closed(&cp_serial.socket) && + common_hal_socketpool_socket_get_connected(&cp_serial.socket); } static bool _read_byte(uint8_t *c) { int len = socketpool_socket_recv_into(&cp_serial.socket, c, 1); - if (len != 1) { + if (len < 1) { return false; } return true; @@ -160,8 +160,6 @@ static void _read_next_frame_header(void) { if (cp_serial.payload_remaining == 0) { cp_serial.frame_index = 0; if (cp_serial.opcode == 0x8) { - cp_serial.closed = true; - common_hal_socketpool_socket_close(&cp_serial.socket); } } diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c index f3bc99cb5e..64f1021df2 100644 --- a/supervisor/shared/workflow.c +++ b/supervisor/shared/workflow.c @@ -46,15 +46,7 @@ #if CIRCUITPY_WEB_WORKFLOW #include "supervisor/shared/web_workflow/web_workflow.h" #endif -static background_callback_t workflow_background_cb; - -static bool workflow_started = false; - -static void workflow_background(void *data) { - #if CIRCUITPY_WEB_WORKFLOW - supervisor_web_workflow_background(); - #endif -} +static background_callback_t workflow_background_cb = {NULL, NULL}; // Called during a VM reset. Doesn't actually reset things. void supervisor_workflow_reset(void) { @@ -63,31 +55,18 @@ void supervisor_workflow_reset(void) { #endif #if CIRCUITPY_WEB_WORKFLOW - supervisor_start_web_workflow(); + if (workflow_background_cb.fun) { + supervisor_start_web_workflow(); + supervisor_workflow_request_background(); + } #endif - - workflow_background_cb.fun = workflow_background; - workflow_background_cb.data = NULL; - supervisor_workflow_request_background(); } void supervisor_workflow_request_background(void) { - if (!workflow_started) { - return; + if (workflow_background_cb.fun) { + workflow_background_cb.data = NULL; + background_callback_add_core(&workflow_background_cb); } - background_callback_add_core(&workflow_background_cb); -} - -// Return true as soon as USB communication with host has started, -// even before enumeration is done. -// Not that some chips don't notice when USB is unplugged after first being plugged in, -// so this is not perfect, but tud_suspended() check helps. -bool supervisor_workflow_connecting(void) { - #if CIRCUITPY_USB - return tud_connected() && !tud_suspended(); - #else - return false; - #endif } // Return true if host has completed connection to us (such as USB enumeration). @@ -120,9 +99,10 @@ void supervisor_workflow_start(void) { #if CIRCUITPY_WEB_WORKFLOW supervisor_start_web_workflow(); + memset(&workflow_background_cb, 0, sizeof(workflow_background_cb)); + workflow_background_cb.fun = supervisor_web_workflow_background; #endif - workflow_started = true; } FRESULT supervisor_workflow_mkdir_parents(FATFS *fs, char *path) { From f2e26e8bde8790d98e1b9a42c2ac9444237f74bc Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 13:12:13 -0500 Subject: [PATCH 208/225] get the cmsis macros the right way --- shared-module/audiomixer/Mixer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index ce39f88919..397a837133 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -33,10 +33,9 @@ #include "py/runtime.h" #include "shared-module/audiocore/__init__.h" -#include "shared-module/audiocore/RawSample.h" -#if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) -#include "periph.h" +#if defined(__arm__) && __arm__ +#include "cmsis_compiler.h" #endif void common_hal_audiomixer_mixer_construct(audiomixer_mixer_obj_t *self, From 2ca4875ce599a0b016b6a715bc158ef4e7580788 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 5 Apr 2023 21:23:19 +0200 Subject: [PATCH 209/225] 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 | 4 ++++ locale/cs.po | 4 ++++ locale/de_DE.po | 4 ++++ locale/el.po | 4 ++++ locale/en_GB.po | 4 ++++ locale/es.po | 4 ++++ locale/fil.po | 4 ++++ locale/fr.po | 4 ++++ locale/hi.po | 4 ++++ locale/it_IT.po | 4 ++++ locale/ja.po | 4 ++++ locale/ko.po | 4 ++++ locale/nl.po | 4 ++++ locale/pl.po | 4 ++++ locale/pt_BR.po | 4 ++++ locale/ru.po | 4 ++++ locale/sv.po | 4 ++++ locale/tr.po | 4 ++++ locale/zh_Latn_pinyin.po | 4 ++++ 19 files changed, 76 insertions(+) diff --git a/locale/ID.po b/locale/ID.po index 99ed347bf5..7163efb5df 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -196,6 +196,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/cs.po b/locale/cs.po index 9f2917d396..0e6b8714af 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -197,6 +197,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/de_DE.po b/locale/de_DE.po index 30b1c8a6c7..6b68831288 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -206,6 +206,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "%q muss ein Array vom Typ 'H' sein" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/el.po b/locale/el.po index 69d62af435..c1d8350462 100644 --- a/locale/el.po +++ b/locale/el.po @@ -201,6 +201,10 @@ msgstr "%q πρέπει να είναι bytearray ή array τύπου 'h', 'H', msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/en_GB.po b/locale/en_GB.po index 0f6abecec5..8f45f3617a 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -200,6 +200,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/es.po b/locale/es.po index 3dd68ca430..0123657e35 100644 --- a/locale/es.po +++ b/locale/es.po @@ -208,6 +208,10 @@ msgstr "%q debe ser un byte-matriz o matriz de tipo 'h', 'H', 'b', o 'B'" msgid "%q must be array of type 'H'" msgstr "%q debe ser un arreglo de tipo 'H'" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/fil.po b/locale/fil.po index 7540377953..2a9127c34c 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -194,6 +194,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/fr.po b/locale/fr.po index 3076df8d16..a281712f96 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -205,6 +205,10 @@ msgstr "%q doit être a bytearray ou array de type 'h', 'H', 'b', ou 'B'" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/hi.po b/locale/hi.po index b0ede40028..1f60a526cd 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -193,6 +193,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/it_IT.po b/locale/it_IT.po index f8037c8954..57a9a3b91f 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -197,6 +197,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/ja.po b/locale/ja.po index 8931beb108..fbe0d8c902 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -200,6 +200,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/ko.po b/locale/ko.po index 34d4ffcb5d..339cb42c86 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -194,6 +194,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/nl.po b/locale/nl.po index 3232cc6f14..a91063c256 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -193,6 +193,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/pl.po b/locale/pl.po index e1bed87c6c..fbd76182cc 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -195,6 +195,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 85ca810b98..58b7424deb 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -206,6 +206,10 @@ msgstr "%q deve ser um bytearray ou uma matriz do tipo 'h', 'H', 'b', ou 'B'" msgid "%q must be array of type 'H'" msgstr "%q deve ser uma matriz do tipo 'H'" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/ru.po b/locale/ru.po index 4d40fe946e..8fe6419b11 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -200,6 +200,10 @@ msgstr "%q должно быть bytearray или array типа 'h', 'H', 'b', msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/sv.po b/locale/sv.po index 8d3bed02f4..dc806e269e 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -207,6 +207,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "%q måste vara en array av typen 'H'" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/tr.po b/locale/tr.po index 5f3882ca9e..1f8874167b 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -201,6 +201,10 @@ msgstr "%q 'h', 'H', 'b' ya da 'B' tipi bir bytearray ya da array olmalı" msgid "%q must be array of type 'H'" msgstr "" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index d149942d6a..37d8016fc7 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -209,6 +209,10 @@ msgstr "" msgid "%q must be array of type 'H'" msgstr "%q bì xū shì lèi xíng wéi 'H' de shù zǔ" +#: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c +msgid "%q must be array of type 'h'" +msgstr "" + #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or %q, not %q" From 09bc8fbdc07e253602e6b04ff972a2350919476b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 13:02:08 -0500 Subject: [PATCH 210/225] add more test vectors for aes --- tests/circuitpython/aes.py | 44 ++++++++++++++++++++++++++++++++++ tests/circuitpython/aes.py.exp | 14 +++++++++++ 2 files changed, 58 insertions(+) diff --git a/tests/circuitpython/aes.py b/tests/circuitpython/aes.py index 40adc020c6..b47c4279d3 100644 --- a/tests/circuitpython/aes.py +++ b/tests/circuitpython/aes.py @@ -97,3 +97,47 @@ for i in range(0, len(plaintext), 16): cipher.decrypt_into(cyphertext[i : i + 16], output) print(str(hexlify(output), "")) print() + +print("truncated-CTR-1") +## Truncated CTR test case +plaintext = unhexlify("6bc1bee22e409f96e93d7e117393172a" "ae2d") + +key = unhexlify("2b7e151628aed2a6abf7158809cf4f3c") +counter = unhexlify("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff") +cyphertext = bytearray(len(plaintext)) +cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter) +for i in range(0, len(plaintext), 16): + output = memoryview(cyphertext)[i : i + 16] + cipher.encrypt_into(plaintext[i : i + 16], output) + print(str(hexlify(output), "")) +print() + +plaintext = bytearray(len(plaintext)) +cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter) +for i in range(0, len(plaintext), 16): + output = memoryview(plaintext)[i : i + 16] + cipher.decrypt_into(cyphertext[i : i + 16], output) + print(str(hexlify(output), "")) +print() + +print("truncated-CTR-2") +## Truncated CTR test case #2 +plaintext = unhexlify("6bc1bee22e409f96e93d7e117393172a" "ae") + +key = unhexlify("2b7e151628aed2a6abf7158809cf4f3c") +counter = unhexlify("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff") +cyphertext = bytearray(len(plaintext)) +cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter) +cipher.encrypt_into(plaintext, cyphertext) +for i in range(0, len(plaintext), 16): + output = memoryview(cyphertext)[i : i + 16] + print(str(hexlify(output), "")) +print() + +plaintext = bytearray(len(plaintext)) +cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter) +cipher.decrypt_into(cyphertext, plaintext) +for i in range(0, len(plaintext), 16): + output = memoryview(plaintext)[i : i + 16] + print(str(hexlify(output), "")) +print() diff --git a/tests/circuitpython/aes.py.exp b/tests/circuitpython/aes.py.exp index da0f8c29b1..17a2bfe12a 100644 --- a/tests/circuitpython/aes.py.exp +++ b/tests/circuitpython/aes.py.exp @@ -34,3 +34,17 @@ ae2d8a571e03ac9c9eb76fac45af8e51 30c81c46a35ce411e5fbc1191a0a52ef f69f2445df4f9b17ad2b417be66c3710 +truncated-CTR-1 +874d6191b620e3261bef6864990db6ce +9806 + +6bc1bee22e409f96e93d7e117393172a +ae2d + +truncated-CTR-2 +874d6191b620e3261bef6864990db6ce +98 + +6bc1bee22e409f96e93d7e117393172a +ae + From 9993b4b01c9448236546f1908ade6b39e04e80cc Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 16:20:27 -0500 Subject: [PATCH 211/225] Prevent playing the same note on 2 channels --- shared-module/synthio/__init__.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shared-module/synthio/__init__.c b/shared-module/synthio/__init__.c index 7ac8e47746..e41869a113 100644 --- a/shared-module/synthio/__init__.c +++ b/shared-module/synthio/__init__.c @@ -160,6 +160,9 @@ STATIC int find_channel_with_note(const synthio_midi_span_t *span, uint8_t note) } bool synthio_span_change_note(synthio_midi_span_t *span, uint8_t old_note, uint8_t new_note) { + if (new_note != SYNTHIO_SILENCE && find_channel_with_note(span, new_note) != -1) { + return false; // note already pressed, do nothing + } int channel = find_channel_with_note(span, old_note); if (channel != -1) { span->note[channel] = new_note; From 992457c7f75adc0185d9733810c46adb9c5897ad Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 16:20:35 -0500 Subject: [PATCH 212/225] Improve documentation --- shared-bindings/synthio/Synthesizer.c | 45 ++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/shared-bindings/synthio/Synthesizer.c b/shared-bindings/synthio/Synthesizer.c index 2ad5cbcd42..56ad0d76cd 100644 --- a/shared-bindings/synthio/Synthesizer.c +++ b/shared-bindings/synthio/Synthesizer.c @@ -36,9 +36,20 @@ #include "shared-bindings/synthio/__init__.h" #include "supervisor/shared/translate/translate.h" -//| class Synth: +//| class Synthesizer: //| def __init__(self, *, sample_rate: int = 11025, waveform: ReadableBuffer = None) -> None: -//| """Create a synthesizer object.""" +//| """Create a synthesizer object. +//| +//| This API is experimental. +//| +//| At least 2 simultaneous notes are supported. mimxrt10xx and rp2040 platforms support up to +//| 12 notes. +//| +//| Notes use MIDI note numbering, with 60 being C4 or Middle C, approximately 262Hz. +//| +//| :param int sample_rate: The desired playback sample rate; higher sample rate requires more memory +//| :param ReadableBuffer waveform: A single-cycle waveform. Default is a 50% duty cycle square wave. If specified, must be a ReadableBuffer of type 'h' (signed 16 bit). It is permitted to modify this buffer during synthesis. This can be used, for instance, to control the overall volume or timbre of the notes. +//| """ STATIC mp_obj_t synthio_synthesizer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_sample_rate, ARG_waveform }; static const mp_arg_t allowed_args[] = { @@ -69,7 +80,11 @@ STATIC void check_for_deinit(synthio_synthesizer_obj_t *self) { } //| def press(self, /, press: Sequence[int] = ()) -> None: -//| """Turn some notes on. Notes use MIDI numbering, with 60 being middle C.""" +//| """Turn some notes on. Notes use MIDI numbering, with 60 being middle C, approximately 262Hz. +//| +//| Pressing a note that was already pressed has no effect. +//| +//| :param Sequence[int] press: Any sequence of integer notes.""" STATIC mp_obj_t synthio_synthesizer_press(mp_obj_t self_in, mp_obj_t press) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -81,7 +96,17 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(synthio_synthesizer_press_obj, synthio_synthesi //| def release_then_press( //| self, release: Sequence[int] = (), press: Sequence[int] = () //| ) -> None: -//| """Turn some notes on and/or off. Notes use MIDI numbering, with 60 being middle C.""" +//| """Turn some notes on and/or off. Notes use MIDI numbering, with 60 being middle C. +//| +//| It is OK to release note that was not actually turned on. +//| +//| Pressing a note that was already pressed has no effect. +//| +//| Releasing and pressing the note again has little effect, but does reset the phase +//| of the note, which may be perceptible as a small glitch. +//| +//| :param Sequence[int] release: Any sequence of integer notes. +//| :param Sequence[int] press: Any sequence of integer notes.""" STATIC mp_obj_t synthio_synthesizer_release_then_press(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_release, ARG_press }; static const mp_arg_t allowed_args[] = { @@ -102,7 +127,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(synthio_synthesizer_release_then_press_obj, 1, // //| def release_all_then_press(self, /, press: Sequence[int]) -> None: -//| """Turn any currently-playing notes off, then turn on the given notes""" +//| """Turn any currently-playing notes off, then turn on the given notes +//| +//| Releasing and pressing the note again has little effect, but does reset the phase +//| of the note, which may be perceptible as a small glitch. +//| +//| :param Sequence[int] press: Any sequence of integer notes.""" STATIC mp_obj_t synthio_synthesizer_release_all_then_press(mp_obj_t self_in, mp_obj_t press) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -173,6 +203,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(synthio_synthesizer_get_pressed_obj, synthio_synthesiz MP_PROPERTY_GETTER(synthio_synthesizer_pressed_obj, (mp_obj_t)&synthio_synthesizer_get_pressed_obj); +//| max_polyphony: int +//| """Maximum polyphony of the synthesizer (read-only class property)""" +//| + STATIC const mp_rom_map_elem_t synthio_synthesizer_locals_dict_table[] = { // Methods { MP_ROM_QSTR(MP_QSTR_press), MP_ROM_PTR(&synthio_synthesizer_press_obj) }, @@ -185,6 +219,7 @@ STATIC const mp_rom_map_elem_t synthio_synthesizer_locals_dict_table[] = { // Properties { MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&synthio_synthesizer_sample_rate_obj) }, + { MP_ROM_QSTR(MP_QSTR_max_polyphony), MP_ROM_INT(CIRCUITPY_SYNTHIO_MAX_CHANNELS) }, { MP_ROM_QSTR(MP_QSTR_pressed), MP_ROM_PTR(&synthio_synthesizer_pressed_obj) }, }; STATIC MP_DEFINE_CONST_DICT(synthio_synthesizer_locals_dict, synthio_synthesizer_locals_dict_table); From 79d093d957a34395f97676dd6115d12322a2bb66 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Apr 2023 17:43:03 -0500 Subject: [PATCH 213/225] tweak max envelope calculation vs number of active notes --- shared-module/synthio/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/synthio/__init__.c b/shared-module/synthio/__init__.c index e41869a113..11e4c1dcc9 100644 --- a/shared-module/synthio/__init__.c +++ b/shared-module/synthio/__init__.c @@ -66,7 +66,7 @@ void synthio_synth_synthesize(synthio_synth_t *synth, uint8_t **bufptr, uint32_t const int16_t *waveform = synth->waveform; uint32_t waveform_length = synth->waveform_length; if (active_channels) { - int16_t loudness = 0x3fff / (1 + active_channels); + int16_t loudness = 0xffff / (1 + 2 * active_channels); for (int chan = 0; chan < CIRCUITPY_SYNTHIO_MAX_CHANNELS; chan++) { if (synth->span.note[chan] == SYNTHIO_SILENCE) { synth->accum[chan] = 0; From 046397aaff26025df0c34137c1ccd0217340fcf2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 6 Apr 2023 08:54:49 -0500 Subject: [PATCH 214/225] sort block of settings --- ports/atmel-samd/mpconfigport.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index d4d1ff31a3..ed734ce679 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -100,11 +100,11 @@ endif CIRCUITPY_ALARM ?= 1 -CIRCUITPY_PS2IO ?= 1 -CIRCUITPY_SAMD ?= 1 CIRCUITPY_FLOPPYIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_PS2IO ?= 1 CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) +CIRCUITPY_SAMD ?= 1 CIRCUITPY_WATCHDOG ?= 1 endif # samd51 From 081e9b995e89262e9760997eeb78e90b754e1a84 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 6 Apr 2023 08:55:00 -0500 Subject: [PATCH 215/225] samd51 can also handle 12 voices @ 24kHz! --- ports/atmel-samd/mpconfigport.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index ed734ce679..032e49ce36 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -105,6 +105,7 @@ CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_PS2IO ?= 1 CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) CIRCUITPY_SAMD ?= 1 +CIRCUITPY_SYNTHIO_MAX_CHANNELS = 12 CIRCUITPY_WATCHDOG ?= 1 endif # samd51 From 8c8ca3b8100b3687c345549ab177528330e2b983 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 6 Apr 2023 10:21:27 -0500 Subject: [PATCH 216/225] endorse new test outputs --- tests/circuitpython/miditrack.py.exp | 4 ++-- tests/circuitpython/synthesizer.py.exp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/circuitpython/miditrack.py.exp b/tests/circuitpython/miditrack.py.exp index be5eef1d0b..bfb082bfe7 100644 --- a/tests/circuitpython/miditrack.py.exp +++ b/tests/circuitpython/miditrack.py.exp @@ -1,4 +1,4 @@ (0, 1, 512, 1) -(1, b'\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\xff\x0f\xff\x0f') +(1, b'V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\xaa*\xaa*') (0, 1, 512, 1) -(1, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x01\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\xff\x0f\x00\x00\x00\x00') +(1, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00V\xd5V\xd5V\xd5V\xd5V\xd5V\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa*\xaa*\xaa*\xaa*\xaa*\xaa*\x00\x00\x00\x00') diff --git a/tests/circuitpython/synthesizer.py.exp b/tests/circuitpython/synthesizer.py.exp index 4296662d60..79c88b3248 100644 --- a/tests/circuitpython/synthesizer.py.exp +++ b/tests/circuitpython/synthesizer.py.exp @@ -1,8 +1,8 @@ () (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) (80,) -(-4095, -4095, -4095, -4095, 4095, 4095, 4095, 4095, 4095, -4095, -4095, -4095) +(-10922, -10922, -10922, -10922, 10922, 10922, 10922, 10922, 10922, -10922, -10922, -10922) (80, 91) -(0, 0, 5460, 5460, 0, -5460, -5460, 0, 5460, 5460, 0, 0) +(0, 0, 13106, 13106, 0, -13106, -13106, 0, 13106, 13106, 0, 0) (91,) -(-4095, 4095, 4095, 4095, -4095, -4095, 4095, 4095, 4095, -4095, -4095, 4095) +(-10922, 10922, 10922, 10922, -10922, -10922, 10922, 10922, 10922, -10922, -10922, 10922) From ebf3d20b28c28a48d1572b9c04106e6b6c8c598d Mon Sep 17 00:00:00 2001 From: Jose David M Date: Wed, 5 Apr 2023 19:44:31 +0000 Subject: [PATCH 217/225] Translated using Weblate (Spanish) Currently translated at 100.0% (1000 of 1000 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/es.po b/locale/es.po index 0123657e35..3ebfdc7833 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-03-31 14:39+0000\n" +"PO-Revision-Date: 2023-04-07 00:49+0000\n" "Last-Translator: Jose David M \n" "Language-Team: \n" "Language: es\n" @@ -210,7 +210,7 @@ msgstr "%q debe ser un arreglo de tipo 'H'" #: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c msgid "%q must be array of type 'h'" -msgstr "" +msgstr "%q debe ser una matriz de tipo 'h'" #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c From 8c64d42cefbdfd8b0699a4834116487f3fbef5e6 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Thu, 6 Apr 2023 00:21:26 +0000 Subject: [PATCH 218/225] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1000 of 1000 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 58b7424deb..d130fcc464 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: 2023-03-31 14:39+0000\n" +"PO-Revision-Date: 2023-04-07 00:49+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -208,7 +208,7 @@ msgstr "%q deve ser uma matriz do tipo 'H'" #: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c msgid "%q must be array of type 'h'" -msgstr "" +msgstr "%q deve ser uma matriz do tipo 'h'" #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c From b16b9102f66293c48bb8b6692549a5f19929f0c3 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Wed, 5 Apr 2023 19:38:42 +0000 Subject: [PATCH 219/225] Translated using Weblate (Swedish) Currently translated at 100.0% (1000 of 1000 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index dc806e269e..8cb79da28e 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: 2023-03-31 14:39+0000\n" +"PO-Revision-Date: 2023-04-07 00:49+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -209,7 +209,7 @@ msgstr "%q måste vara en array av typen 'H'" #: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c msgid "%q must be array of type 'h'" -msgstr "" +msgstr "%q måste vara en matris av typen 'h'" #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c From af35337136177d26ddd6c3f7120fdb73b8fc4b19 Mon Sep 17 00:00:00 2001 From: John Sanders Date: Wed, 5 Apr 2023 06:00:02 -0700 Subject: [PATCH 220/225] Add Waveshare RP2040-LCD-0.96 --- .../boards/waveshare_rp2040_lcd_0_96/board.c | 129 ++++++++++++++++++ .../waveshare_rp2040_lcd_0_96/mpconfigboard.h | 11 ++ .../mpconfigboard.mk | 11 ++ .../pico-sdk-configboard.h | 1 + .../boards/waveshare_rp2040_lcd_0_96/pins.c | 57 ++++++++ 5 files changed, 209 insertions(+) create mode 100644 ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c create mode 100644 ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pins.c diff --git a/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c new file mode 100644 index 0000000000..afe3f87787 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c @@ -0,0 +1,129 @@ +/* + * 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" +#include "mpconfigboard.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" + +#define DELAY 0x80 + + +// display init sequence according to Adafruit_CircuitPython_ST7735R +// https://github.com/adafruit/Adafruit_CircuitPython_ST7735R +uint8_t display_init_sequence[] = { + // sw reset + 0x01, 0 | DELAY, 0x96, + // SLPOUT and Delay + 0x11, 0 | DELAY, 0xFF, + 0xB1, 0x03, 0x01, 0x2C, 0x2D, // _FRMCTR1 + 0xB3, 0x06, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D, // _FRMCTR3 + 0xB4, 0x01, 0x07, // _INVCTR line inversion + 0xC0, 0x03, 0xA2, 0x02, 0x84, // _PWCTR1 GVDD = 4.7V, 1.0uA + 0xC1, 0x01, 0xC5, // _PWCTR2 VGH=14.7V, VGL=-7.35V + 0xC2, 0x02, 0x0A, 0x00, // _PWCTR3 Opamp current small, Boost frequency + 0xC3, 0x02, 0x8A, 0x2A, + 0xC4, 0x02, 0x8A, 0xEE, + 0xC5, 0x01, 0x0E, // _VMCTR1 VCOMH = 4V, VOML = -1.1V + 0x20, 0x00, // _INVOFF + 0x36, 0x01, 0x18, // _MADCTL bottom to top refresh + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie, + // fix on VTL + 0x3A, 0x01, 0x05, // COLMOD - 16bit color + 0xE0, 0x10, 0x02, 0x1C, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2D, 0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10, // _GMCTRP1 Gamma + 0xE1, 0x10, 0x03, 0x1D, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D, 0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10, // _GMCTRN1 + 0x13, 0 | DELAY, 0x0A, // _NORON + 0x29, 0 | DELAY, 0x64, // _DISPON + // 0x36, 0x01, 0xC0, // _MADCTL Default rotation plus BGR encoding + 0x36, 0x01, 0xC8, // _MADCTL Default rotation plus RGB encoding + 0x21, 0x00, // _INVON +}; + +static void display_init(void) { + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct( + spi, + &pin_GPIO10, // CLK + &pin_GPIO11, // MOSI + NULL, // MISO not connected + false // Not half-duplex + ); + + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + + common_hal_displayio_fourwire_construct( + bus, + spi, + &pin_GPIO8, // DC + &pin_GPIO9, // CS + &pin_GPIO12, // RST + 40000000, // baudrate + 0, // polarity + 0 // phase + ); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct( + display, + bus, + 160, // width (after rotation) + 80, // height (after rotation) + 26, // column start + 1, // row start + 90, // rotation + 16, // color depth + false, // grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command + MIPI_COMMAND_WRITE_MEMORY_START, // write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO25, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false, // SH1107_addressing + 50000 // backlight pwm frequency + ); +} + +void board_init(void) { + // Display + display_init(); +} +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.h b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.h new file mode 100644 index 0000000000..1602656f90 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.h @@ -0,0 +1,11 @@ +#define MICROPY_HW_BOARD_NAME "Waveshare RP2040-LCD-0.96" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO21, .sda = &pin_GPIO20}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO18, .mosi = &pin_GPIO19, .miso = &pin_GPIO16}} + +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO0, .rx = &pin_GPIO1}} diff --git a/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.mk b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.mk new file mode 100644 index 0000000000..f441957314 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x1021 +USB_PRODUCT = "Waveshare RP2040-LCD-0.96" +USB_MANUFACTURER = "Waveshare Electronics" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pico-sdk-configboard.h b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pico-sdk-configboard.h new file mode 100644 index 0000000000..36da55d457 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pico-sdk-configboard.h @@ -0,0 +1 @@ +// Put board-specific pico-sdk definitions here. This file must exist. diff --git a/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pins.c b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pins.c new file mode 100644 index 0000000000..32fa4c4073 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/pins.c @@ -0,0 +1,57 @@ +#include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { 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_GP25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + + // ADC + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + + // 0.96 inch LCD ST7735s + { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_LCD_DIN), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_LCD_BL), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, + + // Power pins + { MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 097af804cd52152d23af71fab621ec8f27bc6889 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 7 Apr 2023 09:49:51 -0700 Subject: [PATCH 221/225] Fix ticks In #7497 port_background_task was renamed to port_background_tick but the actual call site wasn't changed. This meant that it was no longer called! Rename more functions from task to tick to make it clearer which is which. --- ports/atmel-samd/background.c | 8 ++++---- ports/broadcom/background.c | 4 ++-- ports/cxd56/background.c | 4 ++-- ports/espressif/background.c | 4 ++-- ports/litex/background.c | 4 ++-- ports/mimxrt10xx/background.c | 4 ++-- ports/nrf/background.c | 4 ++-- ports/raspberrypi/background.c | 4 ++-- ports/stm/background.c | 4 ++-- py/circuitpy_mpconfig.h | 4 ++-- supervisor/background_callback.h | 11 +++++++++-- supervisor/port.h | 11 ++++++----- supervisor/shared/tick.c | 17 ++++++----------- supervisor/shared/tick.h | 9 +-------- 14 files changed, 44 insertions(+), 48 deletions(-) diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c index 6e1dc71d85..2f8357d07b 100644 --- a/ports/atmel-samd/background.c +++ b/ports/atmel-samd/background.c @@ -42,18 +42,18 @@ // PB03 is physical pin "SCL" on the Metro M4 express // so you can't use this code AND an i2c peripheral // at the same time unless you change this -void port_start_background_task(void) { +void port_start_background_tick(void) { REG_PORT_DIRSET1 = (1 << 3); REG_PORT_OUTSET1 = (1 << 3); } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { REG_PORT_OUTCLR1 = (1 << 3); } #else -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } #endif diff --git a/ports/broadcom/background.c b/ports/broadcom/background.c index 5d92f1b8bf..9074a80400 100644 --- a/ports/broadcom/background.c +++ b/ports/broadcom/background.c @@ -28,9 +28,9 @@ #include "py/runtime.h" #include "supervisor/port.h" -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } void port_background_tick(void) { diff --git a/ports/cxd56/background.c b/ports/cxd56/background.c index da172cf5d7..8425f8cfa2 100644 --- a/ports/cxd56/background.c +++ b/ports/cxd56/background.c @@ -34,7 +34,7 @@ void port_background_tick(void) { } void port_background_task(void) { } -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } diff --git a/ports/espressif/background.c b/ports/espressif/background.c index 3fac768f3f..f9069e98a4 100644 --- a/ports/espressif/background.c +++ b/ports/espressif/background.c @@ -51,8 +51,8 @@ void port_background_tick(void) { void port_background_task(void) { } -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } diff --git a/ports/litex/background.c b/ports/litex/background.c index 1329d5fd83..e641daf53b 100644 --- a/ports/litex/background.c +++ b/ports/litex/background.c @@ -34,7 +34,7 @@ void port_background_task(void) { } void port_background_tick(void) { } -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } diff --git a/ports/mimxrt10xx/background.c b/ports/mimxrt10xx/background.c index faa2bda3f8..04de4c1c1c 100644 --- a/ports/mimxrt10xx/background.c +++ b/ports/mimxrt10xx/background.c @@ -37,8 +37,8 @@ void PLACE_IN_ITCM(port_background_task)(void) { void port_background_tick(void) { } -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } diff --git a/ports/nrf/background.c b/ports/nrf/background.c index b8d4df6324..f2df4db0e0 100644 --- a/ports/nrf/background.c +++ b/ports/nrf/background.c @@ -44,10 +44,10 @@ #include "common-hal/audiopwmio/PWMAudioOut.h" #endif -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } void port_background_tick(void) { diff --git a/ports/raspberrypi/background.c b/ports/raspberrypi/background.c index 8e5e3fcd91..1024ff7b38 100644 --- a/ports/raspberrypi/background.c +++ b/ports/raspberrypi/background.c @@ -28,10 +28,10 @@ #include "py/runtime.h" #include "supervisor/port.h" -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } void port_background_tick(void) { diff --git a/ports/stm/background.c b/ports/stm/background.c index 68703a5233..7dc617f49f 100644 --- a/ports/stm/background.c +++ b/ports/stm/background.c @@ -37,7 +37,7 @@ void port_background_task(void) { } void port_background_tick(void) { } -void port_start_background_task(void) { +void port_start_background_tick(void) { } -void port_finish_background_task(void) { +void port_finish_background_tick(void) { } diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 5f140413bb..cc7886cb37 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -439,8 +439,8 @@ struct _supervisor_allocation_node; const char *readline_hist[8]; \ struct _supervisor_allocation_node *first_embedded_allocation; \ -void supervisor_run_background_tasks_if_tick(void); -#define RUN_BACKGROUND_TASKS (supervisor_run_background_tasks_if_tick()) +void background_callback_run_all(void); +#define RUN_BACKGROUND_TASKS (background_callback_run_all()) #define MICROPY_VM_HOOK_LOOP RUN_BACKGROUND_TASKS; #define MICROPY_VM_HOOK_RETURN RUN_BACKGROUND_TASKS; diff --git a/supervisor/background_callback.h b/supervisor/background_callback.h index 651ac020a6..36b0017f0c 100644 --- a/supervisor/background_callback.h +++ b/supervisor/background_callback.h @@ -37,8 +37,9 @@ * To schedule the work, use background_callback_add, with fun as the * function to call and data pointing to the object itself. * - * Next time run_background_tasks_if_tick is called, the callback will - * be run and removed from the linked list. + * Next time background_callback_run_all() is called, the callback will + * be run and removed from the linked list. Use `RUN_BACKGROUND_TASKS;` instead + * of calling background_callback_run_all() directly. * * Queueing a task that is already queued does nothing. Unconditionally * re-queueing it from its own background task will cause it to run during the @@ -46,6 +47,12 @@ * don't do that. * * background_callback_add can be called from interrupt context. + * + * If your work isn't triggered by an event, then it may be better implemented + * using ticks, which runs tasks every millisecond or so. Ticks are enabled with + * supervisor_enable_tick() and disabled with supervisor_disable_tick(). When + * enabled, a timer will schedule a callback to supervisor_background_tick(), + * which includes port_background_tick(), every millisecond. */ typedef void (*background_callback_fun)(void *data); typedef struct background_callback { diff --git a/supervisor/port.h b/supervisor/port.h index b50179e4de..7b48a3f13b 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -94,14 +94,15 @@ void port_idle_until_interrupt(void); void port_background_tick(void); // Execute port specific actions during background tasks. This is before the -// background callback system. +// background callback system and happens *very* often. Use +// port_background_tick() when possible. void port_background_task(void); -// Take port specific actions at the beginning and end of background tasks. +// Take port specific actions at the beginning and end of background ticks. // This is used e.g., to set a monitoring pin for debug purposes. "Actual -// work" should be done in port_background_task() instead. -void port_start_background_task(void); -void port_finish_background_task(void); +// work" should be done in port_background_tick() instead. +void port_start_background_tick(void); +void port_finish_background_tick(void); // Some ports need special handling to wake the main task from another task. The // port must implement the necessary code in this function. A default weak diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 429ca35d60..b91257c8c8 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -65,8 +65,8 @@ static volatile uint64_t last_finished_tick = 0; static volatile size_t tick_enable_count = 0; -static void supervisor_background_tasks(void *unused) { - port_start_background_task(); +static void supervisor_background_tick(void *unused) { + port_start_background_tick(); assert_heap_ok(); @@ -80,16 +80,16 @@ static void supervisor_background_tasks(void *unused) { filesystem_background(); - port_background_task(); + port_background_tick(); assert_heap_ok(); last_finished_tick = port_get_raw_ticks(NULL); - port_finish_background_task(); + port_finish_background_tick(); } -bool supervisor_background_tasks_ok(void) { +bool supervisor_background_ticks_ok(void) { return port_get_raw_ticks(NULL) - last_finished_tick < 1024; } @@ -103,7 +103,7 @@ void supervisor_tick(void) { keypad_tick(); #endif - background_callback_add(&tick_callback, supervisor_background_tasks, NULL); + background_callback_add(&tick_callback, supervisor_background_tick, NULL); } uint64_t supervisor_ticks_ms64() { @@ -117,11 +117,6 @@ uint32_t supervisor_ticks_ms32() { return supervisor_ticks_ms64(); } - -void PLACE_IN_ITCM(supervisor_run_background_tasks_if_tick)() { - background_callback_run_all(); -} - void mp_hal_delay_ms(mp_uint_t delay_ms) { uint64_t start_tick = port_get_raw_ticks(NULL); // Adjust the delay to ticks vs ms. diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index d805aeb099..5f537ad2ed 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -54,13 +54,6 @@ extern uint32_t supervisor_ticks_ms32(void); */ extern uint64_t supervisor_ticks_ms64(void); -/** @brief Run background ticks, but only about every millisecond. - * - * Normally, this is not called directly. Instead use the RUN_BACKGROUND_TASKS - * macro. - */ -extern void supervisor_run_background_if_tick(void); - extern void supervisor_enable_tick(void); extern void supervisor_disable_tick(void); @@ -70,6 +63,6 @@ extern void supervisor_disable_tick(void); * Note that when ticks are not enabled, this function can return false; this is * intended. */ -extern bool supervisor_background_tasks_ok(void); +extern bool supervisor_background_ticks_ok(void); #endif From bc30475d093e758b73ea99b30949344ecb541521 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 7 Apr 2023 12:02:54 -0700 Subject: [PATCH 222/225] Fix frequencyio --- ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index 6d1a3f7c0e..df26379170 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -156,7 +156,7 @@ void frequencyin_interrupt_handler(uint8_t index) { } // Check if we've reached the upper limit of detection - if (!supervisor_background_tasks_ok() || self->errored_too_fast) { + if (!supervisor_background_ticks_ok() || self->errored_too_fast) { self->errored_too_fast = true; frequencyin_emergency_cancel_capture(i); } From 60502679d928abebd23a9f8d31af73f4c4108817 Mon Sep 17 00:00:00 2001 From: hexthat Date: Sat, 8 Apr 2023 17:17:42 +0000 Subject: [PATCH 223/225] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (1000 of 1000 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 37d8016fc7..dffbea185d 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: 2023-03-01 17:39+0000\n" +"PO-Revision-Date: 2023-04-09 17:51+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -15,7 +15,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.16\n" +"X-Generator: Weblate 4.17-dev\n" #: main.c msgid "" @@ -211,7 +211,7 @@ msgstr "%q bì xū shì lèi xíng wéi 'H' de shù zǔ" #: shared-bindings/synthio/MidiTrack.c shared-bindings/synthio/__init__.c msgid "%q must be array of type 'h'" -msgstr "" +msgstr "%q bìxū shì lèixíng wéi 'h' de shùzǔ" #: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c #: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c @@ -830,11 +830,11 @@ msgstr "Liánjiē yǐ duàn kāi, wúfǎ zài shǐyòng. Chuàngjiàn yīgè xī #: shared-bindings/bitmaptools/__init__.c msgid "Coordinate arrays have different lengths" -msgstr "" +msgstr "zuòbiāo shùzǔ jùyǒu bùtóng de chángdù" #: shared-bindings/bitmaptools/__init__.c msgid "Coordinate arrays types have different sizes" -msgstr "" +msgstr "zuòbiāo shùzǔ lèixíng jùyǒu bùtóng de dàxiǎo" #: py/persistentcode.c msgid "Corrupt .mpy file" @@ -1284,7 +1284,7 @@ msgstr "Wúxiào de BSSID" #: main.c msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n" -msgstr "" +msgstr "wú xiào CIRCUITPY_PYSTACK_SIZE\n" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" @@ -1310,7 +1310,7 @@ msgstr "wú xiào data_pins[%d]" #: shared-module/msgpack/__init__.c msgid "Invalid format" -msgstr "" +msgstr "géshì wúxiào" #: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" @@ -1985,7 +1985,7 @@ msgstr "bǐ lì chǐ cùn bì xū chú yǐ 3" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progress. Stop with stop_scan." -msgstr "" +msgstr "Sǎomiáo yǐ zài jìnxíng zhōng. Shǐyòng stop_scan tíngzhǐ." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2302,7 +2302,7 @@ msgstr "wèi zhī de BLE cuò wù: %d" #: ports/raspberrypi/common-hal/wifi/__init__.c #, c-format msgid "Unknown error code %d" -msgstr "" +msgstr "Wèizhī cuòwù dàimǎ %d" #: shared-bindings/wifi/Radio.c #, c-format From add8f06b758bca93f513d32df66c72fbde2cf7ee Mon Sep 17 00:00:00 2001 From: applecuckoo <113647417+applecuckoo@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:27:15 +1200 Subject: [PATCH 224/225] urandom is supported on nRF boards --- shared-bindings/os/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index b2fb8ff095..e9e5f0885f 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -241,7 +241,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync); //| """Returns a string of *size* random bytes based on a hardware True Random //| Number Generator. When not available, it will raise a NotImplementedError. //| -//| **Limitations:** Not yet available on nRF. Not available on SAMD21 due to lack of hardware. +//| **Limitations:** Not available on SAMD21 due to lack of hardware. //| """ //| ... //| From ef78dee4a5980ce8af6ff32724dce632ea14ada1 Mon Sep 17 00:00:00 2001 From: applecuckoo <113647417+applecuckoo@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:33:38 +1200 Subject: [PATCH 225/225] Fix up Contributor Covenant homepage link There was a reference to a Markdown variable that has been deleted from this version, used the original Contributor Covenant as a reference. --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index be1966ce1e..2c17dcfe16 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -123,7 +123,7 @@ accordingly. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at , and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).