From 539502c891c163205d11e116928078d792bfa152 Mon Sep 17 00:00:00 2001 From: Chris Osterwood Date: Thu, 4 Jul 2019 13:22:36 -0400 Subject: [PATCH 001/531] Remove pin reservations. Prevents used from inside of CircuitPython code --- ports/atmel-samd/boards/capablerobot_usbhub/board.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/board.c b/ports/atmel-samd/boards/capablerobot_usbhub/board.c index 9a19e02d13..46385f094f 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/board.c +++ b/ports/atmel-samd/boards/capablerobot_usbhub/board.c @@ -30,13 +30,6 @@ #include "common-hal/microcontroller/Pin.h" void board_init(void) { - // Don't reset: - // - USB Host Enable Pin - // - reset pin of the USB Hub - // - // If either are reset, USB devices will disconnect when the MCU restarts - never_reset_pin_number(PIN_PA07); - never_reset_pin_number(PIN_PB08); } bool board_requests_safe_mode(void) { From 97e7fea517cef72926ac4e8d30c711a59226f259 Mon Sep 17 00:00:00 2001 From: Chris Osterwood Date: Thu, 4 Jul 2019 13:23:57 -0400 Subject: [PATCH 002/531] Change pin names to be more descriptive --- ports/atmel-samd/boards/capablerobot_usbhub/pins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c index 1fde609409..31df7000fa 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c +++ b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c @@ -17,8 +17,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA16) }, { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA17) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_USBHEN), MP_ROM_PTR(&pin_PA07) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_USBRST), MP_ROM_PTR(&pin_PB08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_USBHOSTEN), MP_ROM_PTR(&pin_PA07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_USBRESET), MP_ROM_PTR(&pin_PB08) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, From db84445a6284db224c66a3ecef6290ce0e17915f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 21 Jul 2019 16:21:39 -0400 Subject: [PATCH 003/531] WIP: refactor _pixelbuf to use strings instead of classes --- shared-bindings/_pixelbuf/PixelBuf.c | 101 +++++++++++++++++---------- shared-bindings/_pixelbuf/PixelBuf.h | 3 +- shared-bindings/_pixelbuf/__init__.c | 101 ++++++--------------------- shared-bindings/_pixelbuf/__init__.h | 2 - shared-bindings/_pixelbuf/types.h | 6 +- 5 files changed, 88 insertions(+), 125 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 420720e622..0e43b79dd6 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -40,10 +40,42 @@ #include "../../shared-module/_pixelbuf/PixelBuf.h" #include "shared-bindings/digitalio/DigitalInOut.h" -extern const pixelbuf_byteorder_obj_t byteorder_BGR; -extern const mp_obj_type_t pixelbuf_byteorder_type; extern const int32_t colorwheel(float pos); +int parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { + details.bpp = strlen(byteorder); + char *dotstar = strchr(byteorder, 'D'); + char *r = strchr(byteorder, 'R'); + char *g = strchr(byteorder, 'G'); + char *b = strchr(byteorder, 'B'); + char *w = strchr(byteorder, 'W'); + int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); + if (num_chars < details.bpp) + mp_raise_ValueError(translate("Unexpected character in byteorder")); + if (!(r && b && g)) + mp_raise_ValueError(translate("Incomplete byteorder string")); + details.is_dotstar = dotstar ? true : false; + details.has_white = w ? true : false; + details.byteorder.r = byteorder - r; + details.byteorder.g = byteorder - g; + details.byteorder.b = byteorder - b; + if (w) + details.byteorder.w = byteorder - w; + // The dotstar brightness byte is always first (as it goes with the pixel start bits) + // if 'D' is found at the end, adjust byte position + // if 'D' is elsewhere, error out + if (dotstar) { + size_t dotstar_pos = dotstar - byteorder; + if (dotstar_pos == 4) { + details.byteorder.b += 1; + details.byteorder.g += 1; + details.byteorder.r += 1; + } else if (dotstar_pos != 0) { + mp_raise_ValueError(translate("Dotstar position invalid")); + } + } +} + //| .. currentmodule:: pixelbuf //| //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices @@ -51,7 +83,7 @@ extern const int32_t colorwheel(float pos); //| //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction. //| -//| .. class:: PixelBuf(size, buf, byteorder=BGR, brightness=0, rawbuf=None, offset=0, dotstar=False, auto_write=False, write_function=None, write_args=None) +//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False, write_function=None, write_args=None) //| //| Create a PixelBuf object of the specified size, byteorder, and bits per pixel. //| @@ -60,17 +92,15 @@ extern const int32_t colorwheel(float pos); //| //| When only given ``buf``, ``brightness`` applies to the next pixel assignment. //| -//| When ``dotstar`` is True, and ``bpp`` is 4, the 4th value in a tuple/list -//| is the individual pixel brightness (0-1). Not compatible with RGBW Byteorders. -//| Compatible `ByteOrder` classes are bpp=3, or bpp=4 and has_luminosity=True (g LBGR). +//| When ``D`` (dotstar mode) is present in the byteorder configuration, the +//| 4th value in a tuple/list is the individual pixel brightness (0-1). //| //| :param ~int size: Number of pixelsx -//| :param ~bytearray buf: Bytearray to store pixel data in -//| :param ~_pixelbuf.ByteOrder byteorder: Byte order constant from `_pixelbuf` +//| :param ~bytearray buf: Bytearray in which to store pixel data +//| :param ~str byteorder: Byte order string (such as "BGR" or "BGRD") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) -//| :param ~bytearray rawbuf: Bytearray to store raw pixel colors in +//| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) -//| :param ~bool dotstar: Dotstar mode (default False) //| :param ~bool auto_write: Whether to automatically write pixels (Default False) //| :param ~callable write_function: (optional) Callable to use to send pixels //| :param ~list write_args: (optional) Tuple or list of args to pass to ``write_function``. The @@ -78,7 +108,7 @@ extern const int32_t colorwheel(float pos); //| STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 2, MP_OBJ_FUN_ARGS_MAX, true); - enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, ARG_dotstar, + enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, ARG_auto_write, ARG_write_function, ARG_write_args }; static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, @@ -87,7 +117,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_brightness, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } }, - { MP_QSTR_dotstar, MP_ARG_BOOL, { .u_bool = false } }, { MP_QSTR_auto_write, MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_write_function, MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_write_args, MP_ARG_OBJ, {.u_obj = mp_const_none} }, @@ -95,15 +124,23 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a 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); - if (mp_obj_is_subclass_fast(args[ARG_byteorder].u_obj, &pixelbuf_byteorder_type)) - mp_raise_TypeError_varg(translate("byteorder is not an instance of ByteOrder (got a %s)"), mp_obj_get_type_str(args[ARG_byteorder].u_obj)); + if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj)) + mp_raise_TypeError(translate("byteorder is not a string")); - pixelbuf_byteorder_obj_t *byteorder = (args[ARG_byteorder].u_obj == mp_const_none) ? MP_OBJ_FROM_PTR(&byteorder_BGR) : args[ARG_byteorder].u_obj; + const char *byteorder_str = NULL; + pixelbuf_byteorder_details_t byteorder_details; + size_t bo_len; + if (args[ARG_byteorder].u_obj == NULL) + byteorder_str = "BGR"; + else + byteorder_str = mp_obj_str_get_data(byteorder_str, bo_len); - if (byteorder->has_white && args[ARG_dotstar].u_bool) - mp_raise_ValueError_varg(translate("Can not use dotstar with %s"), mp_obj_get_type_str(byteorder)); + parse_byteorder_string(byteorder_str, byteorder_details); - size_t effective_bpp = args[ARG_dotstar].u_bool ? 4 : byteorder->bpp; // Always 4 for DotStar + if (byteorder_details.has_white && byteorder_details.is_dotstar) + mp_raise_ValueError(translate("Can not use dotstar with a white byte")); + + size_t effective_bpp = byteorder_details.is_dotstar ? 4 : byteorder_details.bpp; // Always 4 for DotStar size_t bytes = args[ARG_size].u_int * effective_bpp; size_t offset = args[ARG_offset].u_int; mp_buffer_info_t bufinfo, rawbufinfo; @@ -133,28 +170,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a self->base.type = &pixelbuf_pixelbuf_type; self->pixels = args[ARG_size].u_int; self->bytes = bytes; - self->byteorder = *byteorder; // Copied because we modify for dotstar + self->byteorder = byteorder_details; // Copied because we modify for dotstar self->bytearray = args[ARG_buf].u_obj; self->two_buffers = two_buffers; self->rawbytearray = two_buffers ? args[ARG_rawbuf].u_obj : NULL; self->offset = offset; - self->dotstar_mode = args[ARG_dotstar].u_bool; self->buf = (uint8_t *)bufinfo.buf + offset; self->rawbuf = two_buffers ? (uint8_t *)rawbufinfo.buf + offset : NULL; self->pixel_step = effective_bpp; self->auto_write = args[ARG_auto_write].u_bool; - if (self->dotstar_mode) { - // Ensure sane configuration - if (!self->byteorder.has_luminosity) { - self->byteorder.has_luminosity = true; - self->byteorder.byteorder.b += 1; - self->byteorder.byteorder.g += 1; - self->byteorder.byteorder.r += 1; - } - self->byteorder.byteorder.w = 0; - } - // Show/auto-write callbacks self->write_function = args[ARG_write_function].u_obj; mp_obj_t function_args = args[ARG_write_args].u_obj; @@ -187,7 +212,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a self->brightness = 1; } - if (self->dotstar_mode) { + if (self->byteorder.is_dotstar) { // Initialize the buffer with the dotstar start bytes. // Header and end must be setup by caller for (uint i = 0; i < self->pixels * 4; i += 4) { @@ -266,7 +291,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { // Compensate for shifted buffer (bpp=3 dotstar) for (uint i = 0; i < self->bytes; i++) { // Don't adjust per-pixel luminance bytes in dotstar mode - if (!self->dotstar_mode || (i % 4 != 0)) + if (!self->byteorder.is_dotstar || (i % 4 != 0)) buf[i] = rawbuf[i] * self->brightness; } } @@ -321,7 +346,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { //| .. attribute:: byteorder //| -//| `ByteOrder` class for the buffer (read-only) +//| byteorder string for the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); @@ -397,7 +422,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; - return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->dotstar_mode); + return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); } else { // Set #if MICROPY_PY_ARRAY_SLICE_ASSIGN @@ -426,7 +451,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple) || MP_OBJ_IS_INT(value)) { pixelbuf_set_pixel(self->buf + (i * self->pixel_step), self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL, - self->brightness, item, &self->byteorder, self->dotstar_mode); + self->brightness, item, &self->byteorder, self->byteorder.is_dotstar); } } if (self->auto_write) @@ -445,10 +470,10 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (value == MP_OBJ_SENTINEL) { // Get uint8_t *pixelstart = (uint8_t *)(self->two_buffers ? self->rawbuf : self->buf) + offset; - return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->dotstar_mode); + return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->byteorder.is_dotstar); } else { // Store pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, - self->brightness, value, &self->byteorder, self->dotstar_mode); + self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) call_write_function(self); return mp_const_none; diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 0b1e362783..0f5613621a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -36,13 +36,12 @@ typedef struct { size_t pixels; size_t bytes; size_t pixel_step; - pixelbuf_byteorder_obj_t byteorder; + pixelbuf_byteorder_details_t byteorder; mp_obj_t bytearray; mp_obj_t rawbytearray; mp_float_t brightness; bool two_buffers; size_t offset; - bool dotstar_mode; uint8_t *rawbuf; uint8_t *buf; mp_obj_t write_function; diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 48b9f1cef1..6ff43cb33b 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -42,9 +42,11 @@ //| .. module:: _pixelbuf //| :synopsis: A fast RGB(W) pixel buffer library for like NeoPixel and DotStar. //| -//| The `_pixelbuf` module provides :py:class:`PixelBuf` and :py:class:`ByteOrder` classes to accelerate +//| The `_pixelbuf` module provides the :py:class:`PixelBuf` class to accelerate //| RGB(W) strip/matrix manipulation, such as DotStar and Neopixel. //| +//| Byteorders are configured with strings, such as "RGB" or "RGBD". +//| TODO: Pull in docs from pypixelbuf. //| Libraries //| @@ -53,31 +55,6 @@ //| //| PixelBuf -//| .. class:: ByteOrder() -//| -//| Classes representing byteorders for circuitpython - - -//| .. attribute:: bpp -//| -//| The number of bytes per pixel (read-only) -//| - -//| .. attribute:: has_white -//| -//| Whether the pixel has white (in addition to RGB) -//| - -//| .. attribute:: has_luminosity -//| -//| Whether the pixel has luminosity (in addition to RGB) -//| - -//| .. attribute:: byteorder -//| -//| Tuple of byte order (r, g, b) or (r, g, b, w) or (r, g, b, l) -//| - STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_byteorder_type)); @@ -113,33 +90,6 @@ STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) } } -STATIC mp_obj_t pixelbuf_byteorder_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->bpp); - default: return MP_OBJ_NULL; // op not supported - } -} - -const mp_obj_type_t pixelbuf_byteorder_type = { - { &mp_type_type }, - .name = MP_QSTR_ByteOrder, - .print = pixelbuf_byteorder_print, - .unary_op = pixelbuf_byteorder_unary_op, - .attr = pixelbuf_byteorder_attr, -}; - - -// This macro is used to simplify RGB subclass definition -#define PIXELBUF_BYTEORDER(p_name, p_bpp, p_r, p_g, p_b, p_w, p_has_white, p_has_luminosity) \ -const pixelbuf_byteorder_obj_t byteorder_## p_name = { \ - { &pixelbuf_byteorder_type }, \ - .name = MP_QSTR_## p_name, \ - .bpp = p_bpp, \ - .byteorder = { p_r, p_g, p_b, p_w }, \ - .has_white = p_has_white, \ - .has_luminosity = p_has_luminosity, \ -}; //| .. function:: wheel(n) //| @@ -290,36 +240,29 @@ PIXELBUF_BYTEORDER(LBGR, 4, 3, 2, 1, 0, false, true) STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, - { MP_ROM_QSTR(MP_QSTR_ByteOrder), MP_ROM_PTR(&pixelbuf_byteorder_type) }, - { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_PTR(&byteorder_RGB) }, - { MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_PTR(&byteorder_RBG) }, - { MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_PTR(&byteorder_GRB) }, - { MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_PTR(&byteorder_GBR) }, - { MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_PTR(&byteorder_BRG) }, - { MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_PTR(&byteorder_BGR) }, - { MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_PTR(&byteorder_RGBW) }, - { MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_PTR(&byteorder_RBGW) }, - { MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_PTR(&byteorder_GRBW) }, - { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_PTR(&byteorder_GBRW) }, - { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_PTR(&byteorder_BRGW) }, - { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_PTR(&byteorder_BGRW) }, - { MP_ROM_QSTR(MP_QSTR_LRGB), MP_ROM_PTR(&byteorder_LRGB) }, - { MP_ROM_QSTR(MP_QSTR_LRBG), MP_ROM_PTR(&byteorder_LRBG) }, - { MP_ROM_QSTR(MP_QSTR_LGRB), MP_ROM_PTR(&byteorder_LGRB) }, - { MP_ROM_QSTR(MP_QSTR_LGBR), MP_ROM_PTR(&byteorder_LGBR) }, - { MP_ROM_QSTR(MP_QSTR_LBRG), MP_ROM_PTR(&byteorder_LBRG) }, - { MP_ROM_QSTR(MP_QSTR_LBGR), MP_ROM_PTR(&byteorder_LBGR) }, - { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, + { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_QSTR(MP_QSTR_RGB) }, + { MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_QSTR(MP_QSTR_RBG) }, + { MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_QSTR(MP_QSTR_GRB) }, + { MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_QSTR(MP_QSTR_GBR) }, + { MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_QSTR(MP_QSTR_BRG) }, + { MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_QSTR(MP_QSTR_BGR) }, + { MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_QSTR(MP_QSTR_RGBW) }, + { MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_QSTR(MP_QSTR_RBGW) }, + { MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_QSTR(MP_QSTR_GRBW) }, + { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_QSTR(MP_QSTR_GBRW) }, + { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_QSTR(MP_QSTR_BRGW) }, + { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_QSTR(MP_QSTR_BGRW) }, + { MP_ROM_QSTR(MP_QSTR_RGBD), MP_ROM_QSTR(MP_QSTR_RGBD) }, + { MP_ROM_QSTR(MP_QSTR_RBGD), MP_ROM_QSTR(MP_QSTR_RBGD) }, + { MP_ROM_QSTR(MP_QSTR_GRBD), MP_ROM_QSTR(MP_QSTR_GRBD) }, + { MP_ROM_QSTR(MP_QSTR_GBRD), MP_ROM_QSTR(MP_QSTR_GBRD) }, + { MP_ROM_QSTR(MP_QSTR_BRGD), MP_ROM_QSTR(MP_QSTR_BRGD) }, + { MP_ROM_QSTR(MP_QSTR_BGRD), MP_ROM_QSTR(MP_QSTR_BGRD) }, + { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_QSTR(&pixelbuf_wheel_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table); -STATIC void pixelbuf_byteorder_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "%q.%q", MP_QSTR__pixelbuf, self->name); - return; -} - const mp_obj_module_t pixelbuf_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&pixelbuf_module_globals, diff --git a/shared-bindings/_pixelbuf/__init__.h b/shared-bindings/_pixelbuf/__init__.h index a62d67c4a4..f70ffe5083 100644 --- a/shared-bindings/_pixelbuf/__init__.h +++ b/shared-bindings/_pixelbuf/__init__.h @@ -29,9 +29,7 @@ #include "common-hal/digitalio/DigitalInOut.h" -STATIC void pixelbuf_byteorder_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); const int32_t colorwheel(float pos); -const mp_obj_type_t pixelbuf_byteorder_type; extern void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* gpio, uint8_t *pixels, uint32_t numBytes); #endif //CP_SHARED_BINDINGS_PIXELBUF_INIT_H diff --git a/shared-bindings/_pixelbuf/types.h b/shared-bindings/_pixelbuf/types.h index f7d757791b..7d772dbf53 100644 --- a/shared-bindings/_pixelbuf/types.h +++ b/shared-bindings/_pixelbuf/types.h @@ -37,12 +37,10 @@ typedef struct { } pixelbuf_rgbw_t; typedef struct { - mp_obj_base_t base; - qstr name; uint8_t bpp; pixelbuf_rgbw_t byteorder; bool has_white; - bool has_luminosity; -} pixelbuf_byteorder_obj_t; + bool is_dotstar; +} pixelbuf_byteorder_details_t; #endif // CIRCUITPYTHON_PIXELBUF_TYPES_H From a62a1ae2bd16a4d8e4029b26bd23761da1b12d5f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 21 Jul 2019 16:30:09 -0400 Subject: [PATCH 004/531] WIP: refactor _pixelbuf to use strings instead of classes --- shared-bindings/_pixelbuf/PixelBuf.c | 2 +- shared-bindings/_pixelbuf/__init__.c | 35 ---------------------------- shared-module/_pixelbuf/PixelBuf.c | 6 ++--- shared-module/_pixelbuf/PixelBuf.h | 8 +++---- 4 files changed, 8 insertions(+), 43 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 0e43b79dd6..2ea40d1de2 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -42,7 +42,7 @@ extern const int32_t colorwheel(float pos); -int parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { +void parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { details.bpp = strlen(byteorder); char *dotstar = strchr(byteorder, 'D'); char *r = strchr(byteorder, 'R'); diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 6ff43cb33b..229c04603c 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -56,41 +56,6 @@ //| PixelBuf -STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_byteorder_type)); - pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in); - if (dest[0] == MP_OBJ_NULL) { - // load attribute - mp_obj_t val; - if (attr == MP_QSTR_bpp) { - val = MP_OBJ_NEW_SMALL_INT(self->bpp); - } else if (attr == MP_QSTR_has_white) { - val = mp_obj_new_bool(self->has_white); - } else if (attr == MP_QSTR_has_luminosity) { - val = mp_obj_new_bool(self->has_luminosity); - } else if (attr == MP_QSTR_byteorder) { - mp_obj_t items[4]; - uint8_t n = self->bpp; - if (self->has_luminosity || self->has_white) { - n = 4; - } - uint8_t *values = (uint8_t *)&(self->byteorder); - for (uint8_t i=0; i -void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj_t *byteorder) { +void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder) { buf[byteorder->byteorder.r] = value >> 16 & 0xff; buf[byteorder->byteorder.g] = (value >> 8) & 0xff; buf[byteorder->byteorder.b] = value & 0xff; @@ -43,7 +43,7 @@ void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj } } -void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_obj_t *byteorder, bool dotstar) { +void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar) { if (MP_OBJ_IS_INT(item)) { uint8_t *target = rawbuf ? rawbuf : buf; pixelbuf_set_pixel_int(target, mp_obj_get_int_truncated(item), byteorder); @@ -94,7 +94,7 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ } } -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_obj_t *byteorder, uint8_t step, bool dotstar) { +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar) { mp_obj_t elems[len]; for (uint i = 0; i < len; i++) { elems[i] = pixelbuf_get_pixel(buf + (i * step), byteorder, dotstar); diff --git a/shared-module/_pixelbuf/PixelBuf.h b/shared-module/_pixelbuf/PixelBuf.h index 9e115fe0cf..6b3272e193 100644 --- a/shared-module/_pixelbuf/PixelBuf.h +++ b/shared-module/_pixelbuf/PixelBuf.h @@ -42,9 +42,9 @@ #define DOTSTAR_GET_BRIGHTNESS(value) ((value & 0b00011111) / 31.0) #define DOTSTAR_LED_START_FULL_BRIGHT 0xFF -void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_obj_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_obj_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_obj_t *byteorder, uint8_t step, bool dotstar); -void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj_t *byteorder); +void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar); +mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar); +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar); +void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder); #endif From 31e4591691891abd92d8e3851cd13fb6dbc9bf64 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 21 Jul 2019 16:37:06 -0400 Subject: [PATCH 005/531] WIP: refactor _pixelbuf to use strings instead of classes --- shared-bindings/_pixelbuf/PixelBuf.c | 2 +- shared-bindings/_pixelbuf/__init__.c | 122 +-------------------------- shared-module/_pixelbuf/PixelBuf.c | 2 +- 3 files changed, 3 insertions(+), 123 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 2ea40d1de2..01ba702c37 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -133,7 +133,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (args[ARG_byteorder].u_obj == NULL) byteorder_str = "BGR"; else - byteorder_str = mp_obj_str_get_data(byteorder_str, bo_len); + byteorder_str = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); parse_byteorder_string(byteorder_str, byteorder_details); diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 229c04603c..02d5f49b35 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -82,126 +82,6 @@ const int32_t colorwheel(float pos) { } } - -/// RGB -//| .. data:: RGB -//| -//| * **order** Red, Green, Blue -//| * **bpp** 3 -PIXELBUF_BYTEORDER(RGB, 3, 0, 1, 2, 3, false, false) -//| .. data:: RBG -//| -//| * **order** Red, Blue, Green -//| * **bpp** 3 -PIXELBUF_BYTEORDER(RBG, 3, 0, 2, 1, 3, false, false) -//| .. data:: GRB -//| -//| * **order** Green, Red, Blue -//| * **bpp** 3 -//| -//| Commonly used by NeoPixel. -PIXELBUF_BYTEORDER(GRB, 3, 1, 0, 2, 3, false, false) -//| .. data:: GBR -//| -//| * **order** Green, Blue, Red -//| * **bpp** 3 -PIXELBUF_BYTEORDER(GBR, 3, 1, 2, 0, 3, false, false) -//| .. data:: BRG -//| -//| * **order** Blue, Red, Green -//| * **bpp** 3 -PIXELBUF_BYTEORDER(BRG, 3, 2, 0, 1, 3, false, false) -//| .. data:: BGR -//| -//| * **order** Blue, Green, Red -//| * **bpp** 3 -//| -//| Commonly used by Dotstar. -PIXELBUF_BYTEORDER(BGR, 3, 2, 1, 0, 3, false, false) - -// RGBW -//| .. data:: RGBW -//| -//| * **order** Red, Green, Blue, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(RGBW, 4, 0, 1, 2, 3, true, false) -//| .. data:: RBGW -//| -//| * **order** Red, Blue, Green, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(RBGW, 4, 0, 2, 1, 3, true, false) -//| .. data:: GRBW -//| -//| * **order** Green, Red, Blue, White -//| * **bpp** 4 -//| * **has_white** True -//| -//| Commonly used by RGBW NeoPixels. -PIXELBUF_BYTEORDER(GRBW, 4, 1, 0, 2, 3, true, false) -//| .. data:: GBRW -//| -//| * **order** Green, Blue, Red, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(GBRW, 4, 1, 2, 0, 3, true, false) -//| .. data:: BRGW -//| -//| * **order** Blue, Red, Green, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(BRGW, 4, 2, 0, 1, 3, true, false) -//| .. data:: BGRW -//| -//| * **order** Blue, Green, Red, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(BGRW, 4, 2, 1, 0, 3, true, false) - -// Luminosity + RGB (eg for Dotstar) -// Luminosity chosen because the luminosity of a Dotstar at full bright -// burns the eyes like looking at the Sun. -// https://www.thesaurus.com/browse/luminosity?s=t -//| .. data:: LRGB -//| -//| * **order** *Luminosity*, Red, Green, Blue -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LRGB, 4, 1, 2, 3, 0, false, true) -//| .. data:: LRBG -//| -//| * **order** *Luminosity*, Red, Blue, Green -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LRBG, 4, 1, 3, 2, 0, false, true) -//| .. data:: LGRB -//| -//| * **order** *Luminosity*, Green, Red, Blue -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LGRB, 4, 2, 1, 3, 0, false, true) -//| .. data:: LGBR -//| -//| * **order** *Luminosity*, Green, Blue, Red -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LGBR, 4, 2, 3, 1, 0, false, true) -//| .. data:: LBRG -//| -//| * **order** *Luminosity*, Blue, Red, Green -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LBRG, 4, 3, 1, 2, 0, false, true) -//| .. data:: LBGR -//| -//| * **order** *Luminosity*, Blue, Green, Red -//| * **bpp** 4 -//| * **has_luminosity** True -//| -//| Actual format commonly used by DotStar (5 bit luninance value) -PIXELBUF_BYTEORDER(LBGR, 4, 3, 2, 1, 0, false, true) - STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, @@ -223,7 +103,7 @@ STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_GBRD), MP_ROM_QSTR(MP_QSTR_GBRD) }, { MP_ROM_QSTR(MP_QSTR_BRGD), MP_ROM_QSTR(MP_QSTR_BRGD) }, { MP_ROM_QSTR(MP_QSTR_BGRD), MP_ROM_QSTR(MP_QSTR_BGRD) }, - { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_QSTR(&pixelbuf_wheel_obj) }, + { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table); diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index 6b222eec85..b7cdef4830 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -102,7 +102,7 @@ mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_de return mp_obj_new_tuple(len, elems); } -mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_obj_t *byteorder, bool dotstar) { +mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar) { mp_obj_t elems[byteorder->bpp]; elems[0] = mp_obj_new_int(buf[byteorder->byteorder.r]); From cf3bb7e1181a0e5cc74a5f12c0d3fcc77dadea8f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 26 Jul 2019 18:52:22 -0400 Subject: [PATCH 006/531] fix bugs and inline the byteorder code --- shared-bindings/_pixelbuf/PixelBuf.c | 77 +++++++++++++--------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 01ba702c37..e508551ae3 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -42,40 +42,6 @@ extern const int32_t colorwheel(float pos); -void parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { - details.bpp = strlen(byteorder); - char *dotstar = strchr(byteorder, 'D'); - char *r = strchr(byteorder, 'R'); - char *g = strchr(byteorder, 'G'); - char *b = strchr(byteorder, 'B'); - char *w = strchr(byteorder, 'W'); - int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); - if (num_chars < details.bpp) - mp_raise_ValueError(translate("Unexpected character in byteorder")); - if (!(r && b && g)) - mp_raise_ValueError(translate("Incomplete byteorder string")); - details.is_dotstar = dotstar ? true : false; - details.has_white = w ? true : false; - details.byteorder.r = byteorder - r; - details.byteorder.g = byteorder - g; - details.byteorder.b = byteorder - b; - if (w) - details.byteorder.w = byteorder - w; - // The dotstar brightness byte is always first (as it goes with the pixel start bits) - // if 'D' is found at the end, adjust byte position - // if 'D' is elsewhere, error out - if (dotstar) { - size_t dotstar_pos = dotstar - byteorder; - if (dotstar_pos == 4) { - details.byteorder.b += 1; - details.byteorder.g += 1; - details.byteorder.r += 1; - } else if (dotstar_pos != 0) { - mp_raise_ValueError(translate("Dotstar position invalid")); - } - } -} - //| .. currentmodule:: pixelbuf //| //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices @@ -123,20 +89,49 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a }; 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); + const char *byteorder = NULL; + pixelbuf_byteorder_details_t byteorder_details; + size_t bo_len; if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj)) mp_raise_TypeError(translate("byteorder is not a string")); - const char *byteorder_str = NULL; - pixelbuf_byteorder_details_t byteorder_details; - size_t bo_len; if (args[ARG_byteorder].u_obj == NULL) - byteorder_str = "BGR"; + byteorder = "BGR"; else - byteorder_str = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); - - parse_byteorder_string(byteorder_str, byteorder_details); + byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); + byteorder_details.bpp = strlen(byteorder); + char *dotstar = strchr(byteorder, 'D'); + char *r = strchr(byteorder, 'R'); + char *g = strchr(byteorder, 'G'); + char *b = strchr(byteorder, 'B'); + char *w = strchr(byteorder, 'W'); + int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); + if (num_chars < byteorder_details.bpp) + mp_raise_ValueError(translate("Unexpected character in byteorder")); + if (!(r && b && g)) + mp_raise_ValueError(translate("Incomplete byteorder string")); + byteorder_details.is_dotstar = dotstar ? true : false; + byteorder_details.has_white = w ? true : false; + byteorder_details.byteorder.r = r - byteorder; + byteorder_details.byteorder.g = g - byteorder; + byteorder_details.byteorder.b = b - byteorder; + if (w) + byteorder_details.byteorder.w = w - byteorder; + // The dotstar brightness byte is always first (as it goes with the pixel start bits) + // if 'D' is found at the end, adjust byte position + // if 'D' is elsewhere, error out + if (dotstar) { + size_t dotstar_pos = dotstar - byteorder; + if (dotstar_pos == 4) { + byteorder_details.byteorder.b += 1; + byteorder_details.byteorder.g += 1; + byteorder_details.byteorder.r += 1; + } else if (dotstar_pos != 0) { + mp_raise_ValueError(translate("Dotstar position invalid")); + } + } if (byteorder_details.has_white && byteorder_details.is_dotstar) mp_raise_ValueError(translate("Can not use dotstar with a white byte")); From cff9c9bc950a3d374babfb3c7388f179c3577e51 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 1 Aug 2019 20:24:39 -0400 Subject: [PATCH 007/531] Reuse error message --- shared-bindings/_pixelbuf/PixelBuf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index e508551ae3..f4f6c83b2c 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -108,10 +108,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a char *b = strchr(byteorder, 'B'); char *w = strchr(byteorder, 'W'); int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); - if (num_chars < byteorder_details.bpp) - mp_raise_ValueError(translate("Unexpected character in byteorder")); - if (!(r && b && g)) - mp_raise_ValueError(translate("Incomplete byteorder string")); + if ((num_chars < byteorder_details.bpp) || !(r && b && g)) + mp_raise_ValueError(translate("Invalid byteorder string")); byteorder_details.is_dotstar = dotstar ? true : false; byteorder_details.has_white = w ? true : false; byteorder_details.byteorder.r = r - byteorder; @@ -124,16 +122,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a // if 'D' is elsewhere, error out if (dotstar) { size_t dotstar_pos = dotstar - byteorder; - if (dotstar_pos == 4) { + if (dotstar_pos == 3) { byteorder_details.byteorder.b += 1; byteorder_details.byteorder.g += 1; byteorder_details.byteorder.r += 1; } else if (dotstar_pos != 0) { - mp_raise_ValueError(translate("Dotstar position invalid")); + mp_raise_ValueError(translate("Invalid byteorder string")); } } if (byteorder_details.has_white && byteorder_details.is_dotstar) - mp_raise_ValueError(translate("Can not use dotstar with a white byte")); + mp_raise_ValueError(translate("Invalid byteorder string")); size_t effective_bpp = byteorder_details.is_dotstar ? 4 : byteorder_details.bpp; // Always 4 for DotStar size_t bytes = args[ARG_size].u_int * effective_bpp; From 5c08182c731a0f341b6ee61b2433f91063552464 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 3 Aug 2019 13:35:11 -0400 Subject: [PATCH 008/531] fix fix the byte order property. --- shared-bindings/_pixelbuf/PixelBuf.c | 16 ++++++++++------ shared-bindings/_pixelbuf/types.h | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index f4f6c83b2c..90210d4f3a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -101,7 +101,11 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a else byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); - byteorder_details.bpp = strlen(byteorder); + if (bo_len < 3 || bo_len > 4) + mp_raise_ValueError(translate("Invalid byteorder string")); + strncpy(byteorder_details.order, byteorder, sizeof(byteorder_details.order)); + + byteorder_details.bpp = bo_len; char *dotstar = strchr(byteorder, 'D'); char *r = strchr(byteorder, 'R'); char *g = strchr(byteorder, 'G'); @@ -344,13 +348,13 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); - return &self->byteorder; + return mp_obj_new_str(self->byteorder.order, strlen(self->byteorder.order)); } -MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_obj, pixelbuf_pixelbuf_obj_get_byteorder); +MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); -const mp_obj_property_t pixelbuf_pixelbuf_byteorder_obj = { +const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_byteorder_obj, + .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_byteorder_str, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj}, }; @@ -479,7 +483,7 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_bpp), MP_ROM_PTR(&pixelbuf_pixelbuf_bpp_obj)}, { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&pixelbuf_pixelbuf_brightness_obj)}, { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, - { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_obj)}, + { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, }; diff --git a/shared-bindings/_pixelbuf/types.h b/shared-bindings/_pixelbuf/types.h index 7d772dbf53..39e49935fa 100644 --- a/shared-bindings/_pixelbuf/types.h +++ b/shared-bindings/_pixelbuf/types.h @@ -41,6 +41,7 @@ typedef struct { pixelbuf_rgbw_t byteorder; bool has_white; bool is_dotstar; + char order[5]; } pixelbuf_byteorder_details_t; #endif // CIRCUITPYTHON_PIXELBUF_TYPES_H From 3cf9a475b99090d72b9992816808cbde309dcc40 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 4 Aug 2019 11:02:33 -0400 Subject: [PATCH 009/531] fix 'white' byte for dotstars --- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- shared-module/_pixelbuf/PixelBuf.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 90210d4f3a..969d167099 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -119,8 +119,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a byteorder_details.byteorder.r = r - byteorder; byteorder_details.byteorder.g = g - byteorder; byteorder_details.byteorder.b = b - byteorder; - if (w) - byteorder_details.byteorder.w = w - byteorder; + byteorder_details.byteorder.w = w ? w - byteorder : 0; // The dotstar brightness byte is always first (as it goes with the pixel start bits) // if 'D' is found at the end, adjust byte position // if 'D' is elsewhere, error out @@ -130,6 +129,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a byteorder_details.byteorder.b += 1; byteorder_details.byteorder.g += 1; byteorder_details.byteorder.r += 1; + byteorder_details.byteorder.w = 0; } else if (dotstar_pos != 0) { mp_raise_ValueError(translate("Invalid byteorder string")); } diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index b7cdef4830..e26f05ac3a 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -47,11 +47,11 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ if (MP_OBJ_IS_INT(item)) { uint8_t *target = rawbuf ? rawbuf : buf; pixelbuf_set_pixel_int(target, mp_obj_get_int_truncated(item), byteorder); - if (dotstar) { + if (dotstar) { buf[0] = DOTSTAR_LED_START_FULL_BRIGHT; if (rawbuf) rawbuf[0] = DOTSTAR_LED_START_FULL_BRIGHT; - } + } if (rawbuf) { buf[byteorder->byteorder.r] = rawbuf[byteorder->byteorder.r] * brightness; buf[byteorder->byteorder.g] = rawbuf[byteorder->byteorder.g] * brightness; From d5658860aa5427717c3aecfc631a39ce3a892da1 Mon Sep 17 00:00:00 2001 From: Chris Osterwood Date: Thu, 8 Aug 2019 14:39:50 -0400 Subject: [PATCH 010/531] Added pin definition for battery change enable. Pin used to switch in a 10 ohm resistor during Hub reset & strapping. --- ports/atmel-samd/boards/capablerobot_usbhub/pins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c index 31df7000fa..b1966930c7 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c +++ b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c @@ -19,6 +19,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_USBHOSTEN), MP_ROM_PTR(&pin_PA07) }, { MP_OBJ_NEW_QSTR(MP_QSTR_USBRESET), MP_ROM_PTR(&pin_PB08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_USBBCEN), MP_ROM_PTR(&pin_PB22) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, From 7507b206be4c2c746f78e67ca76ca882070e34e0 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 3 Oct 2019 19:16:36 -0400 Subject: [PATCH 011/531] disable troublesome context dump (Argument list too long) --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c1f46f6ff..629f554ba7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,10 +6,10 @@ jobs: test: runs-on: ubuntu-16.04 steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" + # - name: Dump GitHub context + # env: + # GITHUB_CONTEXT: ${{ toJson(github) }} + # run: echo "$GITHUB_CONTEXT" - name: Fail if not a release publish # workaround has `on` doesn't have this filter run: exit 1 if: github.event_name == 'release' && (github.event.action != 'published' && github.event.action != 'rerequested') From 00032619bd3c0255b3e30e43951ab8222913f8e5 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 3 Oct 2019 19:42:40 -0400 Subject: [PATCH 012/531] Update translation --- locale/ID.po | 20 +++++++------------- locale/circuitpython.pot | 20 +++++++------------- locale/de_DE.po | 27 ++++++++++++++------------- locale/en_US.po | 20 +++++++------------- locale/en_x_pirate.po | 20 +++++++------------- locale/es.po | 35 ++++++++++++++++++++--------------- locale/fil.po | 25 +++++++++++-------------- locale/fr.po | 35 ++++++++++++++++++++--------------- locale/it_IT.po | 29 +++++++++++++++-------------- locale/pl.po | 33 +++++++++++++++++++-------------- locale/pt_BR.po | 25 +++++++++++-------------- locale/zh_Latn_pinyin.po | 33 +++++++++++++++++++-------------- 12 files changed, 157 insertions(+), 165 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 63e3466b6e..1e5e404465 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -370,11 +370,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -812,6 +807,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Ukuran buffer tidak valid" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1526,8 +1525,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2212,7 +2210,7 @@ msgstr "tidak ada modul yang bernama '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2394,10 +2392,6 @@ msgstr "antrian meluap (overflow)" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d709a69cc9..1e888ad9ef 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -365,11 +365,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -797,6 +792,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1492,8 +1491,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2177,7 +2175,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2358,10 +2356,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index c846b646b7..c39cc653bb 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -369,11 +369,6 @@ msgstr "Ein Bytes kann nur Werte zwischen 0 und 255 annehmen." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Kann dotstar nicht mit %s verwenden" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -803,6 +798,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Ungültige Puffergröße" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1532,8 +1531,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2224,7 +2222,7 @@ msgstr "Kein Modul mit dem Namen '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2407,10 +2405,6 @@ msgstr "Warteschlangenüberlauf" msgid "rawbuf is not the same size as buf" msgstr "rawbuf hat nicht die gleiche Größe wie buf" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "Readonly-Attribut" - #: py/builtinimport.c msgid "relative import" msgstr "relativer Import" @@ -2760,6 +2754,10 @@ msgstr "" #~ msgid "C-level assert" #~ msgstr "C-Level Assert" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Kann dotstar nicht mit %s verwenden" + #~ msgid "Can't add services in Central mode" #~ msgstr "Im Central mode können Dienste nicht hinzugefügt werden" @@ -2978,6 +2976,9 @@ msgstr "" #~ msgid "pin does not have IRQ capabilities" #~ msgstr "Pin hat keine IRQ Fähigkeiten" +#~ msgid "readonly attribute" +#~ msgstr "Readonly-Attribut" + #~ msgid "scan failed" #~ msgstr "Scan fehlgeschlagen" diff --git a/locale/en_US.po b/locale/en_US.po index 652053ee99..a26fd72472 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -365,11 +365,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -797,6 +792,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1492,8 +1491,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2177,7 +2175,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2358,10 +2356,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 1d2fcb659c..0cd7b24643 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -369,11 +369,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -801,6 +796,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1496,8 +1495,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2181,7 +2179,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2362,10 +2360,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" diff --git a/locale/es.po b/locale/es.po index ca8593dcdf..c312565fa8 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -373,11 +373,6 @@ msgstr "Bytes debe estar entre 0 y 255." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "No se puede usar dotstar con %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -808,6 +803,10 @@ msgstr "Inválido bits por valor" msgid "Invalid buffer size" msgstr "Tamaño de buffer inválido" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Inválido periodo de captura. Rango válido: 1 - 500" @@ -1539,9 +1538,8 @@ msgid "byte code not implemented" msgstr "codigo byte no implementado" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "byteorder no es instancia de ByteOrder (encontarmos un %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2234,7 +2232,7 @@ msgstr "ningún módulo se llama '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "no hay tal atributo" @@ -2419,11 +2417,6 @@ msgstr "desbordamiento de cola(queue)" msgid "rawbuf is not the same size as buf" msgstr "rawbuf no es el mismo tamaño que buf" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "atributo no legible" - #: py/builtinimport.c msgid "relative import" msgstr "import relativo" @@ -2768,6 +2761,10 @@ msgstr "paso cero" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "No se puede usar dotstar con %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "No se pueden agregar servicio en modo Central" @@ -2963,6 +2960,10 @@ msgstr "paso cero" #~ msgid "buffer too long" #~ msgstr "buffer demasiado largo" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "byteorder no es instancia de ByteOrder (encontarmos un %s)" + #~ msgid "can query only one param" #~ msgstr "puede consultar solo un param" @@ -3036,6 +3037,10 @@ msgstr "paso cero" #~ msgid "position must be 2-tuple" #~ msgstr "posición debe ser 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "atributo no legible" + #~ msgid "row must be packed and word aligned" #~ msgstr "la fila debe estar empacada y la palabra alineada" diff --git a/locale/fil.po b/locale/fil.po index 6f460c94cf..c252d9c350 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -372,11 +372,6 @@ msgstr "Sa gitna ng 0 o 255 dapat ang bytes." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -817,6 +812,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Mali ang buffer size" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1546,8 +1545,7 @@ msgid "byte code not implemented" msgstr "byte code hindi pa implemented" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2248,7 +2246,7 @@ msgstr "walang module na '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "walang ganoon na attribute" @@ -2431,11 +2429,6 @@ msgstr "puno na ang pila (overflow)" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "hindi mabasa ang attribute" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" @@ -3019,6 +3012,10 @@ msgstr "zero step" #~ msgid "position must be 2-tuple" #~ msgstr "position ay dapat 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "hindi mabasa ang attribute" + #~ msgid "row must be packed and word aligned" #~ msgstr "row ay dapat packed at ang word nakahanay" diff --git a/locale/fr.po b/locale/fr.po index c176fd8bcf..3514362305 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -377,11 +377,6 @@ msgstr "Les octets 'bytes' doivent être entre 0 et 255" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Impossible d'utiliser 'dotstar' avec %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -824,6 +819,10 @@ msgstr "Bits par valeur invalides" msgid "Invalid buffer size" msgstr "Longueur de tampon invalide" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Période de capture invalide. Gamme valide: 1 à 500" @@ -1572,9 +1571,8 @@ msgid "byte code not implemented" msgstr "bytecode non implémenté" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "'byteorder' n'est pas une instance de ByteOrder (reçu un %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2281,7 +2279,7 @@ msgstr "pas de module '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "pas de tel attribut" @@ -2471,11 +2469,6 @@ msgstr "dépassement de file" msgid "rawbuf is not the same size as buf" msgstr "'rawbuf' n'est pas de la même taille que 'buf'" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "attribut en lecture seule" - #: py/builtinimport.c msgid "relative import" msgstr "import relatif" @@ -2824,6 +2817,10 @@ msgstr "'step' nul" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Impossible d'utiliser 'dotstar' avec %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Impossible d'ajouter des services en mode Central" @@ -3015,6 +3012,10 @@ msgstr "'step' nul" #~ msgid "buffer too long" #~ msgstr "tampon trop long" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "'byteorder' n'est pas une instance de ByteOrder (reçu un %s)" + #~ msgid "can query only one param" #~ msgstr "ne peut demander qu'un seul paramètre" @@ -3087,6 +3088,10 @@ msgstr "'step' nul" #~ msgid "position must be 2-tuple" #~ msgstr "position doit être un 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "attribut en lecture seule" + #~ msgid "scan failed" #~ msgstr "échec du scan" diff --git a/locale/it_IT.po b/locale/it_IT.po index 883c65d41f..9376a679b6 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -372,11 +372,6 @@ msgstr "I byte devono essere compresi tra 0 e 255" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "dotstar non può essere usato con %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -817,6 +812,10 @@ msgstr "bits per valore invalido" msgid "Invalid buffer size" msgstr "lunghezza del buffer non valida" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "periodo di cattura invalido. Zona valida: 1 - 500" @@ -1542,8 +1541,7 @@ msgid "byte code not implemented" msgstr "byte code non implementato" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2242,7 +2240,7 @@ msgstr "nessun modulo chiamato '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "attributo inesistente" @@ -2429,11 +2427,6 @@ msgstr "overflow della coda" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "attributo non leggibile" - #: py/builtinimport.c msgid "relative import" msgstr "importazione relativa" @@ -2779,6 +2772,10 @@ msgstr "zero step" #~ msgid "C-level assert" #~ msgstr "assert a livello C" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "dotstar non può essere usato con %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "non si può aggiungere servizi in Central mode" @@ -3017,6 +3014,10 @@ msgstr "zero step" #~ msgid "position must be 2-tuple" #~ msgstr "position deve essere una 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "attributo non leggibile" + #~ msgid "row must be packed and word aligned" #~ msgstr "la riga deve essere compattata e allineata alla parola" diff --git a/locale/pl.po b/locale/pl.po index 9ed76924b5..8cf69bb37d 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -368,11 +368,6 @@ msgstr "Bytes musi być między 0 a 255." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Nie można używać dotstar z %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -802,6 +797,10 @@ msgstr "Zła liczba bitów wartości" msgid "Invalid buffer size" msgstr "Zła wielkość bufora" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Zły okres. Poprawny zakres to: 1 - 500" @@ -1516,9 +1515,8 @@ msgid "byte code not implemented" msgstr "bajtkod niezaimplemntowany" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "byteorder musi być typu ByteOrder (jest %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2202,7 +2200,7 @@ msgstr "brak modułu o nazwie '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "nie ma takiego atrybutu" @@ -2384,10 +2382,6 @@ msgstr "przepełnienie kolejki" msgid "rawbuf is not the same size as buf" msgstr "rawbuf nie jest tej samej wielkości co buf" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "atrybut tylko do odczytu" - #: py/builtinimport.c msgid "relative import" msgstr "relatywny import" @@ -2725,6 +2719,10 @@ msgstr "zerowy krok" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Adres nie ma długości %d bajtów lub zły format" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Nie można używać dotstar z %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Nie można dodać serwisów w trybie Central" @@ -2802,6 +2800,10 @@ msgstr "zerowy krok" #~ msgid "bad GATT role" #~ msgstr "zła rola GATT" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "byteorder musi być typu ByteOrder (jest %s)" + #~ msgid "characteristics includes an object that is not a Characteristic" #~ msgstr "" #~ "charakterystyki zawierają obiekt, który nie jest typu Characteristic" @@ -2809,6 +2811,9 @@ msgstr "zerowy krok" #~ msgid "interval not in range 0.0020 to 10.24" #~ msgstr "przedział poza zakresem 0.0020 do 10.24" +#~ msgid "readonly attribute" +#~ msgstr "atrybut tylko do odczytu" + #~ msgid "services includes an object that is not a Service" #~ msgstr "obiekt typu innego niż Service w services" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index a17a275390..280cf13cdb 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -369,11 +369,6 @@ msgstr "Os bytes devem estar entre 0 e 255." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -810,6 +805,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Arquivo inválido" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1516,8 +1515,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2203,7 +2201,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2384,11 +2382,6 @@ msgstr "estouro de fila" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "atributo ilegível" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2927,6 +2920,10 @@ msgstr "passo zero" #~ msgid "pin does not have IRQ capabilities" #~ msgstr "Pino não tem recursos de IRQ" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "atributo ilegível" + #~ msgid "row must be packed and word aligned" #~ msgstr "Linha deve ser comprimida e com as palavras alinhadas" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index d5df0b7b0c..481b98e7bf 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -369,11 +369,6 @@ msgstr "Zì jié bìxū jiè yú 0 dào 255 zhī jiān." msgid "Call super().__init__() before accessing native object." msgstr "Zài fǎngwèn běn jī wùjiàn zhīqián diàoyòng super().__init__()" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -803,6 +798,10 @@ msgstr "Měi gè zhí de wèi wúxiào" msgid "Invalid buffer size" msgstr "Wúxiào de huǎnchōng qū dàxiǎo" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Wúxiào de bǔhuò zhōuqí. Yǒuxiào fànwéi: 1-500" @@ -1525,9 +1524,8 @@ msgid "byte code not implemented" msgstr "zì jié dàimǎ wèi zhíxíng" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "zì jié bùshì zì jié xù shílì (yǒu %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2215,7 +2213,7 @@ msgstr "méiyǒu mókuài '%q'" msgid "no reset pin available" msgstr "Méiyǒu kěyòng de fùwèi yǐn jiǎo" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "méiyǒu cǐ shǔxìng" @@ -2396,10 +2394,6 @@ msgstr "duìliè yìchū" msgid "rawbuf is not the same size as buf" msgstr "yuánshǐ huǎnchōng qū hé huǎnchōng qū de dàxiǎo bùtóng" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "zhǐ dú shǔxìng" - #: py/builtinimport.c msgid "relative import" msgstr "xiāngduì dǎorù" @@ -2738,6 +2732,10 @@ msgstr "líng bù" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" @@ -2831,6 +2829,10 @@ msgstr "líng bù" #~ msgid "bad GATT role" #~ msgstr "zǒng xiédìng de bùliáng juésè" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "zì jié bùshì zì jié xù shílì (yǒu %s)" + #~ msgid "characteristics includes an object that is not a Characteristic" #~ msgstr "tèxìng bāokuò bùshì zìfú de wùtǐ" @@ -2840,6 +2842,9 @@ msgstr "líng bù" #~ msgid "interval not in range 0.0020 to 10.24" #~ msgstr "jùlí 0.0020 Zhì 10.24 Zhī jiān de jiàngé shíjiān" +#~ msgid "readonly attribute" +#~ msgstr "zhǐ dú shǔxìng" + #~ msgid "row must be packed and word aligned" #~ msgstr "xíng bìxū dǎbāo bìngqiě zì duìqí" From dfad1352ad98c01da1c61c7575074e87ba65cb72 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 3 Oct 2019 19:49:12 -0400 Subject: [PATCH 013/531] echo github context using python --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 629f554ba7..430623dd77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,10 +6,10 @@ jobs: test: runs-on: ubuntu-16.04 steps: - # - name: Dump GitHub context - # env: - # GITHUB_CONTEXT: ${{ toJson(github) }} - # run: echo "$GITHUB_CONTEXT" + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: python -c "import os; print os.environ['GITHUB_CONTEXT']" - name: Fail if not a release publish # workaround has `on` doesn't have this filter run: exit 1 if: github.event_name == 'release' && (github.event.action != 'published' && github.event.action != 'rerequested') From 84b8ae13029633d9db2c6a688303aba4a01ccf2e Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 5 Oct 2019 12:53:58 -0400 Subject: [PATCH 014/531] change frozen point on dotstar and neopixel libs --- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 409e90902a..02758607e2 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 409e90902ac49720c4add985e8e1a1660bbe63a0 +Subproject commit 02758607e26bedd356a0ff004d0493b1783950dd diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index c0bdd8b103..443626b5e5 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit c0bdd8b10383725ee9293f5d88fb8d47eb1272bd +Subproject commit 443626b5e5df688a5b4cc077c4a2c4fdd8fbb49a From 000ae6bf17ca43486e5cfd261d4cb2eded4c3147 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 5 Oct 2019 13:47:40 -0400 Subject: [PATCH 015/531] support subclasses --- shared-bindings/_pixelbuf/PixelBuf.c | 40 +++++++++++++--------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 969d167099..0ad40c6209 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -26,6 +26,7 @@ #include "py/obj.h" #include "py/objarray.h" +#include "py/objtype.h" #include "py/mphal.h" #include "py/runtime.h" #include "py/binary.h" @@ -223,13 +224,20 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } + +// Helper to ensure we have the native super class instead of a subclass. +static pixelbuf_pixelbuf_obj_t* native_pixelbuf(mp_obj_t pixelbuf_obj) { + mp_obj_t native_pixelbuf = mp_instance_cast_to_native_base(pixelbuf_obj, &pixelbuf_pixelbuf_type); + mp_obj_assert_native_inited(native_pixelbuf); + return MP_OBJ_TO_PTR(native_pixelbuf); +} + //| .. attribute:: bpp //| //| The number of bytes per pixel in the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_int_from_uint(self->byteorder.bpp); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_bpp_obj, pixelbuf_pixelbuf_obj_get_bpp); @@ -252,16 +260,14 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = { //| In DotStar mode //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_float(self->brightness); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_brightness_obj, pixelbuf_pixelbuf_obj_get_brightness); STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); self->brightness = mp_obj_float_get(value); if (self->brightness > 1) self->brightness = 1; @@ -298,16 +304,14 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { //| Whether to automatically write the pixels after each update. //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_bool(self->auto_write); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_auto_write_obj, pixelbuf_pixelbuf_obj_get_auto_write); STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_auto_write(mp_obj_t self_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); self->auto_write = mp_obj_is_true(value); return mp_const_none; } @@ -328,8 +332,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = { //| actual pixels. //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_buf(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_bytearray_by_ref(self->bytes, self->buf); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_buf_obj, pixelbuf_pixelbuf_obj_get_buf); @@ -346,8 +349,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { //| byteorder string for the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_str(self->byteorder.order, strlen(self->byteorder.order)); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); @@ -360,8 +362,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { }; STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); switch (op) { case MP_UNARY_OP_BOOL: return mp_const_true; case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->pixels); @@ -375,8 +376,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); call_write_function(self); return mp_const_none; } @@ -398,15 +398,13 @@ void call_write_function(pixelbuf_pixelbuf_obj_t *self) { //| Sets the pixel value at the given index. //| STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - if (value == MP_OBJ_NULL) { // delete item // slice deletion return MP_OBJ_NULL; // op not supported } - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); if (0) { #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { From 55c688cbebc9f4eac3787591f5349c2f4c25e9e4 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 5 Oct 2019 15:53:53 -0400 Subject: [PATCH 016/531] restructure to be subclassable --- shared-bindings/_pixelbuf/PixelBuf.c | 63 +++++++--------------------- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- 2 files changed, 15 insertions(+), 50 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 0ad40c6209..cb6fe55673 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -50,7 +50,7 @@ extern const int32_t colorwheel(float pos); //| //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction. //| -//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False, write_function=None, write_args=None) +//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False) //| //| Create a PixelBuf object of the specified size, byteorder, and bits per pixel. //| @@ -69,14 +69,11 @@ extern const int32_t colorwheel(float pos); //| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) //| :param ~bool auto_write: Whether to automatically write pixels (Default False) -//| :param ~callable write_function: (optional) Callable to use to send pixels -//| :param ~list write_args: (optional) Tuple or list of args to pass to ``write_function``. The -//| PixelBuf instance is appended after these args. //| STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 2, MP_OBJ_FUN_ARGS_MAX, true); enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, - ARG_auto_write, ARG_write_function, ARG_write_args }; + ARG_auto_write }; static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_buf, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -85,8 +82,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_auto_write, MP_ARG_BOOL, {.u_bool = false} }, - { MP_QSTR_write_function, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_write_args, MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -155,13 +150,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (bytes + offset > bufinfo.len) mp_raise_ValueError_varg(translate("buf is too small. need %d bytes"), bytes + offset); - if (!MP_OBJ_IS_TYPE(args[ARG_write_args].u_obj, &mp_type_list) && - !MP_OBJ_IS_TYPE(args[ARG_write_args].u_obj, &mp_type_tuple) && - args[ARG_write_args].u_obj != mp_const_none) - { - mp_raise_ValueError(translate("write_args must be a list, tuple, or None")); - } - // Validation complete, allocate and populate object. pixelbuf_pixelbuf_obj_t *self = m_new_obj(pixelbuf_pixelbuf_obj_t); @@ -178,28 +166,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a self->pixel_step = effective_bpp; self->auto_write = args[ARG_auto_write].u_bool; - // Show/auto-write callbacks - self->write_function = args[ARG_write_function].u_obj; - mp_obj_t function_args = args[ARG_write_args].u_obj; - mp_obj_t *src_objs = (mp_obj_t *)&mp_const_none_obj; - size_t num_items = 0; - if (function_args != mp_const_none) { - if (MP_OBJ_IS_TYPE(function_args, &mp_type_list)) { - mp_obj_list_t *t = MP_OBJ_TO_PTR(function_args); - num_items = t->len; - src_objs = t->items; - } else { - mp_obj_tuple_t *l = MP_OBJ_TO_PTR(function_args); - num_items = l->len; - src_objs = l->items; - } - } - self->write_function_args = mp_obj_new_tuple(num_items + 1, NULL); - for (size_t i = 0; i < num_items; i++) { - self->write_function_args->items[i] = src_objs[i]; - } - self->write_function_args->items[num_items] = self; - if (args[ARG_brightness].u_obj == mp_const_none) { self->brightness = 1.0; } else { @@ -276,7 +242,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_write_function(self); + call_show(self_in); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -299,6 +265,14 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } +mp_obj_t call_show(mp_obj_t self_in) { + mp_obj_t dest[2]; + mp_load_method(self_in, MP_QSTR_show, dest); + if (dest[0] == MP_OBJ_NULL) + return mp_const_none; + return mp_call_method_self_n_kw(dest[0], self_in, 0, 0, mp_const_none); +} + //| .. attribute:: auto_write //| //| Whether to automatically write the pixels after each update. @@ -372,23 +346,14 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| .. method:: show() //| -//| Call the associated write function to display the pixels. +//| Does nothing unless subclassed. //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - call_write_function(self); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); -void call_write_function(pixelbuf_pixelbuf_obj_t *self) { - // execute function if it's set - if (self->write_function != mp_const_none) { - mp_call_function_n_kw(self->write_function, self->write_function_args->len, 0, self->write_function_args->items); - } -} - //| .. method:: __getitem__(index) //| //| Returns the pixel value at the given index. @@ -450,7 +415,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_write_function(self); + call_show(self_in); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -470,7 +435,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_write_function(self); + call_show(self_in); return mp_const_none; } } diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 0f5613621a..2a132dda23 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -50,6 +50,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -void call_write_function(pixelbuf_pixelbuf_obj_t *self); +mp_obj_t call_show(mp_obj_t self_in); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H From fc19e03128aeeb94a22fdff097e4d0576d768986 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 6 Oct 2019 21:30:26 -0400 Subject: [PATCH 017/531] WIP: bonding --- ports/nrf/README.md | 86 ++----------------- ports/nrf/bluetooth/ble_uart.c | 4 +- ports/nrf/boards/adafruit_nrf52840_s140_v6.ld | 1 + ports/nrf/boards/common.ld | 17 ++-- ports/nrf/mpconfigport.h | 10 --- ports/nrf/supervisor/serial.c | 10 +-- py/circuitpy_mpconfig.mk | 14 ++- supervisor/supervisor.mk | 51 +++++------ 8 files changed, 63 insertions(+), 130 deletions(-) diff --git a/ports/nrf/README.md b/ports/nrf/README.md index 5f6d037204..64f5b8aff5 100644 --- a/ports/nrf/README.md +++ b/ports/nrf/README.md @@ -2,43 +2,8 @@ This is a port of CircuitPython to the Nordic Semiconductor nRF52 series of chips. -## Supported Features - -* UART -* SPI -* LEDs -* Pins -* ADC -* I2C -* PWM -* Temperature -* RTC (Real Time Counter. Low-Power counter) -* BLE support including: - * Peripheral role - * Scanner role - * _REPL over Bluetooth LE_ (optionally using WebBluetooth) - * ubluepy: Bluetooth LE module for CircuitPython - * 1 non-connectable advertiser while in connection - -## Tested Hardware - -* nRF52840 - * [PCA10056](http://www.nordicsemi.com/eng/Products/nRF52840-Preview-DK) - -## Board Specific Instructions - -For board-specific instructions on building and flashing CircuitPython, see -the following links: - -> **NOTE**: These board specific readmes may be more up to date than the - generic board-neutral documentation further down. - -* Adafruit Feather nRF52840: `boards/feather_nrf52840_express/README.md`: 1MB Flash, 256KB SRAM -* Nordic PCA10056 (uses nRF52840): `boards/pca10056/README.md` -* MakerDiary nRF52840 MDK: `boards/makerdiary_nrf52840_mdk/README.md` -* MakerDiary nRF52840 MDK USB Dongle: `boards/makerdiary_nrf52840_mdk_usb_dongle/README.md` - -For all other board targets, see the generic notes below. +> **NOTE**: There are board-specific READMEs that may be more up to date than the + generic board-neutral documentation below. ## Compile and Flash @@ -46,41 +11,17 @@ Prerequisite steps for building the nrf port: git clone .git circuitpython cd circuitpython - git submodule update --init + git submodule update --init --recursive make -C mpy-cross +Some boards have UF2 bootloaders and can simply be flashed in the normal way, by copying +firmware.uf2 to the BOOT drive. + To build and flash issue the following command inside the ports/nrf/ folder: make BOARD=pca10056 make BOARD=pca10056 flash -## Compile and Flash with Bluetooth Stack - -First prepare the bluetooth folder by downloading Bluetooth LE stacks and headers: - - ./bluetooth/download_ble_stack.sh - -If the Bluetooth stacks has been downloaded, compile the target with the following command: - - make BOARD=pca10040 SD=s132 - -The **make sd** will trigger a flash of the bluetooth stack before that application is flashed. Note that **make sd** will perform a full erase of the chip, which could cause 3rd party bootloaders to also be wiped. - - make BOARD=pca10040 SD=s132 sd - -Note: further tuning of features to include in bluetooth or even setting up the device to use REPL over Bluetooth can be configured in the `bluetooth_conf.h`. - -## Target Boards and Make Flags - -Target Board (BOARD) | Bluetooth Stack (SD) | Bluetooth Support | Flash Util --------------------------|-------------------------|------------------------|------------------------------- -pca10056 | s140 | Peripheral and Scanner | [Segger](#segger-targets) -feather_nrf52840_express | s140 | Peripheral and Scanner | UF2 bootloader -makerdiary_nrf52840_mdk | s140 | Peripheral and Scanner | pyocd or ARM mbed DAPLink -makerdiary_nrf52840_mdk_usb_dongle | s140 | Peripheral and Scanner | DFU bootloader & nrfutil -electronut_labs_papyr | s140 | Peripheral and Scanner | UF2 bootloader -electronut_labs_blip | s140 | Peripheral and Scanner | Black Magic Probe - ## Segger Targets Install the necessary tools to flash and debug using Segger: @@ -107,22 +48,7 @@ run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Ada * dfu-gen: Generates a Firmware zip to be used by the DFU flash application. * dfu-flash: Triggers the DFU flash application to upload the firmware from the generated Firmware zip file. -Example on how to generate and flash feather_nrf52840 target: - - make BOARD=feather_nrf52840 SD=s140 - make BOARD=feather_nrf52840 SD=s140 dfu-gen dfu-flash - -## Bluetooth LE REPL - -The port also implements a BLE REPL driver. This feature is disabled by default, as it will deactivate the UART REPL when activated. As some of the nRF devices only have one UART, using the BLE REPL free's the UART instance such that it can be used as a general UART peripheral not bound to REPL. - -The configuration can be enabled by editing the `bluetooth_conf.h` and set `MICROPY_PY_BLE_NUS` to 1. When enabled you have different options to test it: * [NUS Console for Linux](https://github.com/tralamazza/nus_console) (recommended) * [WebBluetooth REPL](https://glennrub.github.io/webbluetooth/micropython/repl/) (experimental) - -Other: -* nRF UART application for IPhone/Android - -WebBluetooth mode can also be configured by editing `bluetooth_conf.h` and set `BLUETOOTH_WEBBLUETOOTH_REPL` to 1. This will alternate advertisement between Eddystone URL and regular connectable advertisement. The Eddystone URL will point the phone or PC to download [WebBluetooth REPL](https://glennrub.github.io/webbluetooth/micropython/repl/) (experimental), which subsequently can be used to connect to the Bluetooth REPL from the PC or Phone browser. diff --git a/ports/nrf/bluetooth/ble_uart.c b/ports/nrf/bluetooth/ble_uart.c index 787a2a1174..1e7a319bdd 100644 --- a/ports/nrf/bluetooth/ble_uart.c +++ b/ports/nrf/bluetooth/ble_uart.c @@ -40,7 +40,7 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" -#if (MICROPY_PY_BLE_NUS == 1) +#if CIRCUITPY_SERIAL_BLE static const char default_name[] = "CP-REPL"; // max 8 chars or uuid won't fit in adv data static const char NUS_UUID[] = "6e400001-b5a3-f393-e0a9-e50e24dcca9e"; @@ -190,4 +190,4 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { } } -#endif // MICROPY_PY_BLE_NUS +#endif // CIRCUITPY_SERIAL_BLE diff --git a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld b/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld index 2587a19e34..90b8862cf0 100644 --- a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld +++ b/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld @@ -24,6 +24,7 @@ MEMORY FLASH_ISR (rx) : ORIGIN = 0x00026000, LENGTH = 0x001000 FLASH_TEXT (rx) : ORIGIN = 0x00027000, LENGTH = 0x086000 FLASH_FATFS (r) : ORIGIN = 0x000AD000, LENGTH = 0x040000 + FLASH_CONFIG (r): ORIGIN = 0x000ED000, LENGTH = 0x007000 /* 0x2000000 - RAM:ORIGIN is reserved for Softdevice */ RAM (xrw) : ORIGIN = 0x20004000, LENGTH = 0x20040000 - 0x20004000 diff --git a/ports/nrf/boards/common.ld b/ports/nrf/boards/common.ld index df81aae583..dfb355a76f 100644 --- a/ports/nrf/boards/common.ld +++ b/ports/nrf/boards/common.ld @@ -2,6 +2,10 @@ __fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); __fatfs_flash_length = LENGTH(FLASH_FATFS); +/* Flash region for configuration information (bonding info, keys, etc.) */ +__config_flash_start_addr = ORIGIN(FLASH_CONFIG); +__config_flash_length = LENGTH(FLASH_CONFIG); + /* define output sections */ SECTIONS { @@ -13,7 +17,7 @@ SECTIONS . = ALIGN(4); } >FLASH_ISR - + /* The program code and other data goes into FLASH */ .text : { @@ -28,7 +32,7 @@ SECTIONS . = ALIGN(4); _etext = .; /* define a global symbol at end of code */ } >FLASH_TEXT - + /* .ARM.extab : { @@ -42,10 +46,10 @@ SECTIONS __exidx_end = .; } >FLASH */ - + /* used by the startup to initialize data */ _sidata = .; - + /* This is the initialized data section The program executes knowing that the data is in the RAM but the loader puts the initial values in the FLASH (inidata). @@ -60,8 +64,8 @@ SECTIONS . = ALIGN(4); _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - + } >RAM + /* Uninitialized data section */ .bss : { @@ -105,4 +109,3 @@ SECTIONS .ARM.attributes 0 : { *(.ARM.attributes) } } - diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 0b755a156b..9c3d02f44d 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -38,16 +38,6 @@ #define MICROPY_PY_UBINASCII (1) #define MICROPY_PY_UJSON (1) -// TODO this is old BLE stuff -#if BLUETOOTH_SD - #define MICROPY_PY_BLEIO (1) - #define MICROPY_PY_BLE_NUS (0) -#else - #ifndef MICROPY_PY_BLEIO - #define MICROPY_PY_BLEIO (0) - #endif -#endif - // 24kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 diff --git a/ports/nrf/supervisor/serial.c b/ports/nrf/supervisor/serial.c index 6fd89eb3ea..b19e9267cc 100644 --- a/ports/nrf/supervisor/serial.c +++ b/ports/nrf/supervisor/serial.c @@ -28,15 +28,15 @@ #include "supervisor/serial.h" -#if (MICROPY_PY_BLE_NUS == 1) +#if CIRCUITPY_SERIAL_BLE #include "ble_uart.h" -#else +#elif CIRCUITPY_SERIAL_UART #include #include "nrf_gpio.h" #include "nrfx_uarte.h" #endif -#if (MICROPY_PY_BLE_NUS == 1) +#if CIRCUITPY_SERIAL_BLE void serial_init(void) { ble_uart_init(); @@ -58,7 +58,7 @@ void serial_write(const char *text) { ble_uart_stdout_tx_str(text); } -#elif !defined(NRF52840_XXAA) +#elif CIRCUITPY_SERIAL_UART uint8_t serial_received_char; nrfx_uarte_t serial_instance = NRFX_UARTE_INSTANCE(0); @@ -124,4 +124,4 @@ void serial_write_substring(const char *text, uint32_t len) { } } -#endif +#endif // CIRCUITPY_SERIAL_UART diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c5756f4880..d54e626e2f 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -23,7 +23,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. - # mpconfigboard.mk files can specify: # CIRCUITPY_FULL_BUILD = 1 (which is the default) # or @@ -284,8 +283,21 @@ CIRCUITPY_USTACK = 0 endif CFLAGS += -DCIRCUITPY_USTACK=$(CIRCUITPY_USTACK) +# Non-module conditionals ifndef CIRCUITPY_BITBANG_APA102 CIRCUITPY_BITBANG_APA102 = 0 endif CFLAGS += -DCIRCUITPY_BITBANG_APA102=$(CIRCUITPY_BITBANG_APA102) + +# REPL over BLE +ifndef CIRCUITPY_SERIAL_BLE +CIRCUITPY_SERIAL_BLE = 0 +endif +CFLAGS += -DCIRCUITPY_SERIAL_BLE=$(CIRCUITPY_SERIAL_BLE) + +# REPL over UART +ifndef CIRCUITPY_SERIAL_UART +CIRCUITPY_SERIAL_UART = 0 +endif +CFLAGS += -DCIRCUITPY_SERIAL_UART=$(CIRCUITPY_SERIAL_UART) diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index ee47be4b00..90b0e85d57 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -46,7 +46,7 @@ ifdef EXTERNAL_FLASH_DEVICES else ifeq ($(DISABLE_FILESYSTEM),1) SRC_SUPERVISOR += supervisor/stub/internal_flash.c - else + else SRC_SUPERVISOR += supervisor/internal_flash.c endif endif @@ -58,30 +58,31 @@ ifeq ($(USB),FALSE) SRC_SUPERVISOR += supervisor/serial.c endif else - SRC_SUPERVISOR += lib/tinyusb/src/common/tusb_fifo.c \ - lib/tinyusb/src/device/usbd.c \ - lib/tinyusb/src/device/usbd_control.c \ - lib/tinyusb/src/class/msc/msc_device.c \ - lib/tinyusb/src/class/cdc/cdc_device.c \ - lib/tinyusb/src/class/hid/hid_device.c \ - lib/tinyusb/src/class/midi/midi_device.c \ - lib/tinyusb/src/tusb.c \ - supervisor/shared/serial.c \ - supervisor/usb.c \ - supervisor/shared/usb/usb_desc.c \ - supervisor/shared/usb/usb.c \ - supervisor/shared/usb/usb_msc_flash.c \ - shared-bindings/usb_hid/__init__.c \ - shared-bindings/usb_hid/Device.c \ - shared-bindings/usb_midi/__init__.c \ - shared-bindings/usb_midi/PortIn.c \ - shared-bindings/usb_midi/PortOut.c \ - shared-module/usb_hid/__init__.c \ - shared-module/usb_hid/Device.c \ - shared-module/usb_midi/__init__.c \ - shared-module/usb_midi/PortIn.c \ - shared-module/usb_midi/PortOut.c \ - $(BUILD)/autogen_usb_descriptor.c + SRC_SUPERVISOR += \ + lib/tinyusb/src/common/tusb_fifo.c \ + lib/tinyusb/src/device/usbd.c \ + lib/tinyusb/src/device/usbd_control.c \ + lib/tinyusb/src/class/msc/msc_device.c \ + lib/tinyusb/src/class/cdc/cdc_device.c \ + lib/tinyusb/src/class/hid/hid_device.c \ + lib/tinyusb/src/class/midi/midi_device.c \ + lib/tinyusb/src/tusb.c \ + supervisor/shared/serial.c \ + supervisor/usb.c \ + supervisor/shared/usb/usb_desc.c \ + supervisor/shared/usb/usb.c \ + supervisor/shared/usb/usb_msc_flash.c \ + shared-bindings/usb_hid/__init__.c \ + shared-bindings/usb_hid/Device.c \ + shared-bindings/usb_midi/__init__.c \ + shared-bindings/usb_midi/PortIn.c \ + shared-bindings/usb_midi/PortOut.c \ + shared-module/usb_hid/__init__.c \ + shared-module/usb_hid/Device.c \ + shared-module/usb_midi/__init__.c \ + shared-module/usb_midi/PortIn.c \ + shared-module/usb_midi/PortOut.c \ + $(BUILD)/autogen_usb_descriptor.c CFLAGS += -DUSB_AVAILABLE endif From dc8c27d1292673f1610f6440fa0de810018995fe Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 6 Oct 2019 22:44:00 -0400 Subject: [PATCH 018/531] make dotstar byteorder constants start with P. fix small bugs. --- shared-bindings/_pixelbuf/PixelBuf.c | 46 ++++++++++------------------ shared-bindings/_pixelbuf/PixelBuf.h | 2 -- shared-bindings/_pixelbuf/__init__.c | 12 ++++---- shared-bindings/_pixelbuf/types.h | 2 +- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index cb6fe55673..3a2c88ef61 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -59,12 +59,14 @@ extern const int32_t colorwheel(float pos); //| //| When only given ``buf``, ``brightness`` applies to the next pixel assignment. //| -//| When ``D`` (dotstar mode) is present in the byteorder configuration, the -//| 4th value in a tuple/list is the individual pixel brightness (0-1). +//| When ``P`` (pwm duration) is present as the 4th character of the byteorder +//| string, the 4th value in the tuple/list for a pixel is the individual pixel +//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the +//| output buffer (``buf``). //| //| :param ~int size: Number of pixelsx //| :param ~bytearray buf: Bytearray in which to store pixel data -//| :param ~str byteorder: Byte order string (such as "BGR" or "BGRD") +//| :param ~str byteorder: Byte order string (such as "BGR" or "DBGR") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) //| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) @@ -77,7 +79,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_buf, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_byteorder, MP_ARG_OBJ, { .u_obj = mp_const_none } }, + { MP_QSTR_byteorder, MP_ARG_OBJ, { .u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_BGR) } }, { MP_QSTR_brightness, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } }, @@ -92,17 +94,13 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj)) mp_raise_TypeError(translate("byteorder is not a string")); - if (args[ARG_byteorder].u_obj == NULL) - byteorder = "BGR"; - else - byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); - + byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); if (bo_len < 3 || bo_len > 4) mp_raise_ValueError(translate("Invalid byteorder string")); - strncpy(byteorder_details.order, byteorder, sizeof(byteorder_details.order)); + byteorder_details.order = args[ARG_byteorder].u_obj; byteorder_details.bpp = bo_len; - char *dotstar = strchr(byteorder, 'D'); + char *dotstar = strchr(byteorder, 'P'); char *r = strchr(byteorder, 'R'); char *g = strchr(byteorder, 'G'); char *b = strchr(byteorder, 'B'); @@ -117,18 +115,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a byteorder_details.byteorder.b = b - byteorder; byteorder_details.byteorder.w = w ? w - byteorder : 0; // The dotstar brightness byte is always first (as it goes with the pixel start bits) - // if 'D' is found at the end, adjust byte position - // if 'D' is elsewhere, error out - if (dotstar) { - size_t dotstar_pos = dotstar - byteorder; - if (dotstar_pos == 3) { - byteorder_details.byteorder.b += 1; - byteorder_details.byteorder.g += 1; - byteorder_details.byteorder.r += 1; - byteorder_details.byteorder.w = 0; - } else if (dotstar_pos != 0) { - mp_raise_ValueError(translate("Invalid byteorder string")); - } + if (dotstar && byteorder[0] != 'P') { + mp_raise_ValueError(translate("Invalid byteorder string")); } if (byteorder_details.has_white && byteorder_details.is_dotstar) mp_raise_ValueError(translate("Invalid byteorder string")); @@ -178,7 +166,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (self->byteorder.is_dotstar) { // Initialize the buffer with the dotstar start bytes. - // Header and end must be setup by caller + // Note: Header and end must be setup by caller for (uint i = 0; i < self->pixels * 4; i += 4) { self->buf[i] = DOTSTAR_LED_START_FULL_BRIGHT; if (two_buffers) { @@ -268,9 +256,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { mp_obj_t call_show(mp_obj_t self_in) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); - if (dest[0] == MP_OBJ_NULL) - return mp_const_none; - return mp_call_method_self_n_kw(dest[0], self_in, 0, 0, mp_const_none); + return mp_call_method_n_kw(0, 0, dest); } //| .. attribute:: auto_write @@ -324,7 +310,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return mp_obj_new_str(self->byteorder.order, strlen(self->byteorder.order)); + return self->byteorder.order; } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); @@ -376,13 +362,15 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice)) + // TODO support stepping!!! mp_raise_NotImplementedError(translate("Only slices with step=1 (aka None) are supported")); if ((slice.stop * self->pixel_step) > self->bytes) mp_raise_IndexError(translate("Range out of bounds")); if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; - return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); + uint8_t *readbuf = self->two_buffers ? self->rawbuf : self->buf; + return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); } else { // Set #if MICROPY_PY_ARRAY_SLICE_ASSIGN diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 2a132dda23..aa09e92613 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -44,8 +44,6 @@ typedef struct { size_t offset; uint8_t *rawbuf; uint8_t *buf; - mp_obj_t write_function; - mp_obj_tuple_t *write_function_args; bool auto_write; } pixelbuf_pixelbuf_obj_t; diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 02d5f49b35..e5cb652672 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -97,12 +97,12 @@ STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_QSTR(MP_QSTR_GBRW) }, { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_QSTR(MP_QSTR_BRGW) }, { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_QSTR(MP_QSTR_BGRW) }, - { MP_ROM_QSTR(MP_QSTR_RGBD), MP_ROM_QSTR(MP_QSTR_RGBD) }, - { MP_ROM_QSTR(MP_QSTR_RBGD), MP_ROM_QSTR(MP_QSTR_RBGD) }, - { MP_ROM_QSTR(MP_QSTR_GRBD), MP_ROM_QSTR(MP_QSTR_GRBD) }, - { MP_ROM_QSTR(MP_QSTR_GBRD), MP_ROM_QSTR(MP_QSTR_GBRD) }, - { MP_ROM_QSTR(MP_QSTR_BRGD), MP_ROM_QSTR(MP_QSTR_BRGD) }, - { MP_ROM_QSTR(MP_QSTR_BGRD), MP_ROM_QSTR(MP_QSTR_BGRD) }, + { MP_ROM_QSTR(MP_QSTR_PRGB), MP_ROM_QSTR(MP_QSTR_PRGB) }, + { MP_ROM_QSTR(MP_QSTR_PRBG), MP_ROM_QSTR(MP_QSTR_PRBG) }, + { MP_ROM_QSTR(MP_QSTR_PGRB), MP_ROM_QSTR(MP_QSTR_PGRB) }, + { MP_ROM_QSTR(MP_QSTR_PGBR), MP_ROM_QSTR(MP_QSTR_PGBR) }, + { MP_ROM_QSTR(MP_QSTR_PBRG), MP_ROM_QSTR(MP_QSTR_PBRG) }, + { MP_ROM_QSTR(MP_QSTR_PBGR), MP_ROM_QSTR(MP_QSTR_PBGR) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, }; diff --git a/shared-bindings/_pixelbuf/types.h b/shared-bindings/_pixelbuf/types.h index 39e49935fa..f7dc1a1092 100644 --- a/shared-bindings/_pixelbuf/types.h +++ b/shared-bindings/_pixelbuf/types.h @@ -41,7 +41,7 @@ typedef struct { pixelbuf_rgbw_t byteorder; bool has_white; bool is_dotstar; - char order[5]; + mp_obj_t *order; } pixelbuf_byteorder_details_t; #endif // CIRCUITPYTHON_PIXELBUF_TYPES_H From 137a4f8a5d21f5e37277031887a3908e6c4e371e Mon Sep 17 00:00:00 2001 From: Chris Osterwood Date: Mon, 7 Oct 2019 14:50:39 -0400 Subject: [PATCH 019/531] Added new flash SKU for production hardware --- ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk index 97c8eb8632..8d57c9ccc3 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk +++ b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk @@ -8,8 +8,8 @@ CHIP_VARIANT = SAMD51G19A CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = GD25Q16C +EXTERNAL_FLASH_DEVICE_COUNT = 2 +EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JV_IQ" LONGINT_IMPL = MPZ # No I2S on SAMD51G From 2970680e6af663200b35227bfbca5240542a4c47 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 20 Oct 2019 19:54:25 -0400 Subject: [PATCH 020/531] fix show and fix step > 1 --- py/obj.c | 9 ++++++-- py/objtype.c | 3 ++- shared-bindings/_pixelbuf/PixelBuf.c | 31 +++++++++++++++++----------- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- shared-module/_pixelbuf/PixelBuf.c | 7 +++++-- shared-module/_pixelbuf/PixelBuf.h | 2 +- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/py/obj.c b/py/obj.c index bd2aaf9d26..f91b00a648 100644 --- a/py/obj.c +++ b/py/obj.c @@ -489,14 +489,19 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(base); + mp_obj_t instance = base; + // If we got an MP_OBJ_SENTINEL as the type, then we got called by instance_subscr + if (type == MP_OBJ_SENTINEL) { + instance = ((mp_obj_t *)base)[1]; + type = mp_obj_get_type(((mp_obj_t *)base)[2]); + } if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(base, index, value); + mp_obj_t ret = type->subscr(instance, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); if (ret != MP_OBJ_NULL) { return ret; } - // TODO: call base classes here? } if (value == MP_OBJ_NULL) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { diff --git a/py/objtype.c b/py/objtype.c index 5133d849fc..7d41b86560 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -850,7 +850,8 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value meth_args = 3; } if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr(self->subobj[0], index, value); + mp_obj_t args[3] = {MP_OBJ_SENTINEL, self_in, self->subobj[0]}; + return mp_obj_subscr(args, index, value); } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 3a2c88ef61..aeed6f5043 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -230,7 +230,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_show(self_in); + call_show(self_in, 'b'); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -253,7 +253,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } -mp_obj_t call_show(mp_obj_t self_in) { +mp_obj_t call_show(mp_obj_t self_in, char origin) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); return mp_call_method_n_kw(0, 0, dest); @@ -356,29 +356,35 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + if (0) { #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; - if (!mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice)) - // TODO support stepping!!! - mp_raise_NotImplementedError(translate("Only slices with step=1 (aka None) are supported")); + mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice); + if ((slice.stop * self->pixel_step) > self->bytes) mp_raise_IndexError(translate("Range out of bounds")); + if (slice.step < 0) + mp_raise_IndexError(translate("Negative step not supported")); if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; uint8_t *readbuf = self->two_buffers ? self->rawbuf : self->buf; - return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); + return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, slice.step, self->byteorder.is_dotstar); } else { // Set #if MICROPY_PY_ARRAY_SLICE_ASSIGN if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) mp_raise_ValueError(translate("tuple/list required on RHS")); - size_t dst_len = slice.stop - slice.start; - + size_t dst_len = (slice.stop - slice.start); + dst_len = (slice.stop - slice.start) / slice.step; + if (slice.step > 1) { + if ((slice.stop - slice.start) % slice.step) + dst_len ++; + } mp_obj_t *src_objs; size_t num_items; if (MP_OBJ_IS_TYPE(value, &mp_type_list)) { @@ -394,16 +400,17 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp mp_raise_ValueError_varg(translate("Unmatched number of items on RHS (expected %d, got %d)."), dst_len, num_items); - for (size_t i = slice.start; i < slice.stop; i++) { + size_t target_i = slice.start; + for (size_t i = slice.start; target_i < slice.stop; i++, target_i += slice.step) { mp_obj_t *item = src_objs[i-slice.start]; if (MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple) || MP_OBJ_IS_INT(value)) { - pixelbuf_set_pixel(self->buf + (i * self->pixel_step), + pixelbuf_set_pixel(self->buf + (target_i * self->pixel_step), self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL, self->brightness, item, &self->byteorder, self->byteorder.is_dotstar); } } if (self->auto_write) - call_show(self_in); + call_show(self_in, 's'); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -423,7 +430,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(self_in); + call_show(self_in, 'i'); return mp_const_none; } } diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index aa09e92613..18caa9219a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -48,6 +48,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -mp_obj_t call_show(mp_obj_t self_in); +mp_obj_t call_show(mp_obj_t self_in, char origin); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index e26f05ac3a..a0071903a9 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -94,10 +94,13 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ } } -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar) { +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar) { mp_obj_t elems[len]; + if (slice_step > 1) { + len = len / slice_step; + } for (uint i = 0; i < len; i++) { - elems[i] = pixelbuf_get_pixel(buf + (i * step), byteorder, dotstar); + elems[i] = pixelbuf_get_pixel(buf + ((i * slice_step) * step), byteorder, dotstar); } return mp_obj_new_tuple(len, elems); } diff --git a/shared-module/_pixelbuf/PixelBuf.h b/shared-module/_pixelbuf/PixelBuf.h index 6b3272e193..173ce61a83 100644 --- a/shared-module/_pixelbuf/PixelBuf.h +++ b/shared-module/_pixelbuf/PixelBuf.h @@ -44,7 +44,7 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar); mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar); +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar); void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder); #endif From 7b79ac37399927070e1931022f5759393202ed3d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 20 Oct 2019 23:50:12 -0400 Subject: [PATCH 021/531] Parameterize linker script --- main.c | 2 +- ports/atmel-samd/Makefile | 22 ++++- .../boards/arduino_mkr1300/mpconfigboard.h | 4 - .../boards/arduino_mkr1300/mpconfigboard.mk | 1 - .../boards/arduino_mkrzero/mpconfigboard.h | 4 - .../boards/arduino_mkrzero/mpconfigboard.mk | 1 - .../boards/arduino_zero/mpconfigboard.h | 4 - .../boards/arduino_zero/mpconfigboard.mk | 1 - .../boards/bast_pro_mini_m0/mpconfigboard.h | 3 +- .../boards/bast_pro_mini_m0/mpconfigboard.mk | 1 - .../capablerobot_usbhub/mpconfigboard.h | 9 -- .../capablerobot_usbhub/mpconfigboard.mk | 1 - .../boards/catwan_usbstick/mpconfigboard.h | 4 - .../boards/catwan_usbstick/mpconfigboard.mk | 1 - .../circuitplayground_express/mpconfigboard.h | 6 -- .../mpconfigboard.mk | 1 - .../mpconfigboard.h | 6 -- .../mpconfigboard.mk | 1 - .../mpconfigboard.h | 6 -- .../mpconfigboard.mk | 1 - ports/atmel-samd/boards/common.template.ld | 89 +++++++++++++++++++ .../atmel-samd/boards/cp32-m4/mpconfigboard.h | 8 -- .../boards/cp32-m4/mpconfigboard.mk | 1 - .../boards/datalore_ip_m4/mpconfigboard.h | 8 -- .../boards/datalore_ip_m4/mpconfigboard.mk | 1 - .../boards/datum_distance/mpconfigboard.h | 4 - .../boards/datum_distance/mpconfigboard.mk | 1 - .../boards/datum_imu/mpconfigboard.h | 4 - .../boards/datum_imu/mpconfigboard.mk | 1 - .../boards/datum_light/mpconfigboard.h | 4 - .../boards/datum_light/mpconfigboard.mk | 1 - .../boards/datum_weather/mpconfigboard.h | 4 - .../boards/datum_weather/mpconfigboard.mk | 1 - .../boards/escornabot_makech/mpconfigboard.h | 6 -- .../boards/escornabot_makech/mpconfigboard.mk | 1 - .../feather_m0_adalogger/mpconfigboard.h | 4 - .../feather_m0_adalogger/mpconfigboard.mk | 1 - .../boards/feather_m0_basic/mpconfigboard.h | 4 - .../boards/feather_m0_basic/mpconfigboard.mk | 1 - .../boards/feather_m0_express/mpconfigboard.h | 7 -- .../feather_m0_express/mpconfigboard.mk | 1 - .../mpconfigboard.h | 6 -- .../mpconfigboard.mk | 1 - .../boards/feather_m0_rfm69/mpconfigboard.h | 4 - .../boards/feather_m0_rfm69/mpconfigboard.mk | 1 - .../boards/feather_m0_rfm9x/mpconfigboard.h | 4 - .../boards/feather_m0_rfm9x/mpconfigboard.mk | 1 - .../feather_m0_supersized/mpconfigboard.h | 6 -- .../feather_m0_supersized/mpconfigboard.mk | 1 - .../boards/feather_m4_express/mpconfigboard.h | 8 -- .../feather_m4_express/mpconfigboard.mk | 1 - .../feather_radiofruit_zigbee/mpconfigboard.h | 6 -- .../mpconfigboard.mk | 1 - .../boards/gemma_m0/mpconfigboard.h | 4 - .../boards/gemma_m0/mpconfigboard.mk | 1 - .../grandcentral_m4_express/mpconfigboard.h | 8 -- .../grandcentral_m4_express/mpconfigboard.mk | 1 - .../hallowing_m0_express/mpconfigboard.h | 6 -- .../hallowing_m0_express/mpconfigboard.mk | 1 - .../hallowing_m4_express/mpconfigboard.h | 8 -- .../hallowing_m4_express/mpconfigboard.mk | 1 - .../itsybitsy_m0_express/mpconfigboard.h | 6 -- .../itsybitsy_m0_express/mpconfigboard.mk | 2 - .../itsybitsy_m4_express/mpconfigboard.h | 8 -- .../itsybitsy_m4_express/mpconfigboard.mk | 1 - .../boards/kicksat-sprite/mpconfigboard.h | 2 - .../boards/kicksat-sprite/mpconfigboard.mk | 1 - .../boards/meowmeow/mpconfigboard.h | 6 -- .../boards/meowmeow/mpconfigboard.mk | 1 - .../boards/metro_m0_express/mpconfigboard.h | 6 -- .../boards/metro_m0_express/mpconfigboard.mk | 1 - .../metro_m4_airlift_lite/mpconfigboard.h | 8 -- .../metro_m4_airlift_lite/mpconfigboard.mk | 1 - .../boards/metro_m4_express/mpconfigboard.h | 8 -- .../boards/metro_m4_express/mpconfigboard.mk | 1 - .../boards/mini_sam_m4/mpconfigboard.h | 8 -- .../boards/mini_sam_m4/mpconfigboard.mk | 1 - .../boards/monster_m4sk/mpconfigboard.h | 8 -- .../boards/monster_m4sk/mpconfigboard.mk | 1 - .../boards/pewpew10/mpconfigboard.h | 5 -- .../boards/pewpew10/mpconfigboard.mk | 1 - .../boards/pewpew_m4/mpconfigboard.h | 9 -- .../boards/pewpew_m4/mpconfigboard.mk | 1 - .../boards/pirkey_m0/mpconfigboard.h | 4 - .../boards/pirkey_m0/mpconfigboard.mk | 1 - .../atmel-samd/boards/pybadge/mpconfigboard.h | 8 -- .../boards/pybadge/mpconfigboard.mk | 1 - .../boards/pybadge_airlift/mpconfigboard.h | 8 -- .../boards/pybadge_airlift/mpconfigboard.mk | 1 - .../atmel-samd/boards/pygamer/mpconfigboard.h | 8 -- .../boards/pygamer/mpconfigboard.mk | 1 - .../boards/pygamer_advance/mpconfigboard.h | 8 -- .../boards/pygamer_advance/mpconfigboard.mk | 1 - .../boards/pyportal/mpconfigboard.h | 8 -- .../boards/pyportal/mpconfigboard.mk | 1 - .../boards/pyportal_titano/mpconfigboard.h | 8 -- .../boards/pyportal_titano/mpconfigboard.mk | 1 - .../atmel-samd/boards/pyruler/mpconfigboard.h | 4 - .../boards/pyruler/mpconfigboard.mk | 1 - .../boards/robohatmm1_m0/mpconfigboard.h | 8 -- .../boards/robohatmm1_m0/mpconfigboard.mk | 1 - .../boards/robohatmm1_m4/mpconfigboard.h | 8 -- .../boards/robohatmm1_m4/mpconfigboard.mk | 1 - ports/atmel-samd/boards/sam32/mpconfigboard.h | 5 +- .../atmel-samd/boards/sam32/mpconfigboard.mk | 1 - .../samd21x18-bootloader-crystalless.ld | 73 +-------------- ...8-bootloader-external-flash-crystalless.ld | 73 +-------------- .../samd21x18-bootloader-external-flash.ld | 73 +-------------- .../atmel-samd/boards/samd21x18-bootloader.ld | 73 +-------------- .../boards/samd21x18-external-flash.ld | 72 +-------------- ports/atmel-samd/boards/samd21x18.ld | 72 +-------------- .../samd51x18-bootloader-external-flash.ld | 73 +-------------- .../samd51x19-bootloader-external-flash.ld | 73 +-------------- .../atmel-samd/boards/samd51x19-bootloader.ld | 73 +-------------- .../samd51x20-bootloader-external-flash.ld | 73 +-------------- .../atmel-samd/boards/samd51x20-bootloader.ld | 74 +-------------- .../boards/samd51x20-external-flash.ld | 72 +-------------- ports/atmel-samd/boards/samd51x20.ld | 72 +-------------- .../boards/serpente/mpconfigboard.h | 7 -- .../boards/serpente/mpconfigboard.mk | 1 - .../boards/snekboard/mpconfigboard.h | 7 -- .../boards/snekboard/mpconfigboard.mk | 1 - .../boards/sparkfun_lumidrive/mpconfigboard.h | 4 - .../sparkfun_lumidrive/mpconfigboard.mk | 1 - .../sparkfun_redboard_turbo/mpconfigboard.h | 10 +-- .../sparkfun_redboard_turbo/mpconfigboard.mk | 1 - .../sparkfun_samd21_dev/mpconfigboard.h | 4 - .../sparkfun_samd21_dev/mpconfigboard.mk | 1 - .../sparkfun_samd21_mini/mpconfigboard.h | 4 - .../sparkfun_samd21_mini/mpconfigboard.mk | 1 - .../stringcar_m0_express/mpconfigboard.h | 7 -- .../stringcar_m0_express/mpconfigboard.mk | 2 - .../boards/trellis_m4_express/mpconfigboard.h | 8 -- .../trellis_m4_express/mpconfigboard.mk | 1 - .../boards/trinket_m0/mpconfigboard.h | 4 - .../boards/trinket_m0/mpconfigboard.mk | 2 +- .../trinket_m0_haxpress/mpconfigboard.h | 6 -- .../trinket_m0_haxpress/mpconfigboard.mk | 1 - ports/atmel-samd/boards/uchip/mpconfigboard.h | 4 +- .../atmel-samd/boards/uchip/mpconfigboard.mk | 1 - .../atmel-samd/boards/ugame10/mpconfigboard.h | 6 -- .../boards/ugame10/mpconfigboard.mk | 1 - .../common-hal/microcontroller/__init__.c | 1 - ports/atmel-samd/ld_defines.c | 14 +++ ports/atmel-samd/mpconfigport.h | 37 +++++++- ports/atmel-samd/mpconfigport.mk | 4 + ports/atmel-samd/tick.c | 2 +- ports/cxd56/tick.c | 2 +- ports/nrf/boards/adafruit_nrf52840_s140_v6.ld | 3 +- .../mpconfigboard.h | 6 -- ports/nrf/boards/common.ld | 4 + .../electronut_labs_blip/mpconfigboard.h | 6 -- .../electronut_labs_papyr/mpconfigboard.h | 6 -- .../feather_nrf52840_express/mpconfigboard.h | 6 -- .../makerdiary_nrf52840_mdk/mpconfigboard.h | 6 -- .../mpconfigboard.h | 6 -- .../metro_nrf52840_express/mpconfigboard.h | 6 -- .../nrf/boards/particle_argon/mpconfigboard.h | 6 -- .../nrf/boards/particle_boron/mpconfigboard.h | 6 -- .../nrf/boards/particle_xenon/mpconfigboard.h | 6 -- ports/nrf/boards/pca10056/mpconfigboard.h | 2 - ports/nrf/boards/pca10059/mpconfigboard.h | 2 - .../sparkfun_nrf52840_mini/mpconfigboard.h | 2 - ports/nrf/common-hal/_bleio/Adapter.c | 9 ++ .../nrf/common-hal/microcontroller/__init__.c | 5 +- ports/nrf/common-hal/nvm/ByteArray.c | 15 +--- ports/nrf/common-hal/nvm/ByteArray.h | 2 + ports/nrf/mpconfigport.h | 4 + ports/nrf/peripherals/nrf/nvm.h | 4 - ports/nrf/supervisor/internal_flash.c | 3 +- ports/nrf/tick.c | 2 +- .../boards/feather_f405/mpconfigboard.h | 3 - .../boards/pyboard_v11/mpconfigboard.h | 3 - .../stm32f411ve_discovery/mpconfigboard.h | 6 -- .../stm32f412zg_discovery/mpconfigboard.h | 4 - ports/stm32f4/tick.c | 2 +- py/circuitpy_defns.mk | 1 - py/circuitpy_mpconfig.h | 13 ++- tools/gen_ld_files.py | 47 ++++++++++ 179 files changed, 272 insertions(+), 1490 deletions(-) create mode 100644 ports/atmel-samd/boards/common.template.ld create mode 100644 ports/atmel-samd/ld_defines.c create mode 100755 tools/gen_ld_files.py diff --git a/main.c b/main.c index 6b56f5ff6f..4683bcf004 100755 --- a/main.c +++ b/main.c @@ -199,7 +199,7 @@ void cleanup_after_vm(supervisor_allocation* heap) { bool run_code_py(safe_mode_t safe_mode) { bool serial_connected_at_start = serial_connected(); - #ifdef CIRCUITPY_AUTORELOAD_DELAY_MS + #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 if (serial_connected_at_start) { serial_write("\n"); if (autoreload_is_enabled()) { diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 11e6874edd..16aed16158 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -292,12 +292,17 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) $(addprefix shared-module/, $(SRC_SHARED_MODULE)) \ $(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL)) +# There may be duplicates between SRC_COMMON_HAL_EXPANDED and SRC_SHARED_MODULE_EXPANDED, +# because a few modules have files both in common-hal/ and shared-modules/. +# Doing a $(sort ...) removes duplicates as part of sorting. +SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)) + + SRC_S = supervisor/$(CHIP_FAMILY)_cpu.s OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o)) -OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o)) -OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o)) ifeq ($(INTERNAL_LIBM),1) OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o)) endif @@ -310,9 +315,18 @@ SRC_QSTR_PREPROCESSOR += peripherals/samd/$(CHIP_FAMILY)/clocks.c all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 -$(BUILD)/firmware.elf: $(OBJ) +LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLATE_FILE))) + +# ld_defines.pp is generated from ld_defines.c. See py/mkrules.mk. +# Run gen_ld_files.py over ALL *.template.ld files, not just LD_TEMPLATE_FILE, +# because it may include other template files. +$(LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld + $(STEPECHO) "GEN $@" + $(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld + +$(BUILD)/firmware.elf: $(OBJ) $(LD_FILE) $(STEPECHO) "LINK $@" - $(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h index a508d91913..226717c83b 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h +++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h @@ -7,10 +7,6 @@ #define MICROPY_HW_LED_STATUS (&pin_PB23) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA09) #define DEFAULT_I2C_BUS_SDA (&pin_PA08) diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk index a543468e52..bd682ade07 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x2341 USB_PID = 0x8053 USB_PRODUCT = "Arduino MKR1300" diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h index 02750e6469..4871b1798b 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h +++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h @@ -5,10 +5,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA09) #define DEFAULT_I2C_BUS_SDA (&pin_PA08) diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk index 5612eb88d7..894b9b0110 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8050 USB_PRODUCT = "Arduino MKRZero" diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h index ec201e6ef5..bf2a68c57a 100644 --- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h +++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h @@ -10,10 +10,6 @@ #define MICROPY_PORT_B (PORT_PB03) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk index cbbf15a3ef..f94ec13b7c 100644 --- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x2341 USB_PID = 0x824D USB_PRODUCT = "Arduino Zero" diff --git a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h index 561240c69a..cbfb11d200 100644 --- a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h @@ -5,6 +5,7 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) +// No microcontroller.nvm #define CIRCUITPY_INTERNAL_NVM_SIZE 0 #define DEFAULT_I2C_BUS_SCL (&pin_PA08) @@ -17,8 +18,6 @@ #define DEFAULT_UART_BUS_RX (&pin_PA01) #define DEFAULT_UART_BUS_TX (&pin_PA00) -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) - #define IGNORE_PIN_PA03 1 #define IGNORE_PIN_PA12 1 #define IGNORE_PIN_PA13 1 diff --git a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk index 08e42aa4ef..c3f0750a9e 100644 --- a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x1209 USB_PID = 0xBAB3 USB_PRODUCT = "Bast Pro Mini M0" diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h index f4e40739b0..d359687e13 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h +++ b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h @@ -3,7 +3,6 @@ #define CIRCUITPY_MCU_FAMILY samd51 - #define MICROPY_HW_LED_STATUS (&pin_PA22) // These are pins not to reset. @@ -14,14 +13,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk index f390a8681a..0ff6f58eab 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk +++ b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x04D8 USB_PID = 0xEDB3 USB_PRODUCT = "Programmable USB Hub" diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h index 7a32bf023f..b92c2a65e3 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h +++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h @@ -7,14 +7,10 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - #define DEFAULT_SPI_BUS_SCK (&pin_PA19) #define DEFAULT_SPI_BUS_MOSI (&pin_PA18) #define DEFAULT_SPI_BUS_MISO (&pin_PA22) -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define IGNORE_PIN_PA00 1 #define IGNORE_PIN_PA01 1 #define IGNORE_PIN_PA02 1 diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk index 2399aad5c5..adae4beb27 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk +++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x1209 USB_PID = 0xBAB2 USB_PRODUCT = "CatWAN USBStick" diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h index e6a7e06769..0ed5262ab5 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h @@ -22,12 +22,6 @@ #define SPEAKER_ENABLE_PIN (&pin_PA30) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk index 3c43776f5b..cdbdf44f80 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x8019 USB_PRODUCT = "CircuitPlayground Express" diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index ca6f9b7734..2db5129291 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -22,12 +22,6 @@ #define SPEAKER_ENABLE_PIN (&pin_PA30) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index f456515f9a..a6ed28aa71 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x8019 USB_PRODUCT = "CircuitPlayground Express with Crickit libraries" diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index 333fc79f9b..a1d5b0a671 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -22,12 +22,6 @@ #define SPEAKER_ENABLE_PIN (&pin_PA30) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index f0c9c6b8c4..b5a7c2424d 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x8019 USB_PRODUCT = "CircuitPlayground Express with displayio" diff --git a/ports/atmel-samd/boards/common.template.ld b/ports/atmel-samd/boards/common.template.ld new file mode 100644 index 0000000000..e02bbfab02 --- /dev/null +++ b/ports/atmel-samd/boards/common.template.ld @@ -0,0 +1,89 @@ +/* Template for SAMD21/SAMD51 linking. dollar-sign-curly-bracket items are replaced with strings. */ + +/* Specify the memory areas */ +MEMORY +{ + /* CIRCUITPY_BOOTLOADER_SIZE is size of bootloader, if any. + * SAMD21 Arduino and UF2 bootloaders are 8KiB. SAMD51 UF2 is 6KiB. + * FLASH_SIZE is defined in ASF4. + * RAM_SIZE is defined in mpconfigport.h, from constants from ASF4. + * CIRCUITPY_INTERNAL_CONFIG_SIZE is size of an optional hidden config area, used currently + * for crystalless USB timing calibration. + * CIRCUITPY_INTERNAL_NVM_SIZE is the size of microntroller.nvm. + */ + FLASH (rx) : ORIGIN = 0x00000000 + ${BOOTLOADER_SIZE}, LENGTH = ${FLASH_SIZE} - ${BOOTLOADER_SIZE} - ${CIRCUITPY_INTERNAL_CONFIG_SIZE} - ${CIRCUITPY_INTERNAL_NVM_SIZE} + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE} +} + +/* top end of the stack */ +/* stack must be double-word (8 byte) aligned */ +_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; +_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; + +/* define output sections */ +SECTIONS +{ + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + _sfixed = .; + KEEP(*(.vectors)) /* isr vector table */ + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + + . = ALIGN(4); + } >FLASH + + .ARM.exidx : + { + *(.ARM.exidx*) + *(.gnu.linkonce.armexidx.*) + _etext = .; /* define a global symbol at end of code */ + _sidata = .; /* start of .data section */ + } > FLASH + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : AT ( _sidata ) + { + . = ALIGN(4); + _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */ + *(.ramfunc) + *(.ramfunc*) + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */ + } >RAM + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + _sbss = .; + _szero = .; /* define a global symbol at bss start; used by startup code */ + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ezero = .; /* define a global symbol at bss end; used by startup code */ + _ebss = .; + } >RAM + + /* this just checks there is enough RAM for the requested stack. */ + .stack : + { + . = ALIGN(4); + . = . + ${CIRCUITPY_DEFAULT_STACK_SIZE}; + . = ALIGN(4); + } >RAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h index 9e329b3ed9..8664a6a0ec 100644 --- a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h @@ -12,14 +12,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PB09) #define DEFAULT_I2C_BUS_SDA (&pin_PB08) diff --git a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk index 86a7719b84..25ec501627 100644 --- a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x20-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8021 USB_PRODUCT = "CP32-M4" diff --git a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h index 99167d31bc..f560cfa493 100644 --- a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h @@ -20,14 +20,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) diff --git a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk index aa5f47d400..b2823e30c3 100644 --- a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x4097 USB_PID = 0x0001 USB_PRODUCT = "Datalore IP M4" diff --git a/ports/atmel-samd/boards/datum_distance/mpconfigboard.h b/ports/atmel-samd/boards/datum_distance/mpconfigboard.h index e02e437805..74706ba040 100644 --- a/ports/atmel-samd/boards/datum_distance/mpconfigboard.h +++ b/ports/atmel-samd/boards/datum_distance/mpconfigboard.h @@ -10,10 +10,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk index a7bb8293d4..4f6c7ab82e 100644 --- a/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x04D8 USB_PID = 0xEE8C USB_PRODUCT = "datum-Distance" diff --git a/ports/atmel-samd/boards/datum_imu/mpconfigboard.h b/ports/atmel-samd/boards/datum_imu/mpconfigboard.h index b87739dd0e..3cc218f9e0 100644 --- a/ports/atmel-samd/boards/datum_imu/mpconfigboard.h +++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.h @@ -10,10 +10,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk index 507c83b041..336a1b832f 100644 --- a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x04D8 USB_PID = 0xEE8D USB_PRODUCT = "datum-IMU" diff --git a/ports/atmel-samd/boards/datum_light/mpconfigboard.h b/ports/atmel-samd/boards/datum_light/mpconfigboard.h index 2a91c112dd..33e80d06d0 100644 --- a/ports/atmel-samd/boards/datum_light/mpconfigboard.h +++ b/ports/atmel-samd/boards/datum_light/mpconfigboard.h @@ -10,10 +10,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/datum_light/mpconfigboard.mk b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk index 4bb227ba4e..7ec2efcf96 100644 --- a/ports/atmel-samd/boards/datum_light/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x04D8 USB_PID = 0xEE8E USB_PRODUCT = "datum-Light" diff --git a/ports/atmel-samd/boards/datum_weather/mpconfigboard.h b/ports/atmel-samd/boards/datum_weather/mpconfigboard.h index 45619197b9..328a6860c4 100644 --- a/ports/atmel-samd/boards/datum_weather/mpconfigboard.h +++ b/ports/atmel-samd/boards/datum_weather/mpconfigboard.h @@ -10,10 +10,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk index 411aee6254..d3ec1b0fdd 100644 --- a/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x04D8 USB_PID = 0xEE8F USB_PRODUCT = "datum-Weather" diff --git a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h index f27cb533b2..3a984188fa 100644 --- a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h +++ b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h @@ -8,12 +8,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. diff --git a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk index a2c182e683..dedd49ff71 100644 --- a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk +++ b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x1209 USB_PID = 0xBAB6 USB_PRODUCT = "Escornabot Makech" diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h index eb1b905851..a0fde67ef6 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h @@ -8,10 +8,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA22) #define DEFAULT_I2C_BUS_SDA (&pin_PA23) diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk index a88dbd563e..134abf7236 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8015 USB_PRODUCT = "Feather M0 Adalogger" diff --git a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h index a16cee0b4c..41a4bde212 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h @@ -8,10 +8,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk index 076f1f8ff0..3643743509 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8015 USB_PRODUCT = "Feather M0" diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h index e6cd1c729b..5421dc8890 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h @@ -15,13 +15,6 @@ #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PA23) diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk index 5b89f1be4f..cdee7b7946 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8023 USB_PRODUCT = "Feather M0 Express" diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h index 77146889e5..ee61e1d87d 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h @@ -15,12 +15,6 @@ #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PA23) diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk index 5793d82e55..d5e03b49d4 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8023 USB_PRODUCT = "Feather M0 Express" diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h index 19a5147587..2a319a4129 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h @@ -8,10 +8,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk index 83d794d047..40a461b279 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8015 USB_PRODUCT = "Feather M0 RFM69" diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h index d3db098e54..850033dbe4 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h @@ -8,10 +8,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk index a84e14f55f..736161047a 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8015 USB_PRODUCT = "Feather M0 RFM9x" diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h index 5ad265bf14..2d9f88e2e1 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h @@ -17,12 +17,6 @@ #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk index c5fef4373c..cb13adb76d 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8023 USB_PRODUCT = "Feather M0 Supersized" diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h index f65ea8db78..ba16d17ee4 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h @@ -16,14 +16,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define EXTERNAL_FLASH_QSPI_DUAL #define BOARD_HAS_CRYSTAL 1 diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk index 176ebac82c..d736941df3 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8026 USB_PRODUCT = "Feather M4 Express" diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h index 7df31f3a93..2afe358178 100755 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h @@ -14,12 +14,6 @@ #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PA13) diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk index c4a3a5a19e..05c305b1a2 100755 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8023 USB_PRODUCT = "Feather RadioFruit Zigbee" diff --git a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h index 5f09ab4d2f..b6d8f946bc 100644 --- a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h @@ -10,16 +10,12 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - #define DEFAULT_I2C_BUS_SCL (&pin_PA05) #define DEFAULT_I2C_BUS_SDA (&pin_PA04) #define DEFAULT_UART_BUS_RX (&pin_PA05) #define DEFAULT_UART_BUS_TX (&pin_PA04) -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define IGNORE_PIN_PA03 1 #define IGNORE_PIN_PA06 1 #define IGNORE_PIN_PA07 1 diff --git a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk index 6f44a22f84..d649386328 100644 --- a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x801D USB_PRODUCT = "Gemma M0" diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h index bc8f5a134a..bab0550148 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h @@ -21,14 +21,6 @@ #define MICROPY_PORT_C ( PORT_PC24 | PORT_PC30 | PORT_PC31 ) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB21) diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk index 423761c3f7..49331a705d 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x20-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8032 USB_PRODUCT = "Grand Central M4 Express" diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h index d5c2745009..e5ac346daf 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h @@ -16,12 +16,6 @@ #define MICROPY_PORT_B ( PORT_PB22 | PORT_PB23 ) #define MICROPY_PORT_C ( 0 ) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA17) #define DEFAULT_I2C_BUS_SDA (&pin_PA16) diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index 988d10d1cd..af4a5a2932 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0xD1ED USB_PRODUCT = "HalloWing M0 Express" diff --git a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h index 654632db5d..a0c726e726 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h @@ -16,14 +16,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk index 0d891abc82..9379ed3fe0 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x804A USB_PRODUCT = "Hallowing M4 Express" diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h index 6f9f661d94..db5e2a4df2 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h @@ -16,12 +16,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk index 2b64e90275..4d516c75b6 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x8012 USB_PRODUCT = "ItsyBitsy M0 Express" @@ -21,4 +20,3 @@ CIRCUITPY_RTC = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 - diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h index 9e4d4a10c9..98920b54f2 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h @@ -17,14 +17,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk index 5cab5bf43a..7ce45d0a1a 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x802C USB_PRODUCT = "ItsyBitsy M4 Express" diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h index 194542b055..6664524d24 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h @@ -14,8 +14,6 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE 0 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - 0x010000) - #define DEFAULT_I2C_BUS_SCL (&pin_PA17) #define DEFAULT_I2C_BUS_SDA (&pin_PA16) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index 706e551c5d..6d6571a2ae 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader.ld USB_VID = 0x04D8 USB_PID = 0xED94 USB_PRODUCT = "kicksat-sprite" diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h index 1304b6dfbf..80d3678630 100644 --- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h @@ -8,12 +8,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk index 894e19a6bb..4b452ecbfe 100644 --- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x1209 USB_PID = 0xBAB1 USB_PRODUCT = "Meow Meow" diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h index bfa254b95e..04565feb40 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h @@ -21,12 +21,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PA23) diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk index d3f35ba8b0..b52b1343fb 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8014 USB_PRODUCT = "Metro M0 Express" diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h index e89b0322a1..9fa4018046 100644 --- a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h +++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h @@ -18,14 +18,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk index 98d85ba826..78e27b422f 100644 --- a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8038 USB_PRODUCT = "Metro M4 Airlift Lite" diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h index 2a8878874d..7f8dbb1d2b 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h @@ -20,14 +20,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk index 68b6f64065..4f01f3edd1 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8021 USB_PRODUCT = "Metro M4 Express" diff --git a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h index c4563964f8..08ab7e16b9 100644 --- a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h @@ -17,14 +17,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk index 4bd1d6e522..eedfd2ecca 100644 --- a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x1209 USB_PID = 0x2017 USB_PRODUCT = "Mini SAM M4" diff --git a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h index fc77520f5f..42fb4548e0 100644 --- a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h +++ b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h @@ -13,14 +13,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA01) #define DEFAULT_I2C_BUS_SDA (&pin_PA00) diff --git a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk index a3db7dc890..e61f3d2403 100644 --- a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk +++ b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8048 USB_PRODUCT = "Monster M4SK" diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h index 445ccc4355..6b3b4aa15c 100644 --- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h @@ -5,11 +5,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - - #define IGNORE_PIN_PB00 1 #define IGNORE_PIN_PB01 1 #define IGNORE_PIN_PB02 1 diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk index e24a290519..c9aa26e3c8 100644 --- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x801D USB_PRODUCT = "PewPew 10.2" diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h index 1b3035e120..60cd8d754f 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h @@ -9,14 +9,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA01) #define DEFAULT_I2C_BUS_SDA (&pin_PA00) @@ -48,4 +40,3 @@ #define IGNORE_PIN_PB09 1 #define IGNORE_PIN_PB10 1 #define IGNORE_PIN_PB11 1 - diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 54ec3d1d0e..af7e3fb16c 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader.ld USB_VID = 0x1d50 USB_PID = 0x60e8 USB_PRODUCT = "PewPew M4" diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h index 5a8eb9d147..866e21991b 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h @@ -8,10 +8,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define IGNORE_PIN_PA02 1 #define IGNORE_PIN_PA03 1 #define IGNORE_PIN_PA04 1 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index 686c9099fc..c5b2c9eb58 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8028 USB_PRODUCT = "pIRKey M0" diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.h b/ports/atmel-samd/boards/pybadge/mpconfigboard.h index 36115bc873..435185322a 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.h +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.h @@ -14,14 +14,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk index 7e2cb64398..05df09627c 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8034 USB_PRODUCT = "PyBadge" diff --git a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h index ade74786d3..229cfa3354 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h +++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h @@ -14,14 +14,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk index 7e77b0feaf..242722870a 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8043 USB_PRODUCT = "PyBadge AirLift" diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.h b/ports/atmel-samd/boards/pygamer/mpconfigboard.h index 4720b22eb1..102c259567 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.h +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.h @@ -13,14 +13,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk index 0fce468d9f..70109e332e 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x803E USB_PRODUCT = "PyGamer" diff --git a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h index c05aa4f062..fbe946b72f 100644 --- a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h +++ b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h @@ -13,14 +13,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk index 8711738d4f..7f3207ecd0 100644 --- a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x803E USB_PRODUCT = "PyGamer Advance" diff --git a/ports/atmel-samd/boards/pyportal/mpconfigboard.h b/ports/atmel-samd/boards/pyportal/mpconfigboard.h index 43346488ba..2c4cf4f580 100644 --- a/ports/atmel-samd/boards/pyportal/mpconfigboard.h +++ b/ports/atmel-samd/boards/pyportal/mpconfigboard.h @@ -17,14 +17,6 @@ #define MICROPY_PORT_C ( 0 ) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk index f763c74fa4..149141a4e3 100644 --- a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x20-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8036 USB_PRODUCT = "PyPortal" diff --git a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h index 91c1188108..c463b56616 100644 --- a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h +++ b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h @@ -16,14 +16,6 @@ #define MICROPY_PORT_C ( 0 ) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk index 58b363779c..dbc2d5ae99 100644 --- a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x20-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8054 USB_PRODUCT = "PyPortal Titano" diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.h b/ports/atmel-samd/boards/pyruler/mpconfigboard.h index 171873b47c..4d0586d912 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.h +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.h @@ -10,10 +10,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define IGNORE_PIN_PA12 1 #define IGNORE_PIN_PA13 1 #define IGNORE_PIN_PA16 1 diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk index 9663944a38..220e48872a 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x804C USB_PRODUCT = "PyRuler" diff --git a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h index c6856c68f8..68991f9974 100644 --- a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h @@ -17,13 +17,6 @@ #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define CALIBRATE_CRYSTALLESS 1 #define DEFAULT_I2C_BUS_SCL (&pin_PA23) @@ -39,4 +32,3 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - diff --git a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk index e703fbfb9f..29cca569e6 100644 --- a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x1209 USB_PID = 0x4D43 USB_PRODUCT = "Robo HAT MM1 M0" diff --git a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h index 64040a6586..c66873aeb2 100644 --- a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h @@ -21,14 +21,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk index 56f1617dbf..b2ea18e5f2 100644 --- a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x1209 USB_PID = 0x4D43 USB_PRODUCT = "Robo HAT MM1 M4" diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.h b/ports/atmel-samd/boards/sam32/mpconfigboard.h index f6d3fb6b46..3c6f52ebcc 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.h +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.h @@ -11,12 +11,9 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - +// No microcontroller.nvm #define CIRCUITPY_INTERNAL_NVM_SIZE 0 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - 0x010000) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PA04) diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.mk b/ports/atmel-samd/boards/sam32/mpconfigboard.mk index 12884a9cc8..0d6be64374 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x20-bootloader.ld USB_VID = 0x04D8 USB_PID = 0xEDBE USB_PRODUCT = "SAM32" diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld b/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld index 2adf4fa909..1ee745eb17 100644 --- a/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld +++ b/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld @@ -10,75 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 2K; /* Reserve a minimum of 2K for the stack. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld index bddaae99da..d8f4cc2365 100644 --- a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld +++ b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld @@ -10,75 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 2K; /* Reserve a minimum of 2K for the stack. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld index 4e677a079f..f663326d69 100644 --- a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld +++ b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld @@ -10,75 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K /* 32 KiB RAM */ } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _etext ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 2K; /* Reserve a minimum of 2K for the stack. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-bootloader.ld b/ports/atmel-samd/boards/samd21x18-bootloader.ld index 2ef09ba9af..666ac79c47 100644 --- a/ports/atmel-samd/boards/samd21x18-bootloader.ld +++ b/ports/atmel-samd/boards/samd21x18-bootloader.ld @@ -11,75 +11,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 2K; /* Reserve a minimum of 2K for the stack. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-external-flash.ld b/ports/atmel-samd/boards/samd21x18-external-flash.ld index a540bfde2a..6afdab7345 100644 --- a/ports/atmel-samd/boards/samd21x18-external-flash.ld +++ b/ports/atmel-samd/boards/samd21x18-external-flash.ld @@ -10,74 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K } -/* top end of the stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); -_bootloader_dbl_tap = 0; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 2K; /* Reserve a minimum of 2K for the stack. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18.ld b/ports/atmel-samd/boards/samd21x18.ld index 139be86bb2..c035f5117e 100644 --- a/ports/atmel-samd/boards/samd21x18.ld +++ b/ports/atmel-samd/boards/samd21x18.ld @@ -10,74 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K } -/* top end of the stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); -_bootloader_dbl_tap = 0; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - -/* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 2K; /* Reserve a minimum of 2K for the stack. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld index c0e812ce19..b22bef3f3a 100644 --- a/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld +++ b/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld @@ -10,75 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld index 253a764c9b..f1493f2510 100644 --- a/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld +++ b/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld @@ -10,75 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x19-bootloader.ld b/ports/atmel-samd/boards/samd51x19-bootloader.ld index 56786a37af..c73db2ece9 100644 --- a/ports/atmel-samd/boards/samd51x19-bootloader.ld +++ b/ports/atmel-samd/boards/samd51x19-bootloader.ld @@ -10,75 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld index 598915b1b7..ee28fdf1cc 100644 --- a/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld +++ b/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld @@ -10,75 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K } -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20-bootloader.ld b/ports/atmel-samd/boards/samd51x20-bootloader.ld index 49d4d87914..ea0e0569f5 100644 --- a/ports/atmel-samd/boards/samd51x20-bootloader.ld +++ b/ports/atmel-samd/boards/samd51x20-bootloader.ld @@ -9,76 +9,4 @@ MEMORY FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 1M - 16K - 512K - 8K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K } - -/* top end of the stack */ -/* stack must be double-word (8 byte) aligned */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - 8; -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20-external-flash.ld b/ports/atmel-samd/boards/samd51x20-external-flash.ld index d3ed90476e..5212363fe1 100644 --- a/ports/atmel-samd/boards/samd51x20-external-flash.ld +++ b/ports/atmel-samd/boards/samd51x20-external-flash.ld @@ -9,74 +9,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K } -/* top end of the stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); -_bootloader_dbl_tap = 0; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20.ld b/ports/atmel-samd/boards/samd51x20.ld index e203c5b7a9..1f0b661720 100644 --- a/ports/atmel-samd/boards/samd51x20.ld +++ b/ports/atmel-samd/boards/samd51x20.ld @@ -10,74 +10,4 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K } -/* top end of the stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); -_bootloader_dbl_tap = 0; - -/* define output sections */ -SECTIONS -{ - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - _sfixed = .; - KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - - . = ALIGN(4); - } >FLASH - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - _sidata = .; /* start of .data section */ - } > FLASH - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - *(.ramfunc) - *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; - _szero = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ezero = .; /* define a global symbol at bss end; used by startup code */ - _ebss = .; - } >RAM - - /* this just checks there is enough RAM for a minimal stack */ - .stack : - { - . = ALIGN(4); - . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */ - . = ALIGN(4); - } >RAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} +INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/serpente/mpconfigboard.h b/ports/atmel-samd/boards/serpente/mpconfigboard.h index 034e1f6c37..515bc14410 100644 --- a/ports/atmel-samd/boards/serpente/mpconfigboard.h +++ b/ports/atmel-samd/boards/serpente/mpconfigboard.h @@ -13,12 +13,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA09) #define DEFAULT_I2C_BUS_SDA (&pin_PA08) @@ -36,4 +30,3 @@ // Not connected #define IGNORE_PIN_PA13 1 #define IGNORE_PIN_PA28 1 - diff --git a/ports/atmel-samd/boards/serpente/mpconfigboard.mk b/ports/atmel-samd/boards/serpente/mpconfigboard.mk index 98e1e37297..a5adb17a1e 100644 --- a/ports/atmel-samd/boards/serpente/mpconfigboard.mk +++ b/ports/atmel-samd/boards/serpente/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x8058 USB_PRODUCT = "Serpente" diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.h b/ports/atmel-samd/boards/snekboard/mpconfigboard.h index a349143d91..1c0804fe72 100644 --- a/ports/atmel-samd/boards/snekboard/mpconfigboard.h +++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.h @@ -15,13 +15,6 @@ #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 0 #define DEFAULT_I2C_BUS_SCL (&pin_PA08) /* ANALOG 5 */ diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk index db2e511abf..4faa041b1b 100644 --- a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk +++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x804E USB_PRODUCT = "snekboard" diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h index 80cacfa9b0..d184945f35 100755 --- a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h +++ b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h @@ -13,10 +13,6 @@ #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 //I2C diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk index 9d0ef1c040..6a2afc306e 100755 --- a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x1B4F USB_PID = 0x0017 USB_PRODUCT = "LUMIDrive Board" diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h index cf7c3998bb..ae272d502b 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h @@ -15,20 +15,12 @@ #define SPI_FLASH_SCK_PIN &pin_PB23 #define SPI_FLASH_CS_PIN &pin_PA13 -#define MICROPY_PORT_A ( 0 ) +#define MICROPY_PORT_A ( 0 ) #define MICROPY_PORT_B ( 0 ) #define MICROPY_PORT_C ( 0 ) - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 - // I2C - also QWIIC #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk index e80ef62771..f2d4eccad9 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x1B4F USB_PID = 0x0015 USB_PRODUCT = "RedBoard Turbo Board" diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h index a50c61cf2d..13bb263803 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h +++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h @@ -5,10 +5,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk index c9d0baf11f..0c33ef960e 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x1B4F USB_PID = 0x8D23 USB_PRODUCT = "SparkFun SAMD21 Dev Breakout" diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h index 6af7fa1918..2cfdd9e73b 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h +++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h @@ -5,10 +5,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_I2C_BUS_SDA (&pin_PA22) diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk index a6e216575e..d09785fb8a 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x1B4F USB_PID = 0x8D22 USB_PRODUCT = "SparkFun SAMD21 Mini Breakout" diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h index 34ab8fcfbc..02a6e7f7ce 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h @@ -16,12 +16,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA05) #define DEFAULT_I2C_BUS_SDA (&pin_PA04) @@ -47,4 +41,3 @@ #define IGNORE_PIN_PA28 1 #define IGNORE_PIN_PA30 1 #define IGNORE_PIN_PA31 1 - diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk index 17de6ac742..92129eb63f 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x8060 USB_PRODUCT = "StringCar M0 Express" @@ -21,4 +20,3 @@ CIRCUITPY_RTC = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 - diff --git a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h index 8ca1df1621..96b38810c3 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h @@ -16,14 +16,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define AUTORESET_DELAY_MS 500 - -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PB08) #define DEFAULT_I2C_BUS_SDA (&pin_PB09) diff --git a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk index ec37186c3a..3795208724 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8030 USB_PRODUCT = "Trellis M4 Express" diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h index dd8bc03ccf..69517534ee 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h @@ -11,10 +11,6 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define IGNORE_PIN_PA03 1 #define IGNORE_PIN_PA04 1 #define IGNORE_PIN_PA11 1 diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index b4a00b654a..0d41fa4bd7 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -1,4 +1,4 @@ -LD_FILE = boards/samd21x18-bootloader.ld +LD_TEMPLATE_FILE = boards/common.template.ld USB_VID = 0x239A USB_PID = 0x801F USB_PRODUCT = "Trinket M0" diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h index 369d84b8b8..af473b1288 100644 --- a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h +++ b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h @@ -18,12 +18,6 @@ #define CALIBRATE_CRYSTALLESS 1 -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_PA09) #define DEFAULT_I2C_BUS_SDA (&pin_PA08) diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk index c20358e19f..bd6c9c9ff7 100644 --- a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x801F USB_PRODUCT="Trinket M0 Haxpress" diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.h b/ports/atmel-samd/boards/uchip/mpconfigboard.h index 6dcaf2965c..1877a41ef9 100644 --- a/ports/atmel-samd/boards/uchip/mpconfigboard.h +++ b/ports/atmel-samd/boards/uchip/mpconfigboard.h @@ -7,11 +7,9 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) +// No microcontroller.nvm #define CIRCUITPY_INTERNAL_NVM_SIZE 0 -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) - - // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.mk b/ports/atmel-samd/boards/uchip/mpconfigboard.mk index 109492b764..950910e48b 100644 --- a/ports/atmel-samd/boards/uchip/mpconfigboard.mk +++ b/ports/atmel-samd/boards/uchip/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x04D8 USB_PID = 0xED5F USB_PRODUCT = "uChip CircuitPython" diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.h b/ports/atmel-samd/boards/ugame10/mpconfigboard.h index b5590d986c..550172a517 100644 --- a/ports/atmel-samd/boards/ugame10/mpconfigboard.h +++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.h @@ -13,12 +13,6 @@ #define CALIBRATE_CRYSTALLESS 1 -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_SPI_BUS_SCK (&pin_PA07) #define DEFAULT_SPI_BUS_MISO (&pin_PA11) #define DEFAULT_SPI_BUS_MOSI (&pin_PA06) diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk index f0310b4aaa..1c43369076 100644 --- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x801F USB_PRODUCT = "uGame10" diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index cb0751acef..41dee2b490 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -92,7 +92,6 @@ const mcu_processor_obj_t common_hal_mcu_processor_obj = { }, }; -// NVM is only available on Express boards for now. #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 // The singleton nvm.ByteArray object. const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = { diff --git a/ports/atmel-samd/ld_defines.c b/ports/atmel-samd/ld_defines.c new file mode 100644 index 0000000000..62838ca4b5 --- /dev/null +++ b/ports/atmel-samd/ld_defines.c @@ -0,0 +1,14 @@ +// Fake source file used only to capture #define values for use in ld template files. +#include "mpconfigport.h" + +// For each value needed in the LD file, create a C-like line: +// NAME_OF_VALUE; ///DEFINE_VALUE NAME_OF_VALUE +// The C preprocessor will replace NAME_OF_VALUE with the actual value. +// This will be post-processed by tools/gen_ld_files.py to extract the name and vlaue. + +BOOTLOADER_SIZE; ///DEFINE_VALUE BOOTLOADER_SIZE +RAM_SIZE; ///DEFINE_VALUE RAM_SIZE lambda f: f.rstrip("UL") +FLASH_SIZE; ///DEFINE_VALUE FLASH_SIZE lambda f: f.rstrip("UL") +CIRCUITPY_INTERNAL_CONFIG_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_CONFIG_SIZE +CIRCUITPY_INTERNAL_NVM_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_NVM_SIZE +CIRCUITPY_DEFAULT_STACK_SIZE; ///DEFINE_VALUE CIRCUITPY_DEFAULT_STACK_SIZE diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 4e15a6c308..21adb10028 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -31,6 +31,30 @@ #include "include/sam.h" #ifdef SAMD21 + +// Default is 0, set by py/circuitpy_mpconfig.h +#if INTERNAL_FLASH_FILESYSTEM +// 64kB +#define INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) +#endif + +#ifndef CIRCUITPY_INTERNAL_NVM_SIZE +#define CIRCUITPY_INTERNAL_NVM_SIZE (256) +#endif + +// if CALIBRATE_CRYSTALLESS is requested, make room for storing +// calibration data generated from external USB. +#ifndef CIRCUITPY_INTERNAL_CONFIG_SIZE + #ifdef CALIBRATE_CRYSTALLESS +#define CIRCUITPY_INTERNAL_CONFIG_SIZE (256) + #else +#define CIRCUITPY_INTERNAL_CONFIG_SIZE (0) + #endif +#endif + +// HMCRAMC0_SIZE is defined in the ASF4 include files for each SAMD21 chip. +#define RAM_SIZE HMCRAMC0_SIZE +#define BOOTLOADER_SIZE (8*1024) #define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" #define SPI_FLASH_MAX_BAUDRATE 8000000 @@ -54,9 +78,17 @@ X(EISDIR) \ X(EINVAL) \ -#endif +#endif // SAMD21 #ifdef SAMD51 + +#ifndef CIRCUITPY_INTERNAL_NVM_SIZE +#define CIRCUITPY_INTERNAL_NVM_SIZE (8192) +#endif + +// HSRAM_SIZE is defined in the ASF4 include files for each SAMD51 chip. +#define RAM_SIZE HSRAM_SIZE +#define BOOTLOADER_SIZE (16*1024) #define CIRCUITPY_MCU_FAMILY samd51 #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" #define SPI_FLASH_MAX_BAUDRATE 24000000 @@ -69,7 +101,8 @@ #define MICROPY_PY_UJSON (1) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) // MICROPY_PY_UERRNO_LIST - Use the default -#endif + +#endif // SAMD51 // Turning off audioio, audiobusio, and touchio as necessary // due to limitations of chips is handled in mpconfigboard.mk diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 88ddb49e01..63ddb5f23f 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -1,3 +1,7 @@ +# All linking can be done with this common templated linker script, which has +# parameters that vary based on chip and/or board. +LD_TEMPLATE_FILE = boards/common.template.ld + # 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/ports/atmel-samd/tick.c b/ports/atmel-samd/tick.c index 4d7bb9dca7..6163a64d87 100644 --- a/ports/atmel-samd/tick.c +++ b/ports/atmel-samd/tick.c @@ -56,7 +56,7 @@ void SysTick_Handler(void) { #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); #endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS +#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 autoreload_tick(); #endif #ifdef CIRCUITPY_GAMEPAD_TICKS diff --git a/ports/cxd56/tick.c b/ports/cxd56/tick.c index 6529db7901..6b93a3b659 100644 --- a/ports/cxd56/tick.c +++ b/ports/cxd56/tick.c @@ -39,7 +39,7 @@ void board_timerhook(void) #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); #endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS +#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 autoreload_tick(); #endif } diff --git a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld b/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld index 90b8862cf0..74e66754d8 100644 --- a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld +++ b/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld @@ -19,11 +19,12 @@ /* Specify the memory areas (S140 6.x.x) */ MEMORY { - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000 + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1M FLASH_ISR (rx) : ORIGIN = 0x00026000, LENGTH = 0x001000 FLASH_TEXT (rx) : ORIGIN = 0x00027000, LENGTH = 0x086000 FLASH_FATFS (r) : ORIGIN = 0x000AD000, LENGTH = 0x040000 + FLASH_NVM (r) : ORIGIN = 0x000EC000, LENGTH = 0x001000 FLASH_CONFIG (r): ORIGIN = 0x000ED000, LENGTH = 0x007000 /* 0x2000000 - RAM:ORIGIN is reserved for Softdevice */ diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index 1e55cd0260..cc441eb0b0 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -55,12 +55,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_15 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define DEFAULT_I2C_BUS_SCL (&pin_P0_04) #define DEFAULT_I2C_BUS_SDA (&pin_P0_05) diff --git a/ports/nrf/boards/common.ld b/ports/nrf/boards/common.ld index dfb355a76f..fade4b9e1b 100644 --- a/ports/nrf/boards/common.ld +++ b/ports/nrf/boards/common.ld @@ -6,6 +6,10 @@ __fatfs_flash_length = LENGTH(FLASH_FATFS); __config_flash_start_addr = ORIGIN(FLASH_CONFIG); __config_flash_length = LENGTH(FLASH_CONFIG); +/* Flash region for microcontroller.nvm region */ +__nvm_flash_start_addr = ORIGIN(FLASH_NVM); +__nvm_flash_length = LENGTH(FLASH_NVM); + /* define output sections */ SECTIONS { diff --git a/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h index 21e8c3ef61..6b0813e7d0 100644 --- a/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h +++ b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h @@ -34,12 +34,6 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "ElectronutLabsPapyr" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_11) diff --git a/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h b/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h index 7f5021fdca..594c3e54c9 100644 --- a/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h +++ b/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h @@ -33,12 +33,6 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "ElectronutLabsPapyr" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_06) diff --git a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h index 70ccffc3f3..130c5f3e8b 100644 --- a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h @@ -54,12 +54,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_20 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_11) diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h index ed48364942..093a0df3bd 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h @@ -40,12 +40,6 @@ #define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 3) #define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 8) -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 0 #define DEFAULT_UART_BUS_RX (&pin_P0_19) diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h index d4096503d7..2128428b85 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h @@ -33,10 +33,4 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "MakerDiary52840MDKDongle" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 // according to the schematic we do diff --git a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h index 520eef90d9..99ed5c785b 100644 --- a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h @@ -54,12 +54,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_20 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_16) diff --git a/ports/nrf/boards/particle_argon/mpconfigboard.h b/ports/nrf/boards/particle_argon/mpconfigboard.h index a4ecb2bb43..0d74869b1d 100644 --- a/ports/nrf/boards/particle_argon/mpconfigboard.h +++ b/ports/nrf/boards/particle_argon/mpconfigboard.h @@ -53,12 +53,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_17 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) diff --git a/ports/nrf/boards/particle_boron/mpconfigboard.h b/ports/nrf/boards/particle_boron/mpconfigboard.h index 5e817311f9..61af22f580 100644 --- a/ports/nrf/boards/particle_boron/mpconfigboard.h +++ b/ports/nrf/boards/particle_boron/mpconfigboard.h @@ -53,12 +53,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_17 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.h b/ports/nrf/boards/particle_xenon/mpconfigboard.h index 6c8cc7cef2..c2dfffde85 100644 --- a/ports/nrf/boards/particle_xenon/mpconfigboard.h +++ b/ports/nrf/boards/particle_xenon/mpconfigboard.h @@ -53,12 +53,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_17 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h index 48ef7f1c39..eca339a7db 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.h +++ b/ports/nrf/boards/pca10056/mpconfigboard.h @@ -30,8 +30,6 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "nRF52840-DK" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define MICROPY_HW_LED_STATUS (&pin_P0_13) #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) diff --git a/ports/nrf/boards/pca10059/mpconfigboard.h b/ports/nrf/boards/pca10059/mpconfigboard.h index d5ce212292..eaca1bf210 100644 --- a/ports/nrf/boards/pca10059/mpconfigboard.h +++ b/ports/nrf/boards/pca10059/mpconfigboard.h @@ -29,5 +29,3 @@ #define MICROPY_PY_SYS_PLATFORM "nRF52840-DK" #define MICROPY_HW_LED_STATUS (&pin_P0_06) - -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h index a5ed69b2bd..20a99a6953 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h @@ -30,8 +30,6 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "SFE_NRF52840_Mini" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_P0_11) #define DEFAULT_I2C_BUS_SDA (&pin_P0_08) diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index a8e1f19059..76f08b5ed3 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -39,12 +39,21 @@ #include "supervisor/usb.h" #include "shared-bindings/_bleio/Adapter.h" #include "shared-bindings/_bleio/Address.h" +#include "shared-bindings/nvm/ByteArray.h" #define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS) #define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS) #define BLE_SLAVE_LATENCY 0 #define BLE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) +const nvm_bytearray_obj_t common_hal_bleio_nvm_obj = { + .base = { + .type = &nvm_bytearray_type, + }, + .len = CIRCUITPY_BLE_CONFIG_SIZE, + .start_address = CIRCUITPY_BLE_CONFIG_ADDRESS, +}; + STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { mp_raise_msg_varg(&mp_type_AssertionError, translate("Soft device assert, id: 0x%08lX, pc: 0x%08lX"), id, pc); diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index a6b1c4ba3b..eea3d43cec 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -76,11 +76,14 @@ const mcu_processor_obj_t common_hal_mcu_processor_obj = { }; #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 + // The singleton nvm.ByteArray object. const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = { .base = { .type = &nvm_bytearray_type, - }, + } + .start_address = CIRCUITPY_INTERNAL_NVM_ADDRESS, + .len = CIRCUITPY_INTERNAL_NVM_SIZE, }; #endif diff --git a/ports/nrf/common-hal/nvm/ByteArray.c b/ports/nrf/common-hal/nvm/ByteArray.c index ee270f79bb..416768101d 100644 --- a/ports/nrf/common-hal/nvm/ByteArray.c +++ b/ports/nrf/common-hal/nvm/ByteArray.c @@ -31,19 +31,12 @@ #include "peripherals/nrf/nvm.h" -// defined in linker -extern uint32_t __fatfs_flash_start_addr[]; -extern uint32_t __fatfs_flash_length[]; - -#define NVM_START_ADDR ((uint32_t)__fatfs_flash_start_addr + \ - (uint32_t)__fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE) - uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { - return CIRCUITPY_INTERNAL_NVM_SIZE; + return self->len; } static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) { - // Write a whole page to flash, buffering it first and then erasing and rewriting + // Write a whole page to flash, buffering it first and then erasing and rewriting // it since we can only clear a whole page at a time. if (offset == 0 && len == FLASH_PAGE_SIZE) { @@ -59,7 +52,7 @@ static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { - uint32_t address = NVM_START_ADDR + start_index; + uint32_t address = self->start_address + start_index; uint32_t offset = address % FLASH_PAGE_SIZE; uint32_t page_addr = address - offset; @@ -76,5 +69,5 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t* values) { - memcpy(values, (uint8_t *)(NVM_START_ADDR + start_index), len); + memcpy(values, self->start_address + start_index, len); } diff --git a/ports/nrf/common-hal/nvm/ByteArray.h b/ports/nrf/common-hal/nvm/ByteArray.h index a8d09dd43a..c048d55778 100644 --- a/ports/nrf/common-hal/nvm/ByteArray.h +++ b/ports/nrf/common-hal/nvm/ByteArray.h @@ -31,6 +31,8 @@ typedef struct { mp_obj_base_t base; + uint8_t* start_address; + uint32_t len; } nvm_bytearray_obj_t; #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_NVM_BYTEARRAY_H diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 9c3d02f44d..3cb086f310 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -43,6 +43,10 @@ #include "py/circuitpy_mpconfig.h" +#ifndef CIRCUITPY_INTERNAL_NVM_SIZE +#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) +#endif + #ifndef BOARD_HAS_32KHZ_XTAL // Assume crystal is present, which is the most common case. #define BOARD_HAS_32KHZ_XTAL (1) diff --git a/ports/nrf/peripherals/nrf/nvm.h b/ports/nrf/peripherals/nrf/nvm.h index 4eac3d7283..60a663e81f 100644 --- a/ports/nrf/peripherals/nrf/nvm.h +++ b/ports/nrf/peripherals/nrf/nvm.h @@ -27,8 +27,4 @@ #define FLASH_PAGE_SIZE (4096) -#ifndef CIRCUITPY_INTERNAL_NVM_SIZE -#define CIRCUITPY_INTERNAL_NVM_SIZE (0) -#endif - void nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data); diff --git a/ports/nrf/supervisor/internal_flash.c b/ports/nrf/supervisor/internal_flash.c index dcacd4d27f..c43454eb39 100644 --- a/ports/nrf/supervisor/internal_flash.c +++ b/ports/nrf/supervisor/internal_flash.c @@ -67,7 +67,7 @@ uint32_t supervisor_flash_get_block_size(void) { } uint32_t supervisor_flash_get_block_count(void) { - return ((uint32_t) __fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE) / FILESYSTEM_BLOCK_SIZE ; + return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE ; } void supervisor_flash_flush(void) { @@ -120,4 +120,3 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32 void supervisor_flash_release_cache(void) { } - diff --git a/ports/nrf/tick.c b/ports/nrf/tick.c index 6d8fd13e0a..1a9e69a8c7 100644 --- a/ports/nrf/tick.c +++ b/ports/nrf/tick.c @@ -43,7 +43,7 @@ void SysTick_Handler(void) { #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); #endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS +#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 autoreload_tick(); #endif #ifdef CIRCUITPY_GAMEPAD_TICKS diff --git a/ports/stm32f4/boards/feather_f405/mpconfigboard.h b/ports/stm32f4/boards/feather_f405/mpconfigboard.h index 831a17573a..908b35a71e 100644 --- a/ports/stm32f4/boards/feather_f405/mpconfigboard.h +++ b/ports/stm32f4/boards/feather_f405/mpconfigboard.h @@ -33,9 +33,6 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) -#define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) - // On-board flash #define SPI_FLASH_MOSI_PIN &pin_PB05 #define SPI_FLASH_MISO_PIN &pin_PB04 diff --git a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h index e8441d665c..d793a222f6 100644 --- a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h +++ b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h @@ -32,6 +32,3 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) - -#define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h index d5491fe362..5bea089750 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h @@ -32,9 +32,3 @@ #define FLASH_SIZE (0x80000) //512K #define FLASH_PAGE_SIZE (0x4000) //16K - -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h index ebee98f89f..9e23f1db54 100644 --- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h @@ -32,7 +32,3 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) - -#define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) - diff --git a/ports/stm32f4/tick.c b/ports/stm32f4/tick.c index 43521fb516..b417df3059 100644 --- a/ports/stm32f4/tick.c +++ b/ports/stm32f4/tick.c @@ -44,7 +44,7 @@ void SysTick_Handler(void) { #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); #endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS +#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 autoreload_tick(); #endif #ifdef CIRCUITPY_GAMEPAD_TICKS diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index b72d753904..915310f83a 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -296,7 +296,6 @@ $(filter $(SRC_PATTERNS), \ fontio/Glyph.c \ microcontroller/RunMode.c \ math/__init__.c \ - supervisor/__init__.c \ ) SRC_BINDINGS_ENUMS += \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 2cb6178198..91e2e223c2 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -212,7 +212,6 @@ typedef long mp_off_t; #define MP_SSIZE_MAX (0x7fffffff) #endif - // These CIRCUITPY_xxx values should all be defined in the *.mk files as being on or off. // So if any are not defined in *.mk, they'll throw an error here. @@ -661,8 +660,20 @@ void run_background_tasks(void); #define MICROPY_VM_HOOK_LOOP run_background_tasks(); #define MICROPY_VM_HOOK_RETURN run_background_tasks(); +// CIRCUITPY_AUTORELOAD_DELAY_MS = 0 will completely disable autoreload. +#ifndef CIRCUITPY_AUTORELOAD_DELAY_MS #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 +#endif + +#ifndef CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS #define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000 +#endif + +// Default is no internal flash filesystem. +#ifndef INTERNAL_FLASH_FILESYSTEM_SIZE +#define INTERNAL_FLASH_FILESYSTEM_SIZE (0) +#endif + #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H diff --git a/tools/gen_ld_files.py b/tools/gen_ld_files.py new file mode 100755 index 0000000000..fc80d46c9e --- /dev/null +++ b/tools/gen_ld_files.py @@ -0,0 +1,47 @@ +#! /usr/bin/env python3 +import argparse + +import os +import os.path +import sys +import re +from string import Template + +parser = argparse.ArgumentParser(description='Apply #define values to .template.ld file.') +parser.add_argument('template_files', metavar='TEMPLATE_FILE', type=argparse.FileType('r'), + nargs='+', help="template filename: .template.ld") +parser.add_argument('--defines', type=argparse.FileType('r'), required=True) +parser.add_argument('--out_dir', required=True) + +args = parser.parse_args() + +defines = {} + +# We're looking for lines like this: +# ///DEFINE_VALUE NAME_OF_VALUE +VALUE_LINE_RE = re.compile(r'^([^/].*); ///DEFINE_VALUE (\w+)(.*)$') + +for line in args.defines: + match = VALUE_LINE_RE.match(line.strip()) + if match: + value = match.group(1).strip() + name = match.group(2) + lambda_exp = match.group(3).strip() + # Apply the given lambda to the value if it is present, else just store the value. + defines[match.group(2)] = eval(lambda_exp)(value) if lambda_exp else value + +#print(defines) +fail = False + +for template_file in args.template_files: + ld_template_basename = os.path.basename(template_file.name) + ld_pathname = os.path.join(args.out_dir, ld_template_basename.replace('.template.ld', '.ld')) + with open(ld_pathname, 'w') as output: + try: + output.write(Template(template_file.read()).substitute(defines)) + except KeyError as e: + print("ERROR: {}: No #define for '{}'".format(ld_pathname, e.args[0]), file=sys.stderr) + fail = True + +if fail: + sys.exit(1) From 1505da784f228d43df41a773cfe504e7e4da330a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 28 Oct 2019 18:15:02 -0400 Subject: [PATCH 022/531] wip --- ports/atmel-samd/boards/common.template.ld | 10 +----- ports/atmel-samd/boards/sam32/mpconfigboard.h | 2 +- ports/atmel-samd/ld_defines.c | 7 ++-- ports/atmel-samd/mpconfigport.h | 36 +++++++++++++++++-- ports/atmel-samd/supervisor/internal_flash.c | 2 +- ports/atmel-samd/supervisor/internal_flash.h | 11 +----- py/circuitpy_mpconfig.h | 6 +--- 7 files changed, 41 insertions(+), 33 deletions(-) diff --git a/ports/atmel-samd/boards/common.template.ld b/ports/atmel-samd/boards/common.template.ld index e02bbfab02..aebda87c20 100644 --- a/ports/atmel-samd/boards/common.template.ld +++ b/ports/atmel-samd/boards/common.template.ld @@ -3,15 +3,7 @@ /* Specify the memory areas */ MEMORY { - /* CIRCUITPY_BOOTLOADER_SIZE is size of bootloader, if any. - * SAMD21 Arduino and UF2 bootloaders are 8KiB. SAMD51 UF2 is 6KiB. - * FLASH_SIZE is defined in ASF4. - * RAM_SIZE is defined in mpconfigport.h, from constants from ASF4. - * CIRCUITPY_INTERNAL_CONFIG_SIZE is size of an optional hidden config area, used currently - * for crystalless USB timing calibration. - * CIRCUITPY_INTERNAL_NVM_SIZE is the size of microntroller.nvm. - */ - FLASH (rx) : ORIGIN = 0x00000000 + ${BOOTLOADER_SIZE}, LENGTH = ${FLASH_SIZE} - ${BOOTLOADER_SIZE} - ${CIRCUITPY_INTERNAL_CONFIG_SIZE} - ${CIRCUITPY_INTERNAL_NVM_SIZE} + FLASH (rx) : ORIGIN = 0x00000000 + ${BOOTLOADER_SIZE}, LENGTH = ${CIRCUITPY_FIRMWARE_SIZE} RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE} } diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.h b/ports/atmel-samd/boards/sam32/mpconfigboard.h index 3c6f52ebcc..bd9f5e3983 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.h +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.h @@ -9,7 +9,7 @@ #define MICROPY_PORT_A (PORT_PA24 | PORT_PA25) #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define MICROPY_PORT_D (0) +#define MICROPY_PORT_D (0) // No microcontroller.nvm #define CIRCUITPY_INTERNAL_NVM_SIZE 0 diff --git a/ports/atmel-samd/ld_defines.c b/ports/atmel-samd/ld_defines.c index 62838ca4b5..d8a7a209bf 100644 --- a/ports/atmel-samd/ld_defines.c +++ b/ports/atmel-samd/ld_defines.c @@ -7,8 +7,7 @@ // This will be post-processed by tools/gen_ld_files.py to extract the name and vlaue. BOOTLOADER_SIZE; ///DEFINE_VALUE BOOTLOADER_SIZE -RAM_SIZE; ///DEFINE_VALUE RAM_SIZE lambda f: f.rstrip("UL") -FLASH_SIZE; ///DEFINE_VALUE FLASH_SIZE lambda f: f.rstrip("UL") -CIRCUITPY_INTERNAL_CONFIG_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_CONFIG_SIZE -CIRCUITPY_INTERNAL_NVM_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_NVM_SIZE +RAM_SIZE; ///DEFINE_VALUE RAM_SIZE def noUL(expr): import re; return re.sub( +FLASH_SIZE; ///DEFINE_VALUE FLASH_SIZE lambda expr: expr.rstrip("UL") +CIRCUITPY_FIRMWARE_SIZE; ///DEFINE_VALUE CIRCUITPY_FIRMWARE_SIZE CIRCUITPY_DEFAULT_STACK_SIZE; ///DEFINE_VALUE CIRCUITPY_DEFAULT_STACK_SIZE diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 21adb10028..3334ce1532 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -32,10 +32,10 @@ #ifdef SAMD21 -// Default is 0, set by py/circuitpy_mpconfig.h #if INTERNAL_FLASH_FILESYSTEM -// 64kB -#define INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) +#else +#define CIRCUITPYINTERNAL_FLASH_FILESYSTEM_SIZE (0) #endif #ifndef CIRCUITPY_INTERNAL_NVM_SIZE @@ -86,6 +86,15 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (8192) #endif +// If CIRCUITPY is internal, use half of flash for it. +#ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE + #if INTERNAL_FLASH_FILESYSTEM + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2) + #else + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) + #endif +#endif + // HSRAM_SIZE is defined in the ASF4 include files for each SAMD51 chip. #define RAM_SIZE HSRAM_SIZE #define BOOTLOADER_SIZE (16*1024) @@ -104,6 +113,27 @@ #endif // SAMD51 +// Flash layout, starting at 0x00000000 +// +// bootloader (8 or 16kB) +// firmware +// internal config, used to store crystalless clock calibration info (optional) +// microntroller.nvm (optional) +// internal CIRCUITPY flash filesystem (optional) + +// Bootloader starts at 0x00000000. +#define CIRCUITPY_FIRMWARE_START_ADDR BOOTLOADER_SIZE + +// Total space available for code, after subtracting size of other regions used for non-code. +#define CIRCUITPY_FIRMWARE_SIZE \ + (FLASH_SIZE - BOOTLOADER_SIZE - CIRCUITPY_INTERNAL_CONFIG_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE - \ + CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE) + +#define CIRCUITPY_INTERNAL_CONFIG_START_ADDR (CIRCUITPY_FIRMWARE_START_ADDR + CIRCUITPY_FIRMWARE_SIZE) +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (CIRCUITPY_INTERNAL_CONFIG_START_ADDR + CIRCUITPY_INTERNAL_CONFIG_SIZE) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR \ + (CIRCUITPY_INTERNAL_NVM_START_ADDR + CIRCUITPY_INTERNAL_NVM_SIZE) + // Turning off audioio, audiobusio, and touchio as necessary // due to limitations of chips is handled in mpconfigboard.mk diff --git a/ports/atmel-samd/supervisor/internal_flash.c b/ports/atmel-samd/supervisor/internal_flash.c index 6dd5ac0a70..a8ff5adfa9 100644 --- a/ports/atmel-samd/supervisor/internal_flash.c +++ b/ports/atmel-samd/supervisor/internal_flash.c @@ -86,7 +86,7 @@ void flash_flush(void) { static int32_t convert_block_to_flash_addr(uint32_t block) { if (0 <= block && block < INTERNAL_FLASH_PART1_NUM_BLOCKS) { // a block in partition 1 - return INTERNAL_FLASH_MEM_SEG1_START_ADDR + block * FILESYSTEM_BLOCK_SIZE; + return CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR + block * FILESYSTEM_BLOCK_SIZE; } // bad block return -1; diff --git a/ports/atmel-samd/supervisor/internal_flash.h b/ports/atmel-samd/supervisor/internal_flash.h index 0939a34548..df8b495ccb 100644 --- a/ports/atmel-samd/supervisor/internal_flash.h +++ b/ports/atmel-samd/supervisor/internal_flash.h @@ -32,16 +32,7 @@ #include "sam.h" -#ifdef SAMD51 -#define TOTAL_INTERNAL_FLASH_SIZE (FLASH_SIZE / 2) -#endif - -#ifdef SAMD21 -#define TOTAL_INTERNAL_FLASH_SIZE 0x010000 -#endif - -#define INTERNAL_FLASH_MEM_SEG1_START_ADDR (FLASH_SIZE - TOTAL_INTERNAL_FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE) -#define INTERNAL_FLASH_PART1_NUM_BLOCKS (TOTAL_INTERNAL_FLASH_SIZE / FILESYSTEM_BLOCK_SIZE) +#define INTERNAL_FLASH_PART1_NUM_BLOCKS (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE) #define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms #define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 91e2e223c2..227376ead0 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -167,6 +167,7 @@ typedef long mp_off_t; #define mp_import_stat mp_vfs_import_stat #define mp_builtin_open_obj mp_vfs_open_obj + // extra built in names to add to the global namespace #define MICROPY_PORT_BUILTINS \ { MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \ @@ -669,11 +670,6 @@ void run_background_tasks(void); #define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000 #endif -// Default is no internal flash filesystem. -#ifndef INTERNAL_FLASH_FILESYSTEM_SIZE -#define INTERNAL_FLASH_FILESYSTEM_SIZE (0) -#endif - #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H From 8ab3ef44dddbb82d623dd557461b2b77cf607283 Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Tue, 5 Nov 2019 10:52:25 -0500 Subject: [PATCH 023/531] add bluebird template files --- ports/nrf/boards/teknikio_bluebird/board.c | 38 ++++++++++ .../boards/teknikio_bluebird/mpconfigboard.h | 74 +++++++++++++++++++ .../boards/teknikio_bluebird/mpconfigboard.mk | 26 +++++++ ports/nrf/boards/teknikio_bluebird/pins.c | 71 ++++++++++++++++++ 4 files changed, 209 insertions(+) create mode 100644 ports/nrf/boards/teknikio_bluebird/board.c create mode 100644 ports/nrf/boards/teknikio_bluebird/mpconfigboard.h create mode 100644 ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk create mode 100644 ports/nrf/boards/teknikio_bluebird/pins.c diff --git a/ports/nrf/boards/teknikio_bluebird/board.c b/ports/nrf/boards/teknikio_bluebird/board.c new file mode 100644 index 0000000000..4421970eef --- /dev/null +++ b/ports/nrf/boards/teknikio_bluebird/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h new file mode 100644 index 0000000000..348028c0f7 --- /dev/null +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h @@ -0,0 +1,74 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 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. + */ + +//https://github.com/Teknikio/TKInventionBuilderFramework + +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "Adafruit Circuit Playground Bluefruit" +#define MICROPY_HW_MCU_NAME "nRF52840" +#define MICROPY_PY_SYS_PLATFORM "CircuitPlaygroundBluefruit" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (4096) + +#define MICROPY_HW_LED_STATUS (&pin_P1_14) + +// Unusually, board does not have a 32 kHz xtal. Nearly all boards do. +#define BOARD_HAS_32KHZ_XTAL (0) + +#if QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 21) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 23) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 00) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 15) +#endif + +#if SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P0_21 +#define SPI_FLASH_MISO_PIN &pin_P0_23 +#define SPI_FLASH_SCK_PIN &pin_P0_19 +#define SPI_FLASH_CS_PIN &pin_P0_15 +#endif + +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_04) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_05) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_05) +#define DEFAULT_SPI_BUS_MOSI (&pin_P1_03) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_29) + +#define DEFAULT_UART_BUS_RX (&pin_P0_30) +#define DEFAULT_UART_BUS_TX (&pin_P0_14) diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk new file mode 100644 index 0000000000..dbb32629c6 --- /dev/null +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk @@ -0,0 +1,26 @@ +USB_VID = 0x239A +USB_PID = 0x8046 +USB_PRODUCT = "Circuit Playground Bluefruit" +USB_MANUFACTURER = "Adafruit Industries LLC" + +MCU_SERIES = m4 +MCU_VARIANT = nrf52 +MCU_SUB_VARIANT = nrf52840 +MCU_CHIP = nrf52840 +SD ?= s140 +SOFTDEV_VERSION ?= 6.1.0 + +BOOT_SETTING_ADDR = 0xFF000 + +ifeq ($(SD),) + LD_FILE = boards/nrf52840_1M_256k.ld +else + LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld + CIRCUITPY_BLEIO = 1 +endif + +NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = "GD25Q16C" diff --git a/ports/nrf/boards/teknikio_bluebird/pins.c b/ports/nrf/boards/teknikio_bluebird/pins.c new file mode 100644 index 0000000000..e8e5f4110d --- /dev/null +++ b/ports/nrf/boards/teknikio_bluebird/pins.c @@ -0,0 +1,71 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_AUDIO), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_P0_26) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_02) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_29) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_04) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_30) }, + + // This cannot be A7, as it is on CPX. We don't have enough analog inputs. + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_14) }, + + { MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_P0_28) }, + + { MP_ROM_QSTR(MP_QSTR_TEMPERATURE), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_P1_02) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P1_02) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_P1_15) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_15) }, + + { MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_P1_06) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_06) }, + + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_14) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_13) }, + + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_16) }, + + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SCL), MP_ROM_PTR(&pin_P1_12) }, + + { MP_ROM_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_P1_04) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From d745c1023ee8b0acb859d12a9fdc2104a5ddbc72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=92=20Bjarke=20Gotfredsen?= Date: Tue, 12 Nov 2019 12:48:31 +0200 Subject: [PATCH 024/531] Support for XinaBox CC03 and CS11 CC03 is a ATSAMD21G18 Cortex-M0+ breakout in xChips format. CS11 is the same, but with a SD Card Interface. https://xinabox.cc/products/cc03 https://xinabox.cc/products/cs11 --- ports/atmel-samd/boards/CC03/board.c | 40 +++++++++++++++++++ ports/atmel-samd/boards/CC03/mpconfigboard.h | 24 +++++++++++ ports/atmel-samd/boards/CC03/mpconfigboard.mk | 30 ++++++++++++++ ports/atmel-samd/boards/CC03/pins.c | 35 ++++++++++++++++ ports/atmel-samd/boards/CS11/board.c | 40 +++++++++++++++++++ ports/atmel-samd/boards/CS11/mpconfigboard.h | 24 +++++++++++ ports/atmel-samd/boards/CS11/mpconfigboard.mk | 31 ++++++++++++++ ports/atmel-samd/boards/CS11/pins.c | 35 ++++++++++++++++ 8 files changed, 259 insertions(+) create mode 100644 ports/atmel-samd/boards/CC03/board.c create mode 100644 ports/atmel-samd/boards/CC03/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/CC03/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/CC03/pins.c create mode 100644 ports/atmel-samd/boards/CS11/board.c create mode 100644 ports/atmel-samd/boards/CS11/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/CS11/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/CS11/pins.c diff --git a/ports/atmel-samd/boards/CC03/board.c b/ports/atmel-samd/boards/CC03/board.c new file mode 100644 index 0000000000..770bc82593 --- /dev/null +++ b/ports/atmel-samd/boards/CC03/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) +{ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/CC03/mpconfigboard.h b/ports/atmel-samd/boards/CC03/mpconfigboard.h new file mode 100644 index 0000000000..4690ed3416 --- /dev/null +++ b/ports/atmel-samd/boards/CC03/mpconfigboard.h @@ -0,0 +1,24 @@ +#define MICROPY_HW_BOARD_NAME "XinaBox CC03" +#define MICROPY_HW_MCU_NAME "samd21g18" + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define CIRCUITPY_INTERNAL_NVM_SIZE 256 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define DEFAULT_I2C_BUS_SCL (&pin_PA23) +#define DEFAULT_I2C_BUS_SDA (&pin_PA22) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB11) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB10) +#define DEFAULT_SPI_BUS_MISO (&pin_PA12) + +#define DEFAULT_UART_BUS_RX (&pin_PA11) +#define DEFAULT_UART_BUS_TX (&pin_PA10) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/CC03/mpconfigboard.mk b/ports/atmel-samd/boards/CC03/mpconfigboard.mk new file mode 100644 index 0000000000..47cd07df21 --- /dev/null +++ b/ports/atmel-samd/boards/CC03/mpconfigboard.mk @@ -0,0 +1,30 @@ +LD_FILE = boards/samd21x18-bootloader.ld +USB_VID = 0x239A +USB_PID = 0x8014 +USB_PRODUCT = "XinaBox CC03" +USB_MANUFACTURER = "XinaBox" + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ +CIRCUITPY_SMALL_BUILD = 1 + +SUPEROPT_GC = 0 + +# Make room for frozen libs. +CIRCUITPY_FREQUENCYIO = 0 +#CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_ANALOGIO=0 +CIRCUITPY_NEOPIXEL_WRITE=0 +CIRCUITPY_PULSEIO=0 +CIRCUITPY_ROTARYIO=0 +CIRCUITPY_TOUCHIO_USE_NATIVE=0 +CIRCUITPY_TOUCHIO=0 +#CIRCUITPY_USB_MIDI=0 +#CIRCUITPY_RTC=0 +#CIRCUITPY_USB_HID=0 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice diff --git a/ports/atmel-samd/boards/CC03/pins.c b/ports/atmel-samd/boards/CC03/pins.c new file mode 100644 index 0000000000..2a0a06f218 --- /dev/null +++ b/ports/atmel-samd/boards/CC03/pins.c @@ -0,0 +1,35 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { +// { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, +// { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) }, +// { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) }, +// { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) }, +// { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, +// { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB02) }, +// { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, +// { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, +// { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA14) }, +// { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA09) }, +// { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, +// { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) }, +// { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, +// { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, +// { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_ALERT), MP_ROM_PTR(&pin_PA19) }, +// { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_RED), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, +// { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) }, +// { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) }, +// { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/CS11/board.c b/ports/atmel-samd/boards/CS11/board.c new file mode 100644 index 0000000000..770bc82593 --- /dev/null +++ b/ports/atmel-samd/boards/CS11/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) +{ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/CS11/mpconfigboard.h b/ports/atmel-samd/boards/CS11/mpconfigboard.h new file mode 100644 index 0000000000..9699568dad --- /dev/null +++ b/ports/atmel-samd/boards/CS11/mpconfigboard.h @@ -0,0 +1,24 @@ +#define MICROPY_HW_BOARD_NAME "XinaBox CS11" +#define MICROPY_HW_MCU_NAME "samd21g18" + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define CIRCUITPY_INTERNAL_NVM_SIZE 256 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define DEFAULT_I2C_BUS_SCL (&pin_PA23) +#define DEFAULT_I2C_BUS_SDA (&pin_PA22) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB11) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB10) +#define DEFAULT_SPI_BUS_MISO (&pin_PA12) + +#define DEFAULT_UART_BUS_RX (&pin_PA11) +#define DEFAULT_UART_BUS_TX (&pin_PA10) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/CS11/mpconfigboard.mk b/ports/atmel-samd/boards/CS11/mpconfigboard.mk new file mode 100644 index 0000000000..f4b7a7bfcb --- /dev/null +++ b/ports/atmel-samd/boards/CS11/mpconfigboard.mk @@ -0,0 +1,31 @@ +LD_FILE = boards/samd21x18-bootloader.ld +USB_VID = 0x239A +USB_PID = 0x8014 +USB_PRODUCT = "XinaBox CS11" +USB_MANUFACTURER = "XinaBox" + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ +CIRCUITPY_SMALL_BUILD = 1 + +SUPEROPT_GC = 0 + +# Make room for frozen libs. +CIRCUITPY_FREQUENCYIO = 0 +#CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_ANALOGIO=0 +CIRCUITPY_NEOPIXEL_WRITE=0 +CIRCUITPY_PULSEIO=0 +CIRCUITPY_ROTARYIO=0 +CIRCUITPY_TOUCHIO_USE_NATIVE=0 +CIRCUITPY_TOUCHIO=0 +CIRCUITPY_USB_MIDI=0 +#CIRCUITPY_USB_HID=0 +CIRCUITPY_RTC=0 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD \ No newline at end of file diff --git a/ports/atmel-samd/boards/CS11/pins.c b/ports/atmel-samd/boards/CS11/pins.c new file mode 100644 index 0000000000..d46d1111ff --- /dev/null +++ b/ports/atmel-samd/boards/CS11/pins.c @@ -0,0 +1,35 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { +// { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, +// { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) }, +// { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) }, +// { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) }, +// { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, +// { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB02) }, +// { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, +// { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, +// { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA09) }, +// { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, +// { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) }, +// { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, +// { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, +// { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_ALERT), MP_ROM_PTR(&pin_PA07) }, +// { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_RED), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 91123ab688ffbc13f8757f4acbc939d62b0f890c Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Tue, 12 Nov 2019 18:34:29 +0500 Subject: [PATCH 025/531] Update build.yml --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10c34355d1..850c1ca934 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -159,6 +159,8 @@ jobs: - "uchip" - "ugame10" - "winterbloom_sol" + - "CC03" + - "CS11" steps: - name: Set up Python 3.5 From 3c6c7980185a31fb2d001fb2a6c70c321129503a Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Tue, 12 Nov 2019 18:53:13 +0500 Subject: [PATCH 026/531] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 850c1ca934..b043c3ad2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,8 @@ jobs: fail-fast: false matrix: board: + - "CC03" + - "CS11" - "arduino_mkr1300" - "arduino_mkrzero" - "arduino_nano_33_ble" @@ -159,8 +161,6 @@ jobs: - "uchip" - "ugame10" - "winterbloom_sol" - - "CC03" - - "CS11" steps: - name: Set up Python 3.5 From 6161c72270102e228469da7b0efd506a58592c6f Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Tue, 12 Nov 2019 20:09:57 +0500 Subject: [PATCH 027/531] SD card folder added --- .gitmodules | 3 +++ frozen/Adafruit_CircuitPython_SD | 1 + 2 files changed, 4 insertions(+) create mode 160000 frozen/Adafruit_CircuitPython_SD diff --git a/.gitmodules b/.gitmodules index bb62a5c39d..010b6c879e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -101,3 +101,6 @@ [submodule "ports/cxd56/spresense-exported-sdk"] path = ports/cxd56/spresense-exported-sdk url = https://github.com/sonydevworld/spresense-exported-sdk.git +[submodule "frozen/Adafruit_CircuitPython_SD"] + path = frozen/Adafruit_CircuitPython_SD + url = ../../adafruit/Adafruit_CircuitPython_SD.git diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD new file mode 160000 index 0000000000..5ad33e4ca2 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_SD @@ -0,0 +1 @@ +Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c From b269fb4bfa42683ffc11d9e67e63f08abc5d9445 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Wed, 13 Nov 2019 14:58:57 +0500 Subject: [PATCH 028/531] deleted SD card folder --- frozen/Adafruit_CircuitPython_SD | 1 - 1 file changed, 1 deletion(-) delete mode 160000 frozen/Adafruit_CircuitPython_SD diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD deleted file mode 160000 index 5ad33e4ca2..0000000000 --- a/frozen/Adafruit_CircuitPython_SD +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c From 5493dd5dba7e5129700ac34df1c878d0662f821f Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Wed, 13 Nov 2019 15:06:53 +0500 Subject: [PATCH 029/531] Added SD card submodule --- frozen/Adafruit_CircuitPython_SD | 1 + 1 file changed, 1 insertion(+) create mode 160000 frozen/Adafruit_CircuitPython_SD diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD new file mode 160000 index 0000000000..5ad33e4ca2 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_SD @@ -0,0 +1 @@ +Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c From f6577fc9f70e6112f7f4393d3f4db1ed76e7fac2 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Wed, 13 Nov 2019 15:11:03 +0500 Subject: [PATCH 030/531] SD card folder removed --- .gitmodules | 3 --- frozen/Adafruit_CircuitPython_SD | 1 - 2 files changed, 4 deletions(-) delete mode 160000 frozen/Adafruit_CircuitPython_SD diff --git a/.gitmodules b/.gitmodules index 010b6c879e..bb62a5c39d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -101,6 +101,3 @@ [submodule "ports/cxd56/spresense-exported-sdk"] path = ports/cxd56/spresense-exported-sdk url = https://github.com/sonydevworld/spresense-exported-sdk.git -[submodule "frozen/Adafruit_CircuitPython_SD"] - path = frozen/Adafruit_CircuitPython_SD - url = ../../adafruit/Adafruit_CircuitPython_SD.git diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD deleted file mode 160000 index 5ad33e4ca2..0000000000 --- a/frozen/Adafruit_CircuitPython_SD +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c From 040f201fab9554d1404f2b4f9bb331a490bfb988 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Wed, 13 Nov 2019 15:44:59 +0500 Subject: [PATCH 031/531] added SD card module --- .gitmodules | 3 +++ frozen/Adafruit_CircuitPython_SD | 1 + 2 files changed, 4 insertions(+) create mode 160000 frozen/Adafruit_CircuitPython_SD diff --git a/.gitmodules b/.gitmodules index bb62a5c39d..010b6c879e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -101,3 +101,6 @@ [submodule "ports/cxd56/spresense-exported-sdk"] path = ports/cxd56/spresense-exported-sdk url = https://github.com/sonydevworld/spresense-exported-sdk.git +[submodule "frozen/Adafruit_CircuitPython_SD"] + path = frozen/Adafruit_CircuitPython_SD + url = ../../adafruit/Adafruit_CircuitPython_SD.git diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD new file mode 160000 index 0000000000..5ad33e4ca2 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_SD @@ -0,0 +1 @@ +Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c From 99952c0df0f47bec29c7f93a1978fa5ea02a8aa1 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Wed, 13 Nov 2019 16:07:52 +0500 Subject: [PATCH 032/531] Removed SD card folder --- frozen/Adafruit_CircuitPython_SD | 1 - 1 file changed, 1 deletion(-) delete mode 160000 frozen/Adafruit_CircuitPython_SD diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD deleted file mode 160000 index 5ad33e4ca2..0000000000 --- a/frozen/Adafruit_CircuitPython_SD +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c From 9ce2087a7577a5c4614c9e9b921bf395d0c852e6 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Wed, 13 Nov 2019 17:18:00 +0500 Subject: [PATCH 033/531] change --- .gitmodules | 2 +- frozen/Adafruit_CircuitPython_SD | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 frozen/Adafruit_CircuitPython_SD diff --git a/.gitmodules b/.gitmodules index 010b6c879e..da672df8a0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -103,4 +103,4 @@ url = https://github.com/sonydevworld/spresense-exported-sdk.git [submodule "frozen/Adafruit_CircuitPython_SD"] path = frozen/Adafruit_CircuitPython_SD - url = ../../adafruit/Adafruit_CircuitPython_SD.git + url = https://github.com/adafruit/Adafruit_CircuitPython_SD.git diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD new file mode 160000 index 0000000000..5ad33e4ca2 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_SD @@ -0,0 +1 @@ +Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c From 3db7f2798f92fdf7a8a2823c0cfb0cecbfa284c6 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Thu, 14 Nov 2019 16:34:08 +0500 Subject: [PATCH 034/531] updated --- .github/workflows/build.yml | 4 +-- ports/atmel-samd/boards/CC03/pins.c | 35 ------------------- ports/atmel-samd/boards/CS11/pins.c | 35 ------------------- .../boards/{CC03 => xinabox_cc03}/board.c | 0 .../{CC03 => xinabox_cc03}/mpconfigboard.h | 0 .../{CC03 => xinabox_cc03}/mpconfigboard.mk | 0 ports/atmel-samd/boards/xinabox_cc03/pins.c | 15 ++++++++ .../boards/{CS11 => xinabox_cs11}/board.c | 0 .../{CS11 => xinabox_cs11}/mpconfigboard.h | 0 .../{CS11 => xinabox_cs11}/mpconfigboard.mk | 0 ports/atmel-samd/boards/xinabox_cs11/pins.c | 20 +++++++++++ 11 files changed, 37 insertions(+), 72 deletions(-) delete mode 100644 ports/atmel-samd/boards/CC03/pins.c delete mode 100644 ports/atmel-samd/boards/CS11/pins.c rename ports/atmel-samd/boards/{CC03 => xinabox_cc03}/board.c (100%) rename ports/atmel-samd/boards/{CC03 => xinabox_cc03}/mpconfigboard.h (100%) rename ports/atmel-samd/boards/{CC03 => xinabox_cc03}/mpconfigboard.mk (100%) create mode 100644 ports/atmel-samd/boards/xinabox_cc03/pins.c rename ports/atmel-samd/boards/{CS11 => xinabox_cs11}/board.c (100%) rename ports/atmel-samd/boards/{CS11 => xinabox_cs11}/mpconfigboard.h (100%) rename ports/atmel-samd/boards/{CS11 => xinabox_cs11}/mpconfigboard.mk (100%) create mode 100644 ports/atmel-samd/boards/xinabox_cs11/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b043c3ad2e..a5d725f28e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,8 +73,6 @@ jobs: fail-fast: false matrix: board: - - "CC03" - - "CS11" - "arduino_mkr1300" - "arduino_mkrzero" - "arduino_nano_33_ble" @@ -161,6 +159,8 @@ jobs: - "uchip" - "ugame10" - "winterbloom_sol" + - "xinabox_cc03" + - "xinabox_cs11" steps: - name: Set up Python 3.5 diff --git a/ports/atmel-samd/boards/CC03/pins.c b/ports/atmel-samd/boards/CC03/pins.c deleted file mode 100644 index 2a0a06f218..0000000000 --- a/ports/atmel-samd/boards/CC03/pins.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_global_dict_table[] = { -// { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, -// { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) }, -// { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) }, -// { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) }, -// { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, -// { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB02) }, -// { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, -// { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, -// { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA14) }, -// { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA09) }, -// { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, -// { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) }, -// { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, -// { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, -// { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_ALERT), MP_ROM_PTR(&pin_PA19) }, -// { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, - { MP_ROM_QSTR(MP_QSTR_RED), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, -// { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) }, -// { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) }, -// { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/CS11/pins.c b/ports/atmel-samd/boards/CS11/pins.c deleted file mode 100644 index d46d1111ff..0000000000 --- a/ports/atmel-samd/boards/CS11/pins.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_global_dict_table[] = { -// { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, -// { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) }, -// { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) }, -// { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) }, -// { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, -// { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB02) }, -// { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, -// { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, -// { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA14) }, - { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA09) }, -// { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, -// { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) }, -// { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, -// { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, -// { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_ALERT), MP_ROM_PTR(&pin_PA07) }, -// { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, - { MP_ROM_QSTR(MP_QSTR_RED), MP_ROM_PTR(&pin_PA16) }, - { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_PTR(&pin_PA19) }, - { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_PTR(&pin_PA17) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/CC03/board.c b/ports/atmel-samd/boards/xinabox_cc03/board.c similarity index 100% rename from ports/atmel-samd/boards/CC03/board.c rename to ports/atmel-samd/boards/xinabox_cc03/board.c diff --git a/ports/atmel-samd/boards/CC03/mpconfigboard.h b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.h similarity index 100% rename from ports/atmel-samd/boards/CC03/mpconfigboard.h rename to ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.h diff --git a/ports/atmel-samd/boards/CC03/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk similarity index 100% rename from ports/atmel-samd/boards/CC03/mpconfigboard.mk rename to ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk diff --git a/ports/atmel-samd/boards/xinabox_cc03/pins.c b/ports/atmel-samd/boards/xinabox_cc03/pins.c new file mode 100644 index 0000000000..623b8ed6dc --- /dev/null +++ b/ports/atmel-samd/boards/xinabox_cc03/pins.c @@ -0,0 +1,15 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_RED), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/CS11/board.c b/ports/atmel-samd/boards/xinabox_cs11/board.c similarity index 100% rename from ports/atmel-samd/boards/CS11/board.c rename to ports/atmel-samd/boards/xinabox_cs11/board.c diff --git a/ports/atmel-samd/boards/CS11/mpconfigboard.h b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.h similarity index 100% rename from ports/atmel-samd/boards/CS11/mpconfigboard.h rename to ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.h diff --git a/ports/atmel-samd/boards/CS11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk similarity index 100% rename from ports/atmel-samd/boards/CS11/mpconfigboard.mk rename to ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk diff --git a/ports/atmel-samd/boards/xinabox_cs11/pins.c b/ports/atmel-samd/boards/xinabox_cs11/pins.c new file mode 100644 index 0000000000..84928b0dd6 --- /dev/null +++ b/ports/atmel-samd/boards/xinabox_cs11/pins.c @@ -0,0 +1,20 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_ALERT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_RED), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 949f87fd2508ccd5c2fef010bf70d1cc3d50d1f0 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Thu, 14 Nov 2019 18:50:26 +0500 Subject: [PATCH 035/531] Update pins.c --- ports/atmel-samd/boards/xinabox_cs11/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/xinabox_cs11/pins.c b/ports/atmel-samd/boards/xinabox_cs11/pins.c index 84928b0dd6..f0ef0da674 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/pins.c +++ b/ports/atmel-samd/boards/xinabox_cs11/pins.c @@ -15,6 +15,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 799770926ba8c1baa39290791cc2f9e3ff2ba043 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Thu, 14 Nov 2019 18:51:01 +0500 Subject: [PATCH 036/531] Update pins.c --- ports/atmel-samd/boards/xinabox_cc03/pins.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/boards/xinabox_cc03/pins.c b/ports/atmel-samd/boards/xinabox_cc03/pins.c index 623b8ed6dc..0efc63176b 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/pins.c +++ b/ports/atmel-samd/boards/xinabox_cc03/pins.c @@ -7,9 +7,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GREEN), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_BLUE), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, -}; + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } +} MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 8134ceec8300d8971400e68f1b8197eec6fb043a Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Thu, 14 Nov 2019 23:16:55 +0500 Subject: [PATCH 037/531] Update pins.c --- ports/atmel-samd/boards/xinabox_cc03/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/xinabox_cc03/pins.c b/ports/atmel-samd/boards/xinabox_cc03/pins.c index 0efc63176b..f7c035d0b2 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/pins.c +++ b/ports/atmel-samd/boards/xinabox_cc03/pins.c @@ -11,5 +11,5 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } -} +}; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From fa57de06886f3ec6785ec74676da0b08758c81c7 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 16 Nov 2019 14:04:12 -0500 Subject: [PATCH 038/531] use instance for verbose errors --- py/obj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/obj.c b/py/obj.c index f91b00a648..6177f74b55 100644 --- a/py/obj.c +++ b/py/obj.c @@ -508,21 +508,21 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_raise_TypeError(translate("object does not support item deletion")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item deletion"), mp_obj_get_type_str(base)); + translate("'%s' object does not support item deletion"), mp_obj_get_type_str(instance)); } } else if (value == MP_OBJ_SENTINEL) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object is not subscriptable")); } else { mp_raise_TypeError_varg( - translate("'%s' object is not subscriptable"), mp_obj_get_type_str(base)); + translate("'%s' object is not subscriptable"), mp_obj_get_type_str(instance)); } } else { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object does not support item assignment")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item assignment"), mp_obj_get_type_str(base)); + translate("'%s' object does not support item assignment"), mp_obj_get_type_str(instance)); } } } From acde22a43603faf65510b3a9ba78ba5ac1f45b44 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 16 Nov 2019 15:22:20 -0600 Subject: [PATCH 039/531] circuitpy_mpconfig.h: Move includes after include-guard To benefit from gcc's "once-only headers" implementation, the "wrapper-#ifndef" must be the first non-comment part of the file, according to the manual for various gcc/cpp versions. --- py/circuitpy_mpconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index b1e7bc05aa..efab6a4d6f 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -28,11 +28,11 @@ // sure that the same feature set and settings are used, such as in atmel-samd // and nrf. -#include - #ifndef __INCLUDED_MPCONFIG_CIRCUITPY_H #define __INCLUDED_MPCONFIG_CIRCUITPY_H +#include + // This is CircuitPython. #define CIRCUITPY 1 From 45d1b290ee13ee4080e9718909c33053583314b8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 16 Nov 2019 15:24:56 -0600 Subject: [PATCH 040/531] circuitpy_mpconfig.h: Express HOOKS in terms of RUN_BACKGROUND_TASKS .. this means that when we want to modify RUN_BACKGROUND_TASKS, only one change is needed instead of 3 --- py/circuitpy_mpconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index efab6a4d6f..61d3242919 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -658,8 +658,8 @@ void run_background_tasks(void); // TODO: Used in wiznet5k driver, but may not be needed in the long run. #define MICROPY_THREAD_YIELD() -#define MICROPY_VM_HOOK_LOOP run_background_tasks(); -#define MICROPY_VM_HOOK_RETURN run_background_tasks(); +#define MICROPY_VM_HOOK_LOOP RUN_BACKGROUND_TASKS; +#define MICROPY_VM_HOOK_RETURN RUN_BACKGROUND_TASKS; #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000 From 7f744a2369a5036cadfa05575da1704f709c98bb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 18 Nov 2019 08:22:41 -0600 Subject: [PATCH 041/531] Supervisor: move most of systick to the supervisor This code is shared by most parts, except where not all the #ifdefs inside the tick function were present in all ports. This mostly would have broken gamepad tick support on non-samd ports. The "ms32" and "ms64" variants of the tick functions are introduced because there is no 64-bit atomic read. Disabling interrupts avoids a low probability bug where milliseconds could be off by ~49.5 days once every ~49.5 days (2^32 ms). Avoiding disabling interrupts when only the low 32 bits are needed is a minor optimization. Testing performed: on metro m4 express, USB still works and time.monotonic_ns() still counts up --- drivers/wiznet5k/internet/dns/dns.c | 4 +- ports/atmel-samd/background.c | 5 +- ports/atmel-samd/common-hal/busio/UART.c | 13 ++-- ports/atmel-samd/common-hal/time/__init__.c | 4 +- ports/atmel-samd/mphalport.c | 6 +- ports/atmel-samd/mphalport.h | 6 +- ports/atmel-samd/tick.c | 36 ++------- ports/atmel-samd/tick.h | 2 - ports/cxd56/common-hal/time/__init__.c | 4 +- ports/cxd56/mphalport.c | 6 +- ports/cxd56/mphalport.h | 2 - ports/cxd56/tick.c | 15 +--- ports/cxd56/tick.h | 2 - ports/nrf/common-hal/_bleio/Adapter.c | 3 +- .../common-hal/_bleio/CharacteristicBuffer.c | 5 +- ports/nrf/common-hal/busio/UART.c | 12 +-- ports/nrf/common-hal/time/__init__.c | 2 +- ports/nrf/mphalport.c | 5 +- ports/nrf/mphalport.h | 5 +- ports/nrf/tick.c | 33 ++------ ports/nrf/tick.h | 2 - ports/stm32f4/common-hal/time/__init__.c | 2 +- ports/stm32f4/mphalport.c | 6 +- ports/stm32f4/mphalport.h | 4 +- ports/stm32f4/tick.c | 32 +++----- ports/stm32f4/tick.h | 2 - py/circuitpy_mpconfig.h | 1 + shared-module/displayio/Display.c | 11 +-- shared-module/displayio/EPaperDisplay.c | 5 +- shared-module/displayio/display_core.c | 5 +- shared-module/network/__init__.c | 4 +- shared-module/usb_hid/Device.c | 5 +- supervisor/shared/rgb_led_status.c | 9 ++- supervisor/shared/safe_mode.c | 5 +- supervisor/shared/tick.c | 76 +++++++++++++++++++ supervisor/shared/tick.h | 37 +++++++++ supervisor/supervisor.mk | 1 + 37 files changed, 214 insertions(+), 163 deletions(-) create mode 100644 supervisor/shared/tick.c create mode 100644 supervisor/shared/tick.h diff --git a/drivers/wiznet5k/internet/dns/dns.c b/drivers/wiznet5k/internet/dns/dns.c index daf4db1230..8b9e966708 100644 --- a/drivers/wiznet5k/internet/dns/dns.c +++ b/drivers/wiznet5k/internet/dns/dns.c @@ -52,7 +52,7 @@ #include #include -#include "tick.h" +#include "supervisor/shared/tick.h" //#include "Ethernet/socket.h" //#include "Internet/DNS/dns.h" @@ -125,7 +125,7 @@ uint16_t DNS_MSGID; // DNS message ID uint32_t HAL_GetTick(void) { - return ticks_ms; + return supervisor_ticks_ms32(); } uint32_t hal_sys_tick; diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c index 386ba07158..3b698768b8 100644 --- a/ports/atmel-samd/background.c +++ b/ports/atmel-samd/background.c @@ -28,6 +28,7 @@ #include "audio_dma.h" #include "tick.h" #include "supervisor/filesystem.h" +#include "supervisor/shared/tick.h" #include "supervisor/usb.h" #include "py/runtime.h" @@ -71,9 +72,9 @@ void run_background_tasks(void) { running_background_tasks = false; assert_heap_ok(); - last_finished_tick = ticks_ms; + last_finished_tick = supervisor_ticks_ms64(); } bool background_tasks_ok(void) { - return ticks_ms - last_finished_tick < 1000; + return supervisor_ticks_ms64() - last_finished_tick < 1000; } diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 2505e894af..42493a6b6e 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -34,8 +34,7 @@ #include "py/runtime.h" #include "py/stream.h" #include "supervisor/shared/translate.h" - -#include "tick.h" +#include "supervisor/shared/tick.h" #include "hpl_sercom_config.h" #include "peripheral_clk_config.h" @@ -272,10 +271,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t usart_async_get_io_descriptor(usart_desc_p, &io); size_t total_read = 0; - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); // Busy-wait until timeout or until we've read enough chars. - while (ticks_ms - start_ticks <= self->timeout_ms) { + while (supervisor_ticks_ms64() - start_ticks <= self->timeout_ms) { // Read as many chars as we can right now, up to len. size_t num_read = io_read(io, data, len); @@ -289,7 +288,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t } if (num_read > 0) { // Reset the timeout on every character read. - start_ticks = ticks_ms; + start_ticks = supervisor_ticks_ms64(); } RUN_BACKGROUND_TASKS; // Allow user to break out of a timeout with a KeyboardInterrupt. @@ -330,9 +329,9 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, // Wait until write is complete or timeout. bool done = false; - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); // Busy-wait for timeout. - while (ticks_ms - start_ticks < self->timeout_ms) { + while (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) { if (usart_async_is_tx_empty(usart_desc_p)) { done = true; break; diff --git a/ports/atmel-samd/common-hal/time/__init__.c b/ports/atmel-samd/common-hal/time/__init__.c index 0d60adef20..2d82b3d1ad 100644 --- a/ports/atmel-samd/common-hal/time/__init__.c +++ b/ports/atmel-samd/common-hal/time/__init__.c @@ -28,10 +28,10 @@ #include "shared-bindings/time/__init__.h" -#include "tick.h" +#include "supervisor/shared/tick.h" inline uint64_t common_hal_time_monotonic() { - return ticks_ms; + return supervisor_ticks_ms64(); } void common_hal_time_delay_ms(uint32_t delay) { diff --git a/ports/atmel-samd/mphalport.c b/ports/atmel-samd/mphalport.c index 957bf6073e..96433d729f 100644 --- a/ports/atmel-samd/mphalport.c +++ b/ports/atmel-samd/mphalport.c @@ -45,12 +45,12 @@ #include "mpconfigboard.h" #include "mphalport.h" #include "reset.h" -#include "tick.h" +#include "supervisor/shared/tick.h" extern uint32_t common_hal_mcu_processor_get_frequency(void); void mp_hal_delay_ms(mp_uint_t delay) { - uint64_t start_tick = ticks_ms; + uint64_t start_tick = supervisor_ticks_ms64(); uint64_t duration = 0; while (duration < delay) { RUN_BACKGROUND_TASKS; @@ -59,7 +59,7 @@ void mp_hal_delay_ms(mp_uint_t delay) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { break; } - duration = (ticks_ms - start_tick); + duration = (supervisor_ticks_ms64() - start_tick); // TODO(tannewt): Go to sleep for a little while while we wait. } } diff --git a/ports/atmel-samd/mphalport.h b/ports/atmel-samd/mphalport.h index 64269b201f..8a762e2584 100644 --- a/ports/atmel-samd/mphalport.h +++ b/ports/atmel-samd/mphalport.h @@ -31,11 +31,11 @@ #include "lib/oofatfs/ff.h" -// Global millisecond tick count (driven by SysTick interrupt). -extern volatile uint64_t ticks_ms; +#include "supervisor/shared/tick.h" +// Global millisecond tick count (driven by SysTick interrupt). static inline mp_uint_t mp_hal_ticks_ms(void) { - return ticks_ms; + return supervisor_ticks_ms32(); } // Number of bytes in receive buffer volatile uint8_t usb_rx_count; diff --git a/ports/atmel-samd/tick.c b/ports/atmel-samd/tick.c index 4d7bb9dca7..f996440ae3 100644 --- a/ports/atmel-samd/tick.c +++ b/ports/atmel-samd/tick.c @@ -28,47 +28,21 @@ #include "peripheral_clk_config.h" -#include "supervisor/shared/autoreload.h" -#include "supervisor/filesystem.h" +#include "supervisor/shared/tick.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Processor.h" -#if CIRCUITPY_GAMEPAD -#include "shared-module/gamepad/__init__.h" -#endif - -#if CIRCUITPY_GAMEPADSHIFT -#include "shared-module/gamepadshift/__init__.h" -#endif -// Global millisecond tick count -volatile uint64_t ticks_ms = 0; - void SysTick_Handler(void) { // SysTick interrupt handler called when the SysTick timer reaches zero // (every millisecond). common_hal_mcu_disable_interrupts(); - ticks_ms += 1; // Read the control register to reset the COUNTFLAG. (void) SysTick->CTRL; common_hal_mcu_enable_interrupts(); -#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 - filesystem_tick(); -#endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS - autoreload_tick(); -#endif -#ifdef CIRCUITPY_GAMEPAD_TICKS - if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) { - #if CIRCUITPY_GAMEPAD - gamepad_tick(); - #endif - #if CIRCUITPY_GAMEPADSHIFT - gamepadshift_tick(); - #endif - } -#endif + // Do things common to all ports when the tick occurs + supervisor_tick(); } void tick_init() { @@ -115,7 +89,7 @@ void current_tick(uint64_t* ms, uint32_t* us_until_ms) { uint32_t tick_status = SysTick->CTRL; uint32_t current_us = SysTick->VAL; uint32_t tick_status2 = SysTick->CTRL; - uint64_t current_ms = ticks_ms; + uint64_t current_ms = supervisor_ticks_ms64(); // The second clause ensures our value actually rolled over. Its possible it hit zero between // the VAL read and CTRL read. if ((tick_status & SysTick_CTRL_COUNTFLAG_Msk) != 0 || @@ -129,5 +103,5 @@ void current_tick(uint64_t* ms, uint32_t* us_until_ms) { void wait_until(uint64_t ms, uint32_t us_until_ms) { uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; - while (ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} + while (supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} } diff --git a/ports/atmel-samd/tick.h b/ports/atmel-samd/tick.h index c8c8d739ab..334352df26 100644 --- a/ports/atmel-samd/tick.h +++ b/ports/atmel-samd/tick.h @@ -28,8 +28,6 @@ #include "py/mpconfig.h" -extern volatile uint64_t ticks_ms; - extern struct timer_descriptor ms_timer; void tick_init(void); diff --git a/ports/cxd56/common-hal/time/__init__.c b/ports/cxd56/common-hal/time/__init__.c index 8f7326b629..6f5eedd419 100644 --- a/ports/cxd56/common-hal/time/__init__.c +++ b/ports/cxd56/common-hal/time/__init__.c @@ -26,10 +26,10 @@ #include "py/mphal.h" -#include "tick.h" +#include "supervisor/shared/tick.h" uint64_t common_hal_time_monotonic(void) { - return ticks_ms; + return supervisor_ticks_ms64(); } void common_hal_time_delay_ms(uint32_t delay) { diff --git a/ports/cxd56/mphalport.c b/ports/cxd56/mphalport.c index 79d93f9759..1305706caa 100644 --- a/ports/cxd56/mphalport.c +++ b/ports/cxd56/mphalport.c @@ -31,7 +31,7 @@ #include "py/mpstate.h" -#include "tick.h" +#include "supervisor/shared/tick.h" #define DELAY_CORRECTION (700) #define DELAY_INTERVAL (50) @@ -57,7 +57,7 @@ mp_uint_t mp_hal_ticks_cpu(void) { } void mp_hal_delay_ms(mp_uint_t delay) { - uint64_t start_tick = ticks_ms; + uint64_t start_tick = supervisor_ticks_ms64(); uint64_t duration = 0; while (duration < delay) { #ifdef MICROPY_VM_HOOK_LOOP @@ -68,7 +68,7 @@ void mp_hal_delay_ms(mp_uint_t delay) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { break; } - duration = (ticks_ms - start_tick); + duration = (supervisor_ticks_ms64() - start_tick); // TODO(tannewt): Go to sleep for a little while while we wait. } } diff --git a/ports/cxd56/mphalport.h b/ports/cxd56/mphalport.h index 25bca97ad7..a2be10b8d0 100644 --- a/ports/cxd56/mphalport.h +++ b/ports/cxd56/mphalport.h @@ -31,6 +31,4 @@ #include "lib/utils/interrupt_char.h" -extern volatile uint64_t ticks_ms; - #endif // MICROPY_INCLUDED_CXD56_MPHALPORT_H diff --git a/ports/cxd56/tick.c b/ports/cxd56/tick.c index 6529db7901..671b82b744 100644 --- a/ports/cxd56/tick.c +++ b/ports/cxd56/tick.c @@ -27,19 +27,10 @@ #include "tick.h" #include "supervisor/shared/autoreload.h" -#include "supervisor/filesystem.h" - -// Global millisecond tick count -volatile uint64_t ticks_ms = 0; +#include "supervisor/shared/tick.h" void board_timerhook(void) { - ticks_ms += 1; - -#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 - filesystem_tick(); -#endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS - autoreload_tick(); -#endif + // Do things common to all ports when the tick occurs + supervisor_tick(); } diff --git a/ports/cxd56/tick.h b/ports/cxd56/tick.h index a0d9ee5263..d641d9cd4f 100644 --- a/ports/cxd56/tick.h +++ b/ports/cxd56/tick.h @@ -29,6 +29,4 @@ #include "py/mpconfig.h" -extern volatile uint64_t ticks_ms; - #endif // MICROPY_INCLUDED_CXD56_TICK_H diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 295a42d63b..c3b8dcebe2 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -40,6 +40,7 @@ #include "py/objstr.h" #include "py/runtime.h" #include "supervisor/shared/safe_mode.h" +#include "supervisor/shared/tick.h" #include "supervisor/usb.h" #include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/Adapter.h" @@ -353,7 +354,7 @@ STATIC bool scan_on_ble_evt(ble_evt_t *ble_evt, void *scan_results_in) { ble_gap_evt_adv_report_t *report = &ble_evt->evt.gap_evt.params.adv_report; shared_module_bleio_scanresults_append(scan_results, - ticks_ms, + supervisor_ticks_ms64(), report->type.connectable, report->type.scan_response, report->rssi, diff --git a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c index 5f280e121f..9f9b453de4 100644 --- a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c +++ b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c @@ -39,6 +39,7 @@ #include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/Connection.h" +#include "supervisor/shared/tick.h" #include "common-hal/_bleio/CharacteristicBuffer.h" STATIC void write_to_ringbuf(bleio_characteristic_buffer_obj_t *self, uint8_t *data, uint16_t len) { @@ -100,10 +101,10 @@ void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffe } int common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self, uint8_t *data, size_t len, int *errcode) { - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); // Wait for all bytes received or timeout - while ( (ringbuf_count(&self->ringbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( (ringbuf_count(&self->ringbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { RUN_BACKGROUND_TASKS; // Allow user to break out of a timeout with a KeyboardInterrupt. if ( mp_hal_is_interrupted() ) { diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 54a66ddbe7..982b8efa97 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -231,10 +231,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t } size_t rx_bytes = 0; - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); // Wait for all bytes received or timeout - while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( (ringbuf_count(&self->rbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { RUN_BACKGROUND_TASKS; // Allow user to break out of a timeout with a KeyboardInterrupt. if ( mp_hal_is_interrupted() ) { @@ -265,15 +265,15 @@ size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, if ( len == 0 ) return 0; - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); // Wait for on-going transfer to complete - while ( nrfx_uarte_tx_in_progress(self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( nrfx_uarte_tx_in_progress(self->uarte) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { RUN_BACKGROUND_TASKS; } // Time up - if ( !(ticks_ms - start_ticks < self->timeout_ms) ) { + if ( !(supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { *errcode = MP_EAGAIN; return MP_STREAM_ERROR; } @@ -290,7 +290,7 @@ size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, _VERIFY_ERR(*errcode); (*errcode) = 0; - while ( nrfx_uarte_tx_in_progress(self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( nrfx_uarte_tx_in_progress(self->uarte) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { RUN_BACKGROUND_TASKS; } diff --git a/ports/nrf/common-hal/time/__init__.c b/ports/nrf/common-hal/time/__init__.c index e3cb481ef4..976f519db2 100644 --- a/ports/nrf/common-hal/time/__init__.c +++ b/ports/nrf/common-hal/time/__init__.c @@ -29,7 +29,7 @@ #include "tick.h" uint64_t common_hal_time_monotonic(void) { - return ticks_ms; + return supervisor_ticks_ms64(); } void common_hal_time_delay_ms(uint32_t delay) { diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index bcd9fb1145..3885d5a826 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -31,12 +31,13 @@ #include "py/mphal.h" #include "py/mpstate.h" #include "py/gc.h" +#include "supervisor/shared/tick.h" /*------------------------------------------------------------------*/ /* delay *------------------------------------------------------------------*/ void mp_hal_delay_ms(mp_uint_t delay) { - uint64_t start_tick = ticks_ms; + uint64_t start_tick = supervisor_ticks_ms64(); uint64_t duration = 0; while (duration < delay) { RUN_BACKGROUND_TASKS; @@ -45,7 +46,7 @@ void mp_hal_delay_ms(mp_uint_t delay) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { break; } - duration = (ticks_ms - start_tick); + duration = (supervisor_ticks_ms64() - start_tick); // TODO(tannewt): Go to sleep for a little while while we wait. } } diff --git a/ports/nrf/mphalport.h b/ports/nrf/mphalport.h index a1929a4ace..8bb351401a 100644 --- a/ports/nrf/mphalport.h +++ b/ports/nrf/mphalport.h @@ -33,12 +33,11 @@ #include "lib/utils/interrupt_char.h" #include "nrfx_uarte.h" #include "py/mpconfig.h" +#include "supervisor/shared/tick.h" extern nrfx_uarte_t serial_instance; -extern volatile uint64_t ticks_ms; - -#define mp_hal_ticks_ms() ((mp_uint_t) ticks_ms) +#define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32()) #define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us)) bool mp_hal_stdin_any(void); diff --git a/ports/nrf/tick.c b/ports/nrf/tick.c index 6d8fd13e0a..ac825a7f1f 100644 --- a/ports/nrf/tick.c +++ b/ports/nrf/tick.c @@ -26,31 +26,14 @@ #include "tick.h" -#include "supervisor/shared/autoreload.h" -#include "supervisor/filesystem.h" +#include "supervisor/shared/tick.h" #include "shared-module/gamepad/__init__.h" #include "shared-bindings/microcontroller/Processor.h" #include "nrf.h" -// Global millisecond tick count -volatile uint64_t ticks_ms = 0; - void SysTick_Handler(void) { - // SysTick interrupt handler called when the SysTick timer reaches zero - // (every millisecond). - ticks_ms += 1; - -#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 - filesystem_tick(); -#endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS - autoreload_tick(); -#endif -#ifdef CIRCUITPY_GAMEPAD_TICKS - if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) { - gamepad_tick(); - } -#endif + // Do things common to all ports when the tick occurs + supervisor_tick(); } void tick_init() { @@ -61,11 +44,11 @@ void tick_init() { void tick_delay(uint32_t us) { uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; uint32_t us_between_ticks = SysTick->VAL / ticks_per_us; - uint64_t start_ms = ticks_ms; + uint64_t start_ms = supervisor_ticks_ms64(); while (us > 1000) { - while (ticks_ms == start_ms) {} + while (supervisor_ticks_ms64() == start_ms) {} us -= us_between_ticks; - start_ms = ticks_ms; + start_ms = supervisor_ticks_ms64(); us_between_ticks = 1000; } while (SysTick->VAL > ((us_between_ticks - us) * ticks_per_us)) {} @@ -74,11 +57,11 @@ void tick_delay(uint32_t us) { // us counts down! void current_tick(uint64_t* ms, uint32_t* us_until_ms) { uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; - *ms = ticks_ms; + *ms = supervisor_ticks_ms64(); *us_until_ms = SysTick->VAL / ticks_per_us; } void wait_until(uint64_t ms, uint32_t us_until_ms) { uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; - while(ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} + while(supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} } diff --git a/ports/nrf/tick.h b/ports/nrf/tick.h index 838e9fbea8..d638ad0251 100644 --- a/ports/nrf/tick.h +++ b/ports/nrf/tick.h @@ -30,8 +30,6 @@ #include -extern volatile uint64_t ticks_ms; - extern struct timer_descriptor ms_timer; void tick_init(void); diff --git a/ports/stm32f4/common-hal/time/__init__.c b/ports/stm32f4/common-hal/time/__init__.c index e3cb481ef4..976f519db2 100644 --- a/ports/stm32f4/common-hal/time/__init__.c +++ b/ports/stm32f4/common-hal/time/__init__.c @@ -29,7 +29,7 @@ #include "tick.h" uint64_t common_hal_time_monotonic(void) { - return ticks_ms; + return supervisor_ticks_ms64(); } void common_hal_time_delay_ms(uint32_t delay) { diff --git a/ports/stm32f4/mphalport.c b/ports/stm32f4/mphalport.c index ea864e7ceb..f78e9c7501 100644 --- a/ports/stm32f4/mphalport.c +++ b/ports/stm32f4/mphalport.c @@ -31,11 +31,13 @@ #include "py/mpstate.h" #include "py/gc.h" +#include "supervisor/shared/tick.h" + /*------------------------------------------------------------------*/ /* delay *------------------------------------------------------------------*/ void mp_hal_delay_ms(mp_uint_t delay) { - uint64_t start_tick = ticks_ms; + uint64_t start_tick = supervisor_ticks_ms64(); uint64_t duration = 0; while (duration < delay) { #ifdef MICROPY_VM_HOOK_LOOP @@ -46,7 +48,7 @@ void mp_hal_delay_ms(mp_uint_t delay) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { break; } - duration = (ticks_ms - start_tick); + duration = (supervisor_ticks_ms64() - start_tick); // TODO(tannewt): Go to sleep for a little while while we wait. } } diff --git a/ports/stm32f4/mphalport.h b/ports/stm32f4/mphalport.h index d184138f78..df2f0ca65a 100644 --- a/ports/stm32f4/mphalport.h +++ b/ports/stm32f4/mphalport.h @@ -32,10 +32,10 @@ #include "lib/utils/interrupt_char.h" #include "py/mpconfig.h" +#include "supervisor/shared/tick.h" -extern volatile uint64_t ticks_ms; -#define mp_hal_ticks_ms() ((mp_uint_t) ticks_ms) +#define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32()) //#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us)) bool mp_hal_stdin_any(void); diff --git a/ports/stm32f4/tick.c b/ports/stm32f4/tick.c index 688f71dbd4..f4adf183aa 100644 --- a/ports/stm32f4/tick.c +++ b/ports/stm32f4/tick.c @@ -26,37 +26,23 @@ #include "tick.h" -#include "supervisor/shared/autoreload.h" #include "supervisor/filesystem.h" -#include "shared-module/gamepad/__init__.h" +#include "supervisor/shared/tick.h" #include "shared-bindings/microcontroller/Processor.h" #include "stm32f4xx.h" -// Global millisecond tick count -volatile uint64_t ticks_ms = 0; - void SysTick_Handler(void) { // SysTick interrupt handler called when the SysTick timer reaches zero // (every millisecond). - ticks_ms += 1; -#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 - filesystem_tick(); -#endif -#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS - autoreload_tick(); -#endif -#ifdef CIRCUITPY_GAMEPAD_TICKS - if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) { - gamepad_tick(); - } -#endif + // Do things common to all ports when the tick occurs + supervisor_tick(); } uint32_t HAL_GetTick(void) //override ST HAL { - return (uint32_t)ticks_ms; + return (uint32_t)supervisor_ticks_ms32(); } void tick_init() { @@ -72,11 +58,11 @@ void tick_init() { void tick_delay(uint32_t us) { uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; uint32_t us_between_ticks = SysTick->VAL / ticks_per_us; - uint64_t start_ms = ticks_ms; + uint64_t start_ms = supervisor_ticks_ms64(); while (us > 1000) { - while (ticks_ms == start_ms) {} + while (supervisor_ticks_ms64() == start_ms) {} us -= us_between_ticks; - start_ms = ticks_ms; + start_ms = supervisor_ticks_ms64(); us_between_ticks = 1000; } while (SysTick->VAL > ((us_between_ticks - us) * ticks_per_us)) {} @@ -85,11 +71,11 @@ void tick_delay(uint32_t us) { // us counts down! void current_tick(uint64_t* ms, uint32_t* us_until_ms) { uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; - *ms = ticks_ms; + *ms = supervisor_ticks_ms32(); *us_until_ms = SysTick->VAL / ticks_per_us; } void wait_until(uint64_t ms, uint32_t us_until_ms) { uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; - while(ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} + while(supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} } diff --git a/ports/stm32f4/tick.h b/ports/stm32f4/tick.h index e4772fa2cf..999acc7a3c 100644 --- a/ports/stm32f4/tick.h +++ b/ports/stm32f4/tick.h @@ -30,8 +30,6 @@ #include -extern volatile uint64_t ticks_ms; - extern struct timer_descriptor ms_timer; void tick_init(void); diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 61d3242919..7853e4de95 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -32,6 +32,7 @@ #define __INCLUDED_MPCONFIG_CIRCUITPY_H #include +#include // This is CircuitPython. #define CIRCUITPY 1 diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 862d2cf598..11db0f8ff2 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -35,6 +35,7 @@ #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/display_core.h" #include "supervisor/shared/display.h" +#include "supervisor/shared/tick.h" #include "supervisor/usb.h" #include @@ -313,7 +314,7 @@ uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self bool common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame) { if (!self->auto_refresh && !self->first_manual_refresh) { - uint64_t current_time = ticks_ms; + uint64_t current_time = supervisor_ticks_ms64(); uint32_t current_ms_since_real_refresh = current_time - self->core.last_refresh; // Test to see if the real frame time is below our minimum. if (current_ms_since_real_refresh > maximum_ms_per_real_frame) { @@ -327,7 +328,7 @@ bool common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_ } uint32_t remaining_time = target_ms_per_frame - (current_ms_since_real_refresh % target_ms_per_frame); // We're ahead of the game so wait until we align with the frame rate. - while (ticks_ms - self->last_refresh_call < remaining_time) { + while (supervisor_ticks_ms64() - self->last_refresh_call < remaining_time) { RUN_BACKGROUND_TASKS; } } @@ -350,20 +351,20 @@ STATIC void _update_backlight(displayio_display_obj_t* self) { if (!self->auto_brightness || self->updating_backlight) { return; } - if (ticks_ms - self->last_backlight_refresh < 100) { + if (supervisor_ticks_ms64() - self->last_backlight_refresh < 100) { return; } // TODO(tannewt): Fade the backlight based on it's existing value and a target value. The target // should account for ambient light when possible. common_hal_displayio_display_set_brightness(self, 1.0); - self->last_backlight_refresh = ticks_ms; + self->last_backlight_refresh = supervisor_ticks_ms64(); } void displayio_display_background(displayio_display_obj_t* self) { _update_backlight(self); - if (self->auto_refresh && (ticks_ms - self->core.last_refresh) > self->native_ms_per_frame) { + if (self->auto_refresh && (supervisor_ticks_ms64() - self->core.last_refresh) > self->native_ms_per_frame) { _refresh_display(self); } } diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index df1d5162b7..ad2559a83b 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -35,6 +35,7 @@ #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/__init__.h" #include "supervisor/shared/display.h" +#include "supervisor/shared/tick.h" #include "supervisor/usb.h" #include @@ -175,7 +176,7 @@ uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaper return 0; } // Refresh at seconds per frame rate. - uint32_t elapsed_time = ticks_ms - self->core.last_refresh; + uint32_t elapsed_time = supervisor_ticks_ms64() - self->core.last_refresh; if (elapsed_time > self->milliseconds_per_frame) { return 0; } @@ -339,7 +340,7 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) { bool busy = common_hal_digitalio_digitalinout_get_value(&self->busy); refresh_done = busy != self->busy_state; } else { - refresh_done = ticks_ms - self->core.last_refresh > self->refresh_time; + refresh_done = supervisor_ticks_ms64() - self->core.last_refresh > self->refresh_time; } if (refresh_done) { self->refreshing = false; diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index a73ea81d1f..658daa8d69 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -35,6 +35,7 @@ #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/__init__.h" #include "supervisor/shared/display.h" +#include "supervisor/shared/tick.h" #include #include @@ -281,7 +282,7 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self, } void displayio_display_core_start_refresh(displayio_display_core_t* self) { - self->last_refresh = ticks_ms; + self->last_refresh = supervisor_ticks_ms64(); } void displayio_display_core_finish_refresh(displayio_display_core_t* self) { @@ -289,7 +290,7 @@ void displayio_display_core_finish_refresh(displayio_display_core_t* self) { displayio_group_finish_refresh(self->current_group); } self->full_refresh = false; - self->last_refresh = ticks_ms; + self->last_refresh = supervisor_ticks_ms64(); } void release_display_core(displayio_display_core_t* self) { diff --git a/shared-module/network/__init__.c b/shared-module/network/__init__.c index 96648b260c..925e9a2a30 100644 --- a/shared-module/network/__init__.c +++ b/shared-module/network/__init__.c @@ -31,6 +31,8 @@ #include "py/mphal.h" #include "py/mperrno.h" +#include "supervisor/shared/tick.h" + #include "shared-bindings/random/__init__.h" #include "shared-module/network/__init__.h" @@ -53,7 +55,7 @@ void network_module_deinit(void) { void network_module_background(void) { static uint32_t next_tick = 0; - uint32_t this_tick = ticks_ms; + uint32_t this_tick = supervisor_ticks_ms32(); if (this_tick < next_tick) return; next_tick = this_tick + 1000; diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index bed7d163f9..8744f2ed31 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -30,6 +30,7 @@ #include "shared-bindings/usb_hid/Device.h" #include "shared-module/usb_hid/Device.h" #include "supervisor/shared/translate.h" +#include "supervisor/shared/tick.h" #include "tusb.h" uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self) { @@ -46,8 +47,8 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t* } // Wait until interface is ready, timeout = 2 seconds - uint64_t end_ticks = ticks_ms + 2000; - while ( (ticks_ms < end_ticks) && !tud_hid_ready() ) { + uint64_t end_ticks = supervisor_ticks_ms64() + 2000; + while ( (supervisor_ticks_ms64() < end_ticks) && !tud_hid_ready() ) { RUN_BACKGROUND_TASKS; } diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c index 940cbf1f27..f751a7ffd5 100644 --- a/supervisor/shared/rgb_led_status.c +++ b/supervisor/shared/rgb_led_status.c @@ -27,6 +27,7 @@ #include "mphalport.h" #include "shared-bindings/microcontroller/Pin.h" #include "rgb_led_status.h" +#include "supervisor/shared/tick.h" #ifdef MICROPY_HW_NEOPIXEL uint8_t rgb_status_brightness = 63; @@ -360,7 +361,7 @@ void prep_rgb_status_animation(const pyexec_result_t* result, rgb_status_animation_t* status) { #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED)) new_status_color(ALL_DONE); - status->pattern_start = ticks_ms; + status->pattern_start = supervisor_ticks_ms32(); status->safe_mode = safe_mode; status->found_main = found_main; status->total_exception_cycle = 0; @@ -405,11 +406,11 @@ void prep_rgb_status_animation(const pyexec_result_t* result, void tick_rgb_status_animation(rgb_status_animation_t* status) { #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED)) - uint32_t tick_diff = ticks_ms - status->pattern_start; + uint32_t tick_diff = supervisor_ticks_ms32() - status->pattern_start; if (status->ok) { // All is good. Ramp ALL_DONE up and down. if (tick_diff > ALL_GOOD_CYCLE_MS) { - status->pattern_start = ticks_ms; + status->pattern_start = supervisor_ticks_ms32(); tick_diff = 0; } @@ -424,7 +425,7 @@ void tick_rgb_status_animation(rgb_status_animation_t* status) { } } else { if (tick_diff > status->total_exception_cycle) { - status->pattern_start = ticks_ms; + status->pattern_start = supervisor_ticks_ms32(); tick_diff = 0; } // First flash the file color. diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index d8d3ab379c..363181da06 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -34,6 +34,7 @@ #include "supervisor/shared/rgb_led_colors.h" #include "supervisor/shared/rgb_led_status.h" #include "supervisor/shared/translate.h" +#include "supervisor/shared/tick.h" #define SAFE_MODE_DATA_GUARD 0xad0000af #define SAFE_MODE_DATA_GUARD_MASK 0xff0000ff @@ -59,14 +60,14 @@ safe_mode_t wait_for_safe_mode_reset(void) { common_hal_digitalio_digitalinout_construct(&status_led, MICROPY_HW_LED_STATUS); common_hal_digitalio_digitalinout_switch_to_output(&status_led, true, DRIVE_MODE_PUSH_PULL); #endif - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); uint64_t diff = 0; while (diff < 700) { #ifdef MICROPY_HW_LED_STATUS // Blink on for 100, off for 100, on for 100, off for 100 and on for 200 common_hal_digitalio_digitalinout_set_value(&status_led, diff > 100 && diff / 100 != 2 && diff / 100 != 4); #endif - diff = ticks_ms - start_ticks; + diff = supervisor_ticks_ms64() - start_ticks; } #ifdef MICROPY_HW_LED_STATUS common_hal_digitalio_digitalinout_deinit(&status_led); diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c new file mode 100644 index 0000000000..d4a6ac5d75 --- /dev/null +++ b/supervisor/shared/tick.c @@ -0,0 +1,76 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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 "supervisor/shared/tick.h" +#include "supervisor/filesystem.h" +#include "supervisor/shared/autoreload.h" + +static volatile uint64_t ticks_ms; + +#if CIRCUITPY_GAMEPAD +#include "shared-module/gamepad/__init__.h" +#endif + +#if CIRCUITPY_GAMEPADSHIFT +#include "shared-module/gamepadshift/__init__.h" +#endif + +#include "shared-bindings/microcontroller/__init__.h" + +void supervisor_tick(void) { + + ticks_ms ++; + + +#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 + filesystem_tick(); +#endif +#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS + autoreload_tick(); +#endif +#ifdef CIRCUITPY_GAMEPAD_TICKS + if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) { + #if CIRCUITPY_GAMEPAD + gamepad_tick(); + #endif + #if CIRCUITPY_GAMEPADSHIFT + gamepadshift_tick(); + #endif + } +#endif +} + +uint64_t supervisor_ticks_ms64() { + uint64_t result; + common_hal_mcu_disable_interrupts(); + result = ticks_ms; + common_hal_mcu_enable_interrupts(); + return result; +} + +uint32_t supervisor_ticks_ms32() { + return ticks_ms; +} diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h new file mode 100644 index 0000000000..3defeb1081 --- /dev/null +++ b/supervisor/shared/tick.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __INCLUDED_SUPERVISOR_TICK_H +#define __INCLUDED_SUPERVISOR_TICK_H + +#include +#include + +extern void supervisor_tick(void); +extern uint32_t supervisor_ticks_ms32(void); +extern uint64_t supervisor_ticks_ms64(void); + +#endif diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index b2e4eb1dcf..5e997ee78e 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -10,6 +10,7 @@ SRC_SUPERVISOR = \ supervisor/shared/safe_mode.c \ supervisor/shared/stack.c \ supervisor/shared/status_leds.c \ + supervisor/shared/tick.c \ supervisor/shared/translate.c ifndef $(NO_USB) From 40a47d41dfea885ecfbc6a6fe1fc2ec5124a293b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 18 Nov 2019 10:51:16 -0600 Subject: [PATCH 042/531] samd: background: Allow monitoring time taken in background task If you define MONITOR_BACKGROUND_TASK, then a physical output pin (Metro M4 Express's "SCL" pin by default) will be set HIGH while in the background task and LOW at other times --- ports/atmel-samd/background.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c index 3b698768b8..ca91a31de6 100644 --- a/ports/atmel-samd/background.c +++ b/ports/atmel-samd/background.c @@ -45,6 +45,23 @@ bool stack_ok_so_far = true; static bool running_background_tasks = false; +#ifdef MONITOR_BACKGROUND_TASKS +// 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 +STATIC void start_background_task(void) { + REG_PORT_DIRSET1 = (1<<3); + REG_PORT_OUTSET1 = (1<<3); +} + +STATIC void finish_background_task(void) { + REG_PORT_OUTCLR1 = (1<<3); +} +#else +STATIC void start_background_task(void) {} +STATIC void finish_background_task(void) {} +#endif + void background_tasks_reset(void) { running_background_tasks = false; } @@ -54,6 +71,9 @@ void run_background_tasks(void) { if (running_background_tasks) { return; } + + start_background_task(); + assert_heap_ok(); running_background_tasks = true; @@ -73,6 +93,7 @@ void run_background_tasks(void) { assert_heap_ok(); last_finished_tick = supervisor_ticks_ms64(); + finish_background_task(); } bool background_tasks_ok(void) { From 568636d562b4c64d0095ff2ac921b79eb69e520d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 18 Nov 2019 09:53:12 -0600 Subject: [PATCH 043/531] run_background_tasks: Do nothing unless there has been a tick This improves performance of running python code by 34%, based on the "pystone" benchmark on metro m4 express at 5000 passes (1127.65 -> 1521.6 passes/second). In addition, by instrumenting the tick function and monitoring on an oscilloscope, the time actually spent in run_background_tasks() on the metro m4 decreases from average 43% to 0.5%. (however, there's some additional overhead that is moved around and not accounted for in that "0.5%" figure, each time supervisor_run_background_tasks_if_tick is called but no tick has occurred) On the CPB, it increases pystone from 633 to 769, a smaller percentage increase of 21%. I did not measure the time actually spent in run_background_tasks() on CPB. Testing performed: on metro m4 and cpb, run pystone adapted from python3.4 (change time.time to time.monotonic for sub-second resolution) Besides running a 5000 pass test, I also ran a 50-pass test while scoping how long an output pin was set. Average: 34.59ms or 1445/s on m4, 67.61ms or 739/s on cbp, both matching the other pystone result reasonably well. import pystone import board import digitalio import time d = digitalio.DigitalInOut(board.D13) d.direction = digitalio.Direction.OUTPUT while True: d.value = 0 time.sleep(.01) d.value = 1 pystone.main(50) --- py/circuitpy_mpconfig.h | 4 ++-- supervisor/shared/tick.c | 12 ++++++++++++ supervisor/shared/tick.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 7853e4de95..3e83d0c510 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -653,8 +653,8 @@ extern const struct _mp_obj_module_t ustack_module; FLASH_ROOT_POINTERS \ NETWORK_ROOT_POINTERS \ -void run_background_tasks(void); -#define RUN_BACKGROUND_TASKS (run_background_tasks()) +void supervisor_run_background_tasks_if_tick(void); +#define RUN_BACKGROUND_TASKS (supervisor_run_background_tasks_if_tick()) // TODO: Used in wiznet5k driver, but may not be needed in the long run. #define MICROPY_THREAD_YIELD() diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index d4a6ac5d75..7dc5a52d32 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -24,10 +24,13 @@ * THE SOFTWARE. */ +#include + #include "supervisor/shared/tick.h" #include "supervisor/filesystem.h" #include "supervisor/shared/autoreload.h" +static atomic_bool tick_up; static volatile uint64_t ticks_ms; #if CIRCUITPY_GAMEPAD @@ -44,6 +47,7 @@ void supervisor_tick(void) { ticks_ms ++; + atomic_store(&tick_up, true); #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); @@ -74,3 +78,11 @@ uint64_t supervisor_ticks_ms64() { uint32_t supervisor_ticks_ms32() { return ticks_ms; } + +extern void run_background_tasks(void); + +void supervisor_run_background_tasks_if_tick() { + if (atomic_exchange(&tick_up, false)) { + run_background_tasks(); + } +} diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index 3defeb1081..b662734492 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -33,5 +33,6 @@ extern void supervisor_tick(void); extern uint32_t supervisor_ticks_ms32(void); extern uint64_t supervisor_ticks_ms64(void); +extern void supervisor_run_background_if_tick(void); #endif From a0ef667a1474133b1d6e4c3d74020a68f9ae1671 Mon Sep 17 00:00:00 2001 From: Ayan Pahwa Date: Tue, 19 Nov 2019 01:59:29 +0530 Subject: [PATCH 044/531] Supervisor: create code.py file with sample code --- supervisor/shared/filesystem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index c50d7f4eeb..225dd8d047 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -69,6 +69,18 @@ static void make_empty_file(FATFS *fatfs, const char *path) { f_close(&fp); } + +static void make_sample_code_file(FATFS *fatfs) { + FIL fs; + UINT *char_written = 0; + const byte buffer[] = "print('Hello World!')"; + + //Create or modify existing code.py file + f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS); + f_write(&fs, buffer, sizeof(buffer), char_written); + f_close(&fs); +} + // we don't make this function static because it needs a lot of stack and we // want it to be executed without using stack within main() function void filesystem_init(bool create_allowed, bool force_create) { @@ -98,6 +110,8 @@ void filesystem_init(bool create_allowed, bool force_create) { make_empty_file(&vfs_fat->fatfs, "/.metadata_never_index"); make_empty_file(&vfs_fat->fatfs, "/.Trashes"); make_empty_file(&vfs_fat->fatfs, "/.fseventsd/no_log"); + // make a sample code.py file + make_sample_code_file(&vfs_fat->fatfs); // create empty lib directory f_mkdir(&vfs_fat->fatfs, "/lib"); From 256abf550534b479e17dbb61170059491d8a23de Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 18 Nov 2019 16:13:27 -0500 Subject: [PATCH 045/531] Add board folders --- ports/stm32f4/boards/meowbit_v121/board.c | 39 ++ .../boards/meowbit_v121/mpconfigboard.h | 52 +++ .../boards/meowbit_v121/mpconfigboard.mk | 19 + ports/stm32f4/boards/meowbit_v121/pins.c | 33 ++ .../boards/meowbit_v121/stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ ports/stm32f4/boards/pyb_nano_v2/board.c | 39 ++ .../boards/pyb_nano_v2/mpconfigboard.h | 52 +++ .../boards/pyb_nano_v2/mpconfigboard.mk | 19 + ports/stm32f4/boards/pyb_nano_v2/pins.c | 33 ++ .../boards/pyb_nano_v2/stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ .../boards/stm32f411ce_blackpill/board.c | 39 ++ .../stm32f411ce_blackpill/mpconfigboard.h | 52 +++ .../stm32f411ce_blackpill/mpconfigboard.mk | 19 + .../boards/stm32f411ce_blackpill/pins.c | 33 ++ .../stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ 15 files changed, 1749 insertions(+) create mode 100644 ports/stm32f4/boards/meowbit_v121/board.c create mode 100644 ports/stm32f4/boards/meowbit_v121/mpconfigboard.h create mode 100644 ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/meowbit_v121/pins.c create mode 100644 ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h create mode 100644 ports/stm32f4/boards/pyb_nano_v2/board.c create mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h create mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/pyb_nano_v2/pins.c create mode 100644 ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/board.c create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/pins.c create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h diff --git a/ports/stm32f4/boards/meowbit_v121/board.c b/ports/stm32f4/boards/meowbit_v121/board.c new file mode 100644 index 0000000000..82b0c506ed --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h new file mode 100644 index 0000000000..67ddc885ae --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define AUTORESET_DELAY_MS 500 +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PB05 +#define SPI_FLASH_MISO_PIN &pin_PB04 +#define SPI_FLASH_SCK_PIN &pin_PB03 +#define SPI_FLASH_CS_PIN &pin_PA15 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PB11) +#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk new file mode 100644 index 0000000000..5bad4e81f3 --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x805A +USB_PRODUCT = "Feather STM32F405 Express" +USB_MANUFACTURER = "Adafruit Industries LLC" +USB_DEVICES = "CDC,MSC" + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f405xx +MCU_PACKAGE = 64 +CMSIS_MCU = STM32F405xx +LD_FILE = boards/STM32F405.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c new file mode 100644 index 0000000000..4aa1f362ad --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -0,0 +1,33 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..68a49b4ba8 --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h @@ -0,0 +1,440 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)40000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm32f4/boards/pyb_nano_v2/board.c b/ports/stm32f4/boards/pyb_nano_v2/board.c new file mode 100644 index 0000000000..82b0c506ed --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h new file mode 100644 index 0000000000..67ddc885ae --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define AUTORESET_DELAY_MS 500 +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PB05 +#define SPI_FLASH_MISO_PIN &pin_PB04 +#define SPI_FLASH_SCK_PIN &pin_PB03 +#define SPI_FLASH_CS_PIN &pin_PA15 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PB11) +#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk new file mode 100644 index 0000000000..5bad4e81f3 --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x805A +USB_PRODUCT = "Feather STM32F405 Express" +USB_MANUFACTURER = "Adafruit Industries LLC" +USB_DEVICES = "CDC,MSC" + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f405xx +MCU_PACKAGE = 64 +CMSIS_MCU = STM32F405xx +LD_FILE = boards/STM32F405.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/pyb_nano_v2/pins.c b/ports/stm32f4/boards/pyb_nano_v2/pins.c new file mode 100644 index 0000000000..4aa1f362ad --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/pins.c @@ -0,0 +1,33 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..68a49b4ba8 --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h @@ -0,0 +1,440 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)40000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/board.c b/ports/stm32f4/boards/stm32f411ce_blackpill/board.c new file mode 100644 index 0000000000..82b0c506ed --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h new file mode 100644 index 0000000000..67ddc885ae --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define AUTORESET_DELAY_MS 500 +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PB05 +#define SPI_FLASH_MISO_PIN &pin_PB04 +#define SPI_FLASH_SCK_PIN &pin_PB03 +#define SPI_FLASH_CS_PIN &pin_PA15 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PB11) +#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk new file mode 100644 index 0000000000..5bad4e81f3 --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x805A +USB_PRODUCT = "Feather STM32F405 Express" +USB_MANUFACTURER = "Adafruit Industries LLC" +USB_DEVICES = "CDC,MSC" + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f405xx +MCU_PACKAGE = 64 +CMSIS_MCU = STM32F405xx +LD_FILE = boards/STM32F405.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c new file mode 100644 index 0000000000..4aa1f362ad --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c @@ -0,0 +1,33 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..68a49b4ba8 --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h @@ -0,0 +1,440 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)40000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From b3d7467719ad432614efd725f937f70cdf444cd3 Mon Sep 17 00:00:00 2001 From: ndgarage Date: Tue, 19 Nov 2019 14:52:09 -0700 Subject: [PATCH 046/531] add-ndbit6 --- .github/workflows/build.yml | 1 + ports/atmel-samd/boards/ndbit6/board.c | 39 ++++++++++++++++++ .../atmel-samd/boards/ndbit6/mpconfigboard.h | 36 +++++++++++++++++ .../atmel-samd/boards/ndbit6/mpconfigboard.mk | 17 ++++++++ ports/atmel-samd/boards/ndbit6/pins.c | 40 +++++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 ports/atmel-samd/boards/ndbit6/board.c create mode 100644 ports/atmel-samd/boards/ndbit6/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/ndbit6/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/ndbit6/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10c34355d1..3356b68427 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,6 +121,7 @@ jobs: - "metro_nrf52840_express" - "mini_sam_m4" - "monster_m4sk" + - "ndbit6" - "particle_argon" - "particle_boron" - "particle_xenon" diff --git a/ports/atmel-samd/boards/ndbit6/board.c b/ports/atmel-samd/boards/ndbit6/board.c new file mode 100644 index 0000000000..0f60736a24 --- /dev/null +++ b/ports/atmel-samd/boards/ndbit6/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/ndbit6/mpconfigboard.h b/ports/atmel-samd/boards/ndbit6/mpconfigboard.h new file mode 100644 index 0000000000..98c64def71 --- /dev/null +++ b/ports/atmel-samd/boards/ndbit6/mpconfigboard.h @@ -0,0 +1,36 @@ +#define MICROPY_HW_BOARD_NAME "NDBit6" +#define MICROPY_HW_MCU_NAME "samd21e18" + +// LED status +#define MICROPY_HW_LED_STATUS (&pin_PA23) + +// These are pins not to reset. +//#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01) +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code. +#define CIRCUITPY_INTERNAL_NVM_SIZE 256 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define DEFAULT_I2C_BUS_SCL (&pin_PA17) +#define DEFAULT_I2C_BUS_SDA (&pin_PA16) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA17) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA16) +#define DEFAULT_SPI_BUS_MISO (&pin_PA18) + +#define DEFAULT_UART_BUS_RX (&pin_PA17) +#define DEFAULT_UART_BUS_TX (&pin_PA16) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 + +// Not connected +//#define IGNORE_PIN_PA13 1 +//#define IGNORE_PIN_PA28 1 + diff --git a/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk b/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk new file mode 100644 index 0000000000..484d61762d --- /dev/null +++ b/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk @@ -0,0 +1,17 @@ +LD_FILE = boards/samd21x18-bootloader-crystalless.ld +USB_VID = 0x239A +USB_PID = 0x8066 +USB_PRODUCT = "ndbit6" +USB_MANUFACTURER = "ndGarage" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 + +SUPEROPT_GC = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_GAMEPAD = 0 diff --git a/ports/atmel-samd/boards/ndbit6/pins.c b/ports/atmel-samd/boards/ndbit6/pins.c new file mode 100644 index 0000000000..0bf6866561 --- /dev/null +++ b/ports/atmel-samd/boards/ndbit6/pins.c @@ -0,0 +1,40 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_PA23) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA04) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); + From 11c2c3443f65e6d0342417c5dbc42302992710da Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 19 Nov 2019 13:55:58 -0800 Subject: [PATCH 047/531] Add support for extended (>31 byte) BLE advertisements. --- ports/nrf/common-hal/_bleio/Adapter.c | 37 +++++++++++++++++++++------ shared-bindings/_bleio/Adapter.c | 3 +++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 295a42d63b..f7f1198534 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -508,8 +508,9 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre // The nRF SD 6.1.0 can only do one concurrent advertisement so share the advertising handle. uint8_t adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; -STATIC void check_data_fit(size_t data_len) { - if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) { +STATIC void check_data_fit(size_t data_len, bool connectable) { + if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED || + (connectable && data_len > BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED)) { mp_raise_ValueError(translate("Data too large for advertisement packet")); } } @@ -525,11 +526,31 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, common_hal_bleio_adapter_stop_advertising(self); } + + bool extended = advertising_data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX || + scan_response_data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX; + + uint8_t adv_type; + if (extended) { + if (connectable) { + adv_type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED; + } else if (scan_response_data_len > 0) { + adv_type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED; + } else { + adv_type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED; + } + } else if (connectable) { + adv_type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + } else if (scan_response_data_len > 0) { + adv_type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED; + } else { + adv_type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED; + } + uint32_t err_code; ble_gap_adv_params_t adv_params = { .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS), - .properties.type = connectable ? BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED - : BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED, + .properties.type = adv_type, .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED, .filter_policy = BLE_GAP_ADV_FP_ANY, .primary_phy = BLE_GAP_PHY_1MBPS, @@ -564,15 +585,15 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool uint32_t err_code; - check_data_fit(advertising_data_bufinfo->len); - check_data_fit(scan_response_data_bufinfo->len); + check_data_fit(advertising_data_bufinfo->len, connectable); + check_data_fit(scan_response_data_bufinfo->len, connectable); // The advertising data buffers must not move, because the SoftDevice depends on them. // So make them long-lived and reuse them onwards. if (self->advertising_data == NULL) { - self->advertising_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true); + self->advertising_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED * sizeof(uint8_t), false, true); } if (self->scan_response_data == NULL) { - self->scan_response_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true); + self->scan_response_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED * sizeof(uint8_t), false, true); } memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len); diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 24a70f4084..8efdb387ad 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -144,6 +144,9 @@ const mp_obj_property_t bleio_adapter_name_obj = { //| Starts advertising until `stop_advertising` is called or if connectable, another device //| connects to us. //| +//| .. warning: If data is longer than 31 bytes, then this will automatically advertise as an +//| extended advertisement that older BLE 4.x clients won't be able to scan for. +//| //| :param buf data: advertising data packet bytes //| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed. //| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral. From 9764006f81b6d8a14421f78777259bc3fd0ef015 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 20 Nov 2019 15:30:31 -0500 Subject: [PATCH 048/531] add F401 pin definition --- ports/stm32f4/peripherals/stm32f4/periph.h | 5 + .../peripherals/stm32f4/stm32f401xe/clocks.c | 61 +++++++ .../peripherals/stm32f4/stm32f401xe/gpio.c | 54 ++++++ .../peripherals/stm32f4/stm32f401xe/periph.c | 172 ++++++++++++++++++ .../peripherals/stm32f4/stm32f401xe/periph.h | 57 ++++++ .../peripherals/stm32f4/stm32f401xe/pins.c | 123 +++++++++++++ .../peripherals/stm32f4/stm32f401xe/pins.h | 121 ++++++++++++ 7 files changed, 593 insertions(+) create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h diff --git a/ports/stm32f4/peripherals/stm32f4/periph.h b/ports/stm32f4/peripherals/stm32f4/periph.h index 4b00ce1d92..02304c626c 100644 --- a/ports/stm32f4/peripherals/stm32f4/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/periph.h @@ -140,6 +140,11 @@ typedef struct { //Starter Lines +#ifdef STM32F411xE +#define HAS_DAC 0 +#include "stm32f401xe/periph.h" +#endif + #ifdef STM32F411xE #define HAS_DAC 0 #include "stm32f411xe/periph.h" diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c new file mode 100644 index 0000000000..883c252d51 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c @@ -0,0 +1,61 @@ + +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" + +void stm32f4_peripherals_clocks_init(void) { + //System clock init + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; + RCC_OscInitStruct.PLL.PLLQ = 7; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); +} diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c new file mode 100644 index 0000000000..45dc8fc6fa --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c @@ -0,0 +1,54 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" +#include "stm32f4/gpio.h" +#include "common-hal/microcontroller/Pin.h" + +void stm32f4_peripherals_gpio_init(void) { + //Enable all GPIO for now + GPIO_InitTypeDef GPIO_InitStruct = {0}; + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + + //Never reset pins + never_reset_pin_number(2,13); //PC13 anti tamp + never_reset_pin_number(2,14); //PC14 OSC32_IN + never_reset_pin_number(2,15); //PC15 OSC32_OUT + never_reset_pin_number(0,13); //PA13 SWDIO + never_reset_pin_number(0,14); //PA14 SWCLK +} + +//LEDs are inverted on F411 DISCO +void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { +} + + diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c new file mode 100644 index 0000000000..859e9a1adb --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c @@ -0,0 +1,172 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" +#include "py/mphal.h" +#include "stm32f4/pins.h" +#include "stm32f4/periph.h" + +// I2C + +I2C_TypeDef * mcu_i2c_banks[3] = {I2C1, I2C2, I2C3}; + +const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5] = { + I2C_SDA(1, 4, &pin_PB07), + I2C_SDA(1, 4, &pin_PB09), + I2C_SDA(2, 9, &pin_PB03), + I2C_SDA(3, 4, &pin_PC09), + I2C_SDA(3, 9, &pin_PB04), +}; + +const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { + I2C_SCL(1, 4, &pin_PB06), + I2C_SCL(1, 4, &pin_PB08), + I2C_SCL(2, 4, &pin_PB10), + I2C_SCL(3, 4, &pin_PA08) +}; + +// SPI + +SPI_TypeDef * mcu_spi_banks[4] = {SPI1, SPI2, SPI3, SPI4}; + +const mcu_spi_sck_obj_t mcu_spi_sck_list[9] = { + SPI(1, 5, &pin_PA05), + SPI(1, 5, &pin_PB03), + SPI(2, 5, &pin_PB10), + SPI(2, 5, &pin_PB13), + SPI(2, 5, &pin_PD03), + SPI(3, 6, &pin_PB03), + SPI(3, 6, &pin_PC10), + SPI(4, 5, &pin_PE02), + SPI(4, 5, &pin_PE12), +}; + +const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9] = { + SPI(1, 5, &pin_PA07), + SPI(1, 5, &pin_PB05), + SPI(2, 5, &pin_PB15), + SPI(2, 5, &pin_PC03), + SPI(3, 6, &pin_PB05), + SPI(3, 6, &pin_PC12), + SPI(3, 5, &pin_PD06), + SPI(4, 5, &pin_PE06), + SPI(4, 5, &pin_PE14), +}; + +const mcu_spi_miso_obj_t mcu_spi_miso_list[8] = { + SPI(1, 5, &pin_PA06), + SPI(1, 5, &pin_PB04), + SPI(2, 5, &pin_PB14), + SPI(2, 5, &pin_PC02), + SPI(3, 6, &pin_PB04), + SPI(3, 6, &pin_PC11), + SPI(4, 5, &pin_PE05), + SPI(4, 5, &pin_PE13), +}; + +const mcu_spi_nss_obj_t mcu_spi_nss_list[9] = { + SPI(1, 5, &pin_PA04), + SPI(1, 5, &pin_PA15), + SPI(2, 5, &pin_PB09), + SPI(2, 5, &pin_PB12), + SPI(3, 6, &pin_PA04), + SPI(3, 6, &pin_PA15), + SPI(4, 6, &pin_PB12), + SPI(4, 5, &pin_PE04), + SPI(4, 5, &pin_PE11), +}; + +USART_TypeDef * mcu_uart_banks[MAX_UART] = {USART1, USART2, NULL, NULL, NULL, USART6}; +bool mcu_uart_has_usart[MAX_UART] = {true, true, false, false, false, true}; + +const mcu_uart_tx_obj_t mcu_uart_tx_list[6] = { + UART(2, 7, &pin_PA02), + UART(1, 7, &pin_PA09), + UART(6, 8, &pin_PA11), + UART(1, 7, &pin_PB06), + UART(6, 8, &pin_PC06), + UART(2, 7, &pin_PD05), +}; + +const mcu_uart_rx_obj_t mcu_uart_rx_list[6] = { + UART(2, 7, &pin_PA03), + UART(1, 7, &pin_PA10), + UART(6, 8, &pin_PA12), + UART(1, 7, &pin_PB07), + UART(6, 8, &pin_PC07), + UART(2, 7, &pin_PD06), +}; + +//Timers +//TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins +TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10, + TIM11, NULL, NULL, NULL}; + +const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { + TIM(2,1,1,&pin_PA00), + TIM(5,2,1,&pin_PA00), + TIM(2,1,2,&pin_PA01), + TIM(5,2,2,&pin_PA01), + TIM(2,1,3,&pin_PA02), + TIM(5,2,3,&pin_PA02), + TIM(2,1,4,&pin_PA03), + TIM(5,2,4,&pin_PA03), + TIM(9,3,1,&pin_PA02), + TIM(9,3,2,&pin_PA03), + TIM(3,2,1,&pin_PA06), + TIM(3,2,2,&pin_PA07), + TIM(1,1,1,&pin_PA08), + TIM(1,1,2,&pin_PA09), + TIM(1,1,3,&pin_PA10), + TIM(1,1,4,&pin_PA11), + TIM(2,1,1,&pin_PA15), + TIM(3,2,3,&pin_PB00), + TIM(3,2,4,&pin_PB01), + TIM(2,1,2,&pin_PB03), + TIM(3,2,1,&pin_PB04), + TIM(3,2,2,&pin_PB05), + TIM(4,2,1,&pin_PB06), + TIM(4,2,2,&pin_PB07), + TIM(4,2,3,&pin_PB08), + TIM(10,2,1,&pin_PB08), + TIM(4,2,4,&pin_PB09), + TIM(11,2,1,&pin_PB09), + TIM(2,1,3,&pin_PB10), + TIM(3,2,1,&pin_PC06), + TIM(3,2,2,&pin_PC07), + TIM(3,2,3,&pin_PC08), + TIM(3,2,4,&pin_PC09), + TIM(4,2,1,&pin_PD12), + TIM(4,2,2,&pin_PD13), + TIM(4,2,3,&pin_PD14), + TIM(4,2,4,&pin_PD15), + TIM(9,3,1,&pin_PE05), + TIM(9,3,2,&pin_PE06), + TIM(1,1,1,&pin_PE09), + TIM(1,1,2,&pin_PE11), + TIM(1,1,3,&pin_PE13), + TIM(1,1,4,&pin_PE14), +}; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h new file mode 100644 index 0000000000..7d3f4dca22 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h @@ -0,0 +1,57 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H + +//I2C +extern I2C_TypeDef * mcu_i2c_banks[3]; + +extern const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5]; +extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; + +//SPI +extern SPI_TypeDef * mcu_spi_banks[4]; + +extern const mcu_spi_sck_obj_t mcu_spi_sck_list[9]; +extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9]; +extern const mcu_spi_miso_obj_t mcu_spi_miso_list[8]; +extern const mcu_spi_nss_obj_t mcu_spi_nss_list[9]; + +//UART +extern USART_TypeDef * mcu_uart_banks[MAX_UART]; +extern bool mcu_uart_has_usart[MAX_UART]; + +extern const mcu_uart_tx_obj_t mcu_uart_tx_list[6]; +extern const mcu_uart_rx_obj_t mcu_uart_rx_list[6]; + +//Timers +#define TIM_BANK_ARRAY_LEN 14 +#define TIM_PIN_ARRAY_LEN 44 +TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN]; +const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c new file mode 100644 index 0000000000..7e88c3dcba --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c @@ -0,0 +1,123 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" +#include "py/mphal.h" +#include "stm32f4/pins.h" + +const mcu_pin_obj_t pin_PE02 = PIN(4, 2, NO_ADC); +const mcu_pin_obj_t pin_PE03 = PIN(4, 3, NO_ADC); +const mcu_pin_obj_t pin_PE04 = PIN(4, 4, NO_ADC); +const mcu_pin_obj_t pin_PE05 = PIN(4, 5, NO_ADC); +const mcu_pin_obj_t pin_PE06 = PIN(4, 6, NO_ADC); + +const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); //anti-tamp +const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); //OSC32_IN +const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); //OSC32_OUT + +const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_1,10)); +const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_1,11)); +const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_1,12)); +const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_1,13)); + +const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1,0)); +const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1,1)); +const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1,2)); +const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1,3)); +const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1,4)); +const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1,5)); +const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1,6)); +const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1,7)); + +const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_1,14)); +const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_1,15)); + +const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1,8)); +const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1,9)); +const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); + +const mcu_pin_obj_t pin_PE07 = PIN(4, 7, NO_ADC); +const mcu_pin_obj_t pin_PE08 = PIN(4, 8, NO_ADC); +const mcu_pin_obj_t pin_PE09 = PIN(4, 9, NO_ADC); +const mcu_pin_obj_t pin_PE10 = PIN(4, 10, NO_ADC); +const mcu_pin_obj_t pin_PE11 = PIN(4, 11, NO_ADC); +const mcu_pin_obj_t pin_PE12 = PIN(4, 12, NO_ADC); +const mcu_pin_obj_t pin_PE13 = PIN(4, 13, NO_ADC); +const mcu_pin_obj_t pin_PE14 = PIN(4, 14, NO_ADC); +const mcu_pin_obj_t pin_PE15 = PIN(4, 15, NO_ADC); + +const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); +const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); +const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); +const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); +const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); + +const mcu_pin_obj_t pin_PD08 = PIN(3, 8, NO_ADC); +const mcu_pin_obj_t pin_PD09 = PIN(3, 9, NO_ADC); +const mcu_pin_obj_t pin_PD10 = PIN(3, 10, NO_ADC); +const mcu_pin_obj_t pin_PD11 = PIN(3, 11, NO_ADC); +const mcu_pin_obj_t pin_PD12 = PIN(3, 12, NO_ADC); +const mcu_pin_obj_t pin_PD13 = PIN(3, 13, NO_ADC); +const mcu_pin_obj_t pin_PD14 = PIN(3, 14, NO_ADC); +const mcu_pin_obj_t pin_PD15 = PIN(3, 15, NO_ADC); + +const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); +const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); +const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); +const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); + +const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); +const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); +const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); +const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); +const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); +const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); //SWDIO +const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); //SWCLK +const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); //JTDI + +const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); +const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); +const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); + +const mcu_pin_obj_t pin_PD00 = PIN(3, 0, NO_ADC); +const mcu_pin_obj_t pin_PD01 = PIN(3, 1, NO_ADC); +const mcu_pin_obj_t pin_PD02 = PIN(3, 2, NO_ADC); +const mcu_pin_obj_t pin_PD03 = PIN(3, 3, NO_ADC); +const mcu_pin_obj_t pin_PD04 = PIN(3, 4, NO_ADC); +const mcu_pin_obj_t pin_PD05 = PIN(3, 5, NO_ADC); +const mcu_pin_obj_t pin_PD06 = PIN(3, 6, NO_ADC); +const mcu_pin_obj_t pin_PD07 = PIN(3, 7, NO_ADC); + +const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); +const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); +const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); +const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); +const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); +const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); +const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); + +const mcu_pin_obj_t pin_PE00 = PIN(4, 0, NO_ADC); +const mcu_pin_obj_t pin_PE01 = PIN(4, 1, NO_ADC); \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h new file mode 100644 index 0000000000..37d3a5cf11 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h @@ -0,0 +1,121 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H + +//Pins in datasheet order: DocID026289 Rev 7 page 38. LQFP100 only +//pg 38 +extern const mcu_pin_obj_t pin_PE02; +extern const mcu_pin_obj_t pin_PE03; +extern const mcu_pin_obj_t pin_PE04; +extern const mcu_pin_obj_t pin_PE05; +//pg 39 +extern const mcu_pin_obj_t pin_PE06; +extern const mcu_pin_obj_t pin_PC13; +extern const mcu_pin_obj_t pin_PC14; +extern const mcu_pin_obj_t pin_PC15; +extern const mcu_pin_obj_t pin_PC00; +extern const mcu_pin_obj_t pin_PC01; +extern const mcu_pin_obj_t pin_PC02; +extern const mcu_pin_obj_t pin_PC03; +//pg 40 +extern const mcu_pin_obj_t pin_PA00; +extern const mcu_pin_obj_t pin_PA01; +extern const mcu_pin_obj_t pin_PA02; +extern const mcu_pin_obj_t pin_PA03; +extern const mcu_pin_obj_t pin_PA04; +extern const mcu_pin_obj_t pin_PA05; +extern const mcu_pin_obj_t pin_PA06; +extern const mcu_pin_obj_t pin_PA07; +//pg 41 +extern const mcu_pin_obj_t pin_PC04; +extern const mcu_pin_obj_t pin_PC05; +extern const mcu_pin_obj_t pin_PB00; +extern const mcu_pin_obj_t pin_PB01; +extern const mcu_pin_obj_t pin_PB02; +extern const mcu_pin_obj_t pin_PE07; +extern const mcu_pin_obj_t pin_PE08; +extern const mcu_pin_obj_t pin_PE09; +extern const mcu_pin_obj_t pin_PE10; +extern const mcu_pin_obj_t pin_PE11; +extern const mcu_pin_obj_t pin_PE12; +extern const mcu_pin_obj_t pin_PE13; +extern const mcu_pin_obj_t pin_PE14; +extern const mcu_pin_obj_t pin_PE15; +//pg 42 +extern const mcu_pin_obj_t pin_PB10; +extern const mcu_pin_obj_t pin_PB12; +extern const mcu_pin_obj_t pin_PB13; +extern const mcu_pin_obj_t pin_PB14; +extern const mcu_pin_obj_t pin_PB15; +extern const mcu_pin_obj_t pin_PD08; +extern const mcu_pin_obj_t pin_PD09; +extern const mcu_pin_obj_t pin_PD10; +extern const mcu_pin_obj_t pin_PD11; +extern const mcu_pin_obj_t pin_PD12; +//pg 43 +extern const mcu_pin_obj_t pin_PD13; +extern const mcu_pin_obj_t pin_PD14; +extern const mcu_pin_obj_t pin_PD15; +extern const mcu_pin_obj_t pin_PC06; +extern const mcu_pin_obj_t pin_PC07; +extern const mcu_pin_obj_t pin_PC08; +extern const mcu_pin_obj_t pin_PC09; +extern const mcu_pin_obj_t pin_PA08; +extern const mcu_pin_obj_t pin_PA09; +//pg 44 +extern const mcu_pin_obj_t pin_PA10; +extern const mcu_pin_obj_t pin_PA11; +extern const mcu_pin_obj_t pin_PA12; +extern const mcu_pin_obj_t pin_PA13; +extern const mcu_pin_obj_t pin_PA14; +extern const mcu_pin_obj_t pin_PA15; +extern const mcu_pin_obj_t pin_PC10; +extern const mcu_pin_obj_t pin_PC11; +extern const mcu_pin_obj_t pin_PC12; +//pg 45 +extern const mcu_pin_obj_t pin_PD00; +extern const mcu_pin_obj_t pin_PD01; +extern const mcu_pin_obj_t pin_PD02; +extern const mcu_pin_obj_t pin_PD03; +extern const mcu_pin_obj_t pin_PD04; +extern const mcu_pin_obj_t pin_PD05; +extern const mcu_pin_obj_t pin_PD06; +extern const mcu_pin_obj_t pin_PD07; +extern const mcu_pin_obj_t pin_PB03; +extern const mcu_pin_obj_t pin_PB04; +extern const mcu_pin_obj_t pin_PB05; +extern const mcu_pin_obj_t pin_PB06; +//pg 46 +extern const mcu_pin_obj_t pin_PB07; +extern const mcu_pin_obj_t pin_PB08; +extern const mcu_pin_obj_t pin_PB09; +extern const mcu_pin_obj_t pin_PE00; +extern const mcu_pin_obj_t pin_PE01; + + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H From 70719597ab7b3785a6641b08ef3cb82d9b6b459b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 20 Nov 2019 10:15:11 -0600 Subject: [PATCH 049/531] supervisor: tick: Rewrite without atomics --- supervisor/shared/tick.c | 17 ++++++++++------- supervisor/shared/tick.h | 1 - 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 7dc5a52d32..0be3230823 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -24,14 +24,12 @@ * THE SOFTWARE. */ -#include - #include "supervisor/shared/tick.h" #include "supervisor/filesystem.h" #include "supervisor/shared/autoreload.h" -static atomic_bool tick_up; static volatile uint64_t ticks_ms; +static volatile uint32_t background_ticks_ms32; #if CIRCUITPY_GAMEPAD #include "shared-module/gamepad/__init__.h" @@ -47,8 +45,6 @@ void supervisor_tick(void) { ticks_ms ++; - atomic_store(&tick_up, true); - #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); #endif @@ -82,7 +78,14 @@ uint32_t supervisor_ticks_ms32() { extern void run_background_tasks(void); void supervisor_run_background_tasks_if_tick() { - if (atomic_exchange(&tick_up, false)) { - run_background_tasks(); + uint32_t now32 = ticks_ms; + + if (now32 == background_ticks_ms32) { + return; } + background_ticks_ms32 = now32; + + run_background_tasks(); +} + } diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index b662734492..eb2af29ca4 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -28,7 +28,6 @@ #define __INCLUDED_SUPERVISOR_TICK_H #include -#include extern void supervisor_tick(void); extern uint32_t supervisor_ticks_ms32(void); From a9baa0f954ec757ef1e3990af136a4f0b3cb2b1e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 20 Nov 2019 10:15:33 -0600 Subject: [PATCH 050/531] supervisor: tick: document --- supervisor/shared/tick.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index eb2af29ca4..e747de2d83 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -29,9 +29,32 @@ #include +/** @brief To be called once every ms + * + * The port must call supervisor_tick once per millisecond to perform regular tasks. + * This is called from the SysTick interrupt or similar, and is safe to call in an + * interrupt context. + */ extern void supervisor_tick(void); +/** @brief Get the lower 32 bits of the time in milliseconds + * + * This can be more efficient than supervisor_ticks_ms64, for sites where a wraparound + * of ~49.5 days is not harmful. + */ extern uint32_t supervisor_ticks_ms32(void); +/** @brief Get the full time in milliseconds + * + * Because common ARM mcus cannot atomically work with 64-bit quantities, this + * function must briefly disable interrupts in order to return the value. If + * only relative durations of less than about ~49.5 days need to be considered, + * then it may be possible to use supervisor_ticks_ms64 instead. + */ 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); #endif From 46c5775ba4b9c4905f8e3f4c1842c2c6c04d8fb0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 20 Nov 2019 10:15:44 -0600 Subject: [PATCH 051/531] supervisor: tick: add supervisor_fake_tick --- supervisor/shared/tick.c | 3 +++ supervisor/shared/tick.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 0be3230823..69256081c4 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -88,4 +88,7 @@ void supervisor_run_background_tasks_if_tick() { run_background_tasks(); } +void supervisor_fake_tick() { + uint32_t now32 = ticks_ms; + background_ticks_ms32 = (now32 - 1); } diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index e747de2d83..7ce8281ba9 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -36,6 +36,13 @@ * interrupt context. */ extern void supervisor_tick(void); +/** @brief Cause background tasks to be called soon + * + * Normally, background tasks are only run once per tick. For other cases where + * an event noticed from an interrupt context needs to be completed by a background + * task activity, the interrupt can call supervisor_fake_tick. + */ +extern void supervisor_fake_tick(void); /** @brief Get the lower 32 bits of the time in milliseconds * * This can be more efficient than supervisor_ticks_ms64, for sites where a wraparound From d8d95d99984caa083a9f14754460065152eaa365 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 20 Nov 2019 15:55:13 -0500 Subject: [PATCH 052/531] Minor meowbit changes --- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 4 ++-- ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 67ddc885ae..b2d53d9999 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -26,8 +26,8 @@ //Micropython setup -#define MICROPY_HW_BOARD_NAME "Feather STM32F405 Express" -#define MICROPY_HW_MCU_NAME "STM32F405RG" +#define MICROPY_HW_BOARD_NAME "MEOWBIT" +#define MICROPY_HW_MCU_NAME "STM32F401xE" #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 5bad4e81f3..7998e04523 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -11,9 +11,9 @@ LONGINT_IMPL = MPZ MCU_SERIES = m4 MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f405xx +MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 -CMSIS_MCU = STM32F405xx +CMSIS_MCU = STM32F401xE LD_FILE = boards/STM32F405.ld TEXT0_ADDR = 0x08000000 TEXT1_ADDR = 0x08010000 \ No newline at end of file From 006182f4e867840266a0c3a669fc7938ef03a9fc Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 20 Nov 2019 15:56:00 -0500 Subject: [PATCH 053/531] Remove meowbit for now --- ports/stm32f4/boards/meowbit_v121/board.c | 39 -- .../boards/meowbit_v121/mpconfigboard.h | 52 --- .../boards/meowbit_v121/mpconfigboard.mk | 19 - ports/stm32f4/boards/meowbit_v121/pins.c | 33 -- .../boards/meowbit_v121/stm32f4xx_hal_conf.h | 440 ------------------ 5 files changed, 583 deletions(-) delete mode 100644 ports/stm32f4/boards/meowbit_v121/board.c delete mode 100644 ports/stm32f4/boards/meowbit_v121/mpconfigboard.h delete mode 100644 ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk delete mode 100644 ports/stm32f4/boards/meowbit_v121/pins.c delete mode 100644 ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h diff --git a/ports/stm32f4/boards/meowbit_v121/board.c b/ports/stm32f4/boards/meowbit_v121/board.c deleted file mode 100644 index 82b0c506ed..0000000000 --- a/ports/stm32f4/boards/meowbit_v121/board.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "boards/board.h" -#include "mpconfigboard.h" - -void board_init(void) { -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { - -} diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h deleted file mode 100644 index 67ddc885ae..0000000000 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" -#define MICROPY_HW_MCU_NAME "STM32F405RG" - -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (0x4000) - -#define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) - -// On-board flash -#define SPI_FLASH_MOSI_PIN &pin_PB05 -#define SPI_FLASH_MISO_PIN &pin_PB04 -#define SPI_FLASH_SCK_PIN &pin_PB03 -#define SPI_FLASH_CS_PIN &pin_PA15 - -#define DEFAULT_I2C_BUS_SCL (&pin_PB06) -#define DEFAULT_I2C_BUS_SDA (&pin_PB07) - -#define DEFAULT_SPI_BUS_SCK (&pin_PB13) -#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) -#define DEFAULT_SPI_BUS_MISO (&pin_PB14) - -#define DEFAULT_UART_BUS_RX (&pin_PB11) -#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk deleted file mode 100644 index 5bad4e81f3..0000000000 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ /dev/null @@ -1,19 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x805A -USB_PRODUCT = "Feather STM32F405 Express" -USB_MANUFACTURER = "Adafruit Industries LLC" -USB_DEVICES = "CDC,MSC" - -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = GD25Q16C -LONGINT_IMPL = MPZ - -MCU_SERIES = m4 -MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f405xx -MCU_PACKAGE = 64 -CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c deleted file mode 100644 index 4aa1f362ad..0000000000 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, - - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, - - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, - - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, - - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, - - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h deleted file mode 100644 index 68a49b4ba8..0000000000 --- a/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h +++ /dev/null @@ -1,440 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf_template.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32f4xx_hal_conf.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_H -#define __STM32F4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED - -#define HAL_ADC_MODULE_ENABLED -/* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CRC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ -#define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ -#define HAL_I2C_MODULE_ENABLED -#define HAL_I2S_MODULE_ENABLED -/* #define HAL_IWDG_MODULE_ENABLED */ -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_RNG_MODULE_ENABLED */ -/* #define HAL_RTC_MODULE_ENABLED */ -/* #define HAL_SAI_MODULE_ENABLED */ -/* #define HAL_SD_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ -#define HAL_PCD_MODULE_ENABLED -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_EXTI_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)40000) -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature. */ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) - -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver -* Activated: CRC code is present inside driver -* Deactivated: CRC code cleaned from driver -*/ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED - #include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED - #include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED - #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED - #include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED - #include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED - #include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED - #include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED - #include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED - #include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 13d786b2ef4803cd4bc061042aac7b8ec6f0d1d1 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 21 Nov 2019 14:27:59 -0500 Subject: [PATCH 054/531] added pin defs --- .../boards/pyb_nano_v2/mpconfigboard.h | 2 +- ports/stm32f4/boards/pyb_nano_v2/pins.c | 40 +++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h index 67ddc885ae..f9548737f3 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h @@ -26,7 +26,7 @@ //Micropython setup -#define MICROPY_HW_BOARD_NAME "Feather STM32F405 Express" +#define MICROPY_HW_BOARD_NAME "PYB LR Nano V2" #define MICROPY_HW_MCU_NAME "STM32F405RG" #define FLASH_SIZE (0x100000) diff --git a/ports/stm32f4/boards/pyb_nano_v2/pins.c b/ports/stm32f4/boards/pyb_nano_v2/pins.c index 4aa1f362ad..566ae0f1a4 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/pins.c +++ b/ports/stm32f4/boards/pyb_nano_v2/pins.c @@ -1,20 +1,34 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_Y10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_Y9), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_Y8), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_Y7), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_Y6), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_Y5), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_Y4), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_Y3), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_Y2), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_Y1), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_Y0), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + { MP_ROM_QSTR(MP_QSTR_X15), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_X14), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_X13), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_X12), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_X11), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_X10), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_X9), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_X8), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_X7), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_X6), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_X5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_X4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_X3), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_X2), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_X1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_X0), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, From 4e4ecafd97c6d2adbf27fb65f51ec3c201eab224 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 21 Nov 2019 16:53:06 -0500 Subject: [PATCH 055/531] Add definitions for PYB Nano and blackpill --- .../boards/pyb_nano_v2/mpconfigboard.h | 25 ++++---- .../boards/pyb_nano_v2/mpconfigboard.mk | 16 ++--- ports/stm32f4/boards/pyb_nano_v2/pins.c | 32 ++++++---- .../boards/pyb_nano_v2/stm32f4xx_hal_conf.h | 2 +- .../stm32f411ce_blackpill/mpconfigboard.h | 29 +++------ .../stm32f411ce_blackpill/mpconfigboard.mk | 20 +++---- .../boards/stm32f411ce_blackpill/pins.c | 59 ++++++++++--------- .../stm32f4xx_hal_conf.h | 4 +- .../stm32f411ve_discovery/mpconfigboard.h | 2 + .../stm32f4/common-hal/microcontroller/Pin.c | 4 ++ .../common-hal/microcontroller/__init__.c | 2 +- .../peripherals/stm32f4/stm32f411xe/clocks.c | 3 +- 12 files changed, 102 insertions(+), 96 deletions(-) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h index f9548737f3..7980ca93d6 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h @@ -27,26 +27,21 @@ //Micropython setup #define MICROPY_HW_BOARD_NAME "PYB LR Nano V2" -#define MICROPY_HW_MCU_NAME "STM32F405RG" +#define MICROPY_HW_MCU_NAME "STM32F411CE" -#define FLASH_SIZE (0x100000) +#define FLASH_SIZE (0x80000) #define FLASH_PAGE_SIZE (0x4000) -#define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) +#define BOARD_OSC_DIV 8 // On-board flash -#define SPI_FLASH_MOSI_PIN &pin_PB05 -#define SPI_FLASH_MISO_PIN &pin_PB04 -#define SPI_FLASH_SCK_PIN &pin_PB03 -#define SPI_FLASH_CS_PIN &pin_PA15 +#define SPI_FLASH_MOSI_PIN (&pin_PB15) +#define SPI_FLASH_MISO_PIN (&pin_PB14) +#define SPI_FLASH_SCK_PIN (&pin_PB13) +#define SPI_FLASH_CS_PIN (&pin_PB12) -#define DEFAULT_I2C_BUS_SCL (&pin_PB06) -#define DEFAULT_I2C_BUS_SDA (&pin_PB07) +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 -#define DEFAULT_SPI_BUS_SCK (&pin_PB13) -#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) -#define DEFAULT_SPI_BUS_MISO (&pin_PB14) +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) -#define DEFAULT_UART_BUS_RX (&pin_PB11) -#define DEFAULT_UART_BUS_TX (&pin_PB10) +#define AUTORESET_DELAY_MS 500 diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk index 5bad4e81f3..918f79f96e 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk @@ -1,19 +1,19 @@ USB_VID = 0x239A USB_PID = 0x805A -USB_PRODUCT = "Feather STM32F405 Express" -USB_MANUFACTURER = "Adafruit Industries LLC" +USB_PRODUCT = "PYB LR Nano V2" +USB_MANUFACTURER = "MicroPython Chinese Community" USB_DEVICES = "CDC,MSC" SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = GD25Q16C +EXTERNAL_FLASH_DEVICES = W25Q64JV_IQ LONGINT_IMPL = MPZ MCU_SERIES = m4 MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f405xx -MCU_PACKAGE = 64 -CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld +MCU_SUB_VARIANT = stm32f411xe +MCU_PACKAGE = 48 +CMSIS_MCU = STM32F411xE +LD_FILE = boards/STM32F411VETx_FLASH.ld TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 \ No newline at end of file +TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/pyb_nano_v2/pins.c b/ports/stm32f4/boards/pyb_nano_v2/pins.c index 566ae0f1a4..e10124f6af 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/pins.c +++ b/ports/stm32f4/boards/pyb_nano_v2/pins.c @@ -30,18 +30,30 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_X1), MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_X0), MP_ROM_PTR(&pin_PA00) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_SCL2), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_SDA3), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_SCL3), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_SCK1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_MISO1), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_MOSI1), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_SCK2), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MISO2), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI2), MP_ROM_PTR(&pin_PB15) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA03) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_LED_YELLOW), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_PA03) }, + + { MP_ROM_QSTR(MP_QSTR_SW), MP_ROM_PTR(&pin_PC13) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h index 68a49b4ba8..ab04df3182 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h +++ b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h @@ -93,7 +93,7 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ + #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index 67ddc885ae..8a482ce7dc 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -26,27 +26,16 @@ //Micropython setup -#define MICROPY_HW_BOARD_NAME "Feather STM32F405 Express" -#define MICROPY_HW_MCU_NAME "STM32F405RG" +#define MICROPY_HW_BOARD_NAME "stm32f411ce-blackpill" +#define MICROPY_HW_MCU_NAME "STM32F411CE" -#define FLASH_SIZE (0x100000) +#define FLASH_SIZE (0x80000) #define FLASH_PAGE_SIZE (0x4000) +#define BOARD_OSC_DIV 25 + +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) + #define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) - -// On-board flash -#define SPI_FLASH_MOSI_PIN &pin_PB05 -#define SPI_FLASH_MISO_PIN &pin_PB04 -#define SPI_FLASH_SCK_PIN &pin_PB03 -#define SPI_FLASH_CS_PIN &pin_PA15 - -#define DEFAULT_I2C_BUS_SCL (&pin_PB06) -#define DEFAULT_I2C_BUS_SDA (&pin_PB07) - -#define DEFAULT_SPI_BUS_SCK (&pin_PB13) -#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) -#define DEFAULT_SPI_BUS_MISO (&pin_PB14) - -#define DEFAULT_UART_BUS_RX (&pin_PB11) -#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk index 5bad4e81f3..4d3644d4f6 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk @@ -1,19 +1,17 @@ USB_VID = 0x239A USB_PID = 0x805A -USB_PRODUCT = "Feather STM32F405 Express" -USB_MANUFACTURER = "Adafruit Industries LLC" +USB_PRODUCT = "stm32f411ce-blackpill" +USB_MANUFACTURER = "Unknown" USB_DEVICES = "CDC,MSC" -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = GD25Q16C -LONGINT_IMPL = MPZ +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f405xx -MCU_PACKAGE = 64 -CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld +MCU_SUB_VARIANT = stm32f411xe +MCU_PACKAGE = 48 +CMSIS_MCU = STM32F411xE +LD_FILE = boards/STM32F411VETx_FLASH.ld TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 \ No newline at end of file +TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c index 4aa1f362ad..0846cee673 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c @@ -1,33 +1,38 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_B12), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_B13), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_B14), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_B15), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_B3), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_B4), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_B5), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_B6), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_B7), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_B8), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_B9), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, - - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, - - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, - - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, - - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_B10), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_B2), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_B1), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_B0), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_C15), MP_ROM_PTR(&pin_PC15) }, + { MP_ROM_QSTR(MP_QSTR_C14), MP_ROM_PTR(&pin_PC14) }, + { MP_ROM_QSTR(MP_QSTR_C13), MP_ROM_PTR(&pin_PC13) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h index 68a49b4ba8..81d29f2420 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h @@ -67,7 +67,7 @@ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ -#define HAL_PCD_MODULE_ENABLED +/* #define HAL_PCD_MODULE_ENABLED */ /* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_DSI_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ @@ -93,7 +93,7 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ + #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h index d7898ba0b8..0c6f537f87 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h @@ -32,6 +32,8 @@ #define FLASH_SIZE (0x80000) //512K #define FLASH_PAGE_SIZE (0x4000) //16K +#define BOARD_OSC_DIV 8 + #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) diff --git a/ports/stm32f4/common-hal/microcontroller/Pin.c b/ports/stm32f4/common-hal/microcontroller/Pin.c index 21290e03c9..615e483585 100644 --- a/ports/stm32f4/common-hal/microcontroller/Pin.c +++ b/ports/stm32f4/common-hal/microcontroller/Pin.c @@ -46,8 +46,12 @@ bool neopixel_in_use; #elif MCU_PACKAGE == 64 #define GPIO_PORT_COUNT 3 GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC}; +#elif MCU_PACKAGE == 48 + #define GPIO_PORT_COUNT 3 + GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC}; #endif + STATIC uint16_t claimed_pins[GPIO_PORT_COUNT]; STATIC uint16_t never_reset_pins[GPIO_PORT_COUNT]; diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c index c7493a4d60..7e45e8ed8b 100644 --- a/ports/stm32f4/common-hal/microcontroller/__init__.c +++ b/ports/stm32f4/common-hal/microcontroller/__init__.c @@ -169,7 +169,7 @@ STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) }, #endif { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, -#if MCU_PACKAGE != 100 +#if MCU_PACKAGE == 144 { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, #endif { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c index 883c252d51..53810af263 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c @@ -25,6 +25,7 @@ * THE SOFTWARE. */ #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" void stm32f4_peripherals_clocks_init(void) { //System clock init @@ -44,7 +45,7 @@ void stm32f4_peripherals_clocks_init(void) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLM = BOARD_OSC_DIV; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLQ = 7; From b5ff9684bb3eda2b8a080d809e288dcd1ee644d7 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 21 Nov 2019 17:09:28 -0500 Subject: [PATCH 056/531] remove misplaced status LED definitions --- .../peripherals/stm32f4/stm32f411xe/gpio.c | 111 ------------------ 1 file changed, 111 deletions(-) diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c index 2b80647c0e..ed1c33b642 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c @@ -24,86 +24,6 @@ * THE SOFTWARE. */ -/* GPIO PIN REFERENCE -#define DATA_Ready_Pin GPIO_PIN_2 -#define DATA_Ready_GPIO_Port GPIOE -#define CS_I2C_SPI_Pin GPIO_PIN_3 -#define CS_I2C_SPI_GPIO_Port GPIOE -#define INT1_Pin GPIO_PIN_4 -#define INT1_GPIO_Port GPIOE -#define INT2_Pin GPIO_PIN_5 -#define INT2_GPIO_Port GPIOE -#define PC14_OSC32_IN_Pin GPIO_PIN_14 -#define PC14_OSC32_IN_GPIO_Port GPIOC -#define PC15_OSC32_OUT_Pin GPIO_PIN_15 -#define PC15_OSC32_OUT_GPIO_Port GPIOC -#define PH0_OSC_IN_Pin GPIO_PIN_0 -#define PH0_OSC_IN_GPIO_Port GPIOH -#define PH1_OSC_OUT_Pin GPIO_PIN_1 -#define PH1_OSC_OUT_GPIO_Port GPIOH -#define OTG_FS_PowerSwitchOn_Pin GPIO_PIN_0 -#define OTG_FS_PowerSwitchOn_GPIO_Port GPIOC -#define PDM_OUT_Pin GPIO_PIN_3 -#define PDM_OUT_GPIO_Port GPIOC -#define I2S3_WS_Pin GPIO_PIN_4 -#define I2S3_WS_GPIO_Port GPIOA -#define SPI1_SCK_Pin GPIO_PIN_5 -#define SPI1_SCK_GPIO_Port GPIOA -#define SPI1_MISO_Pin GPIO_PIN_6 -#define SPI1_MISO_GPIO_Port GPIOA -#define SPI1_MOSI_Pin GPIO_PIN_7 -#define SPI1_MOSI_GPIO_Port GPIOA -#define CLK_IN_Pin GPIO_PIN_10 -#define CLK_IN_GPIO_Port GPIOB -#define LD4_Pin GPIO_PIN_12 -#define LD4_GPIO_Port GPIOD -#define LD3_Pin GPIO_PIN_13 -#define LD3_GPIO_Port GPIOD -#define LD5_Pin GPIO_PIN_14 -#define LD5_GPIO_Port GPIOD -#define LD6_Pin GPIO_PIN_15 -#define LD6_GPIO_Port GPIOD -#define I2S3_MCK_Pin GPIO_PIN_7 -#define I2S3_MCK_GPIO_Port GPIOC -#define VBUS_FS_Pin GPIO_PIN_9 -#define VBUS_FS_GPIO_Port GPIOA -#define OTG_FS_ID_Pin GPIO_PIN_10 -#define OTG_FS_ID_GPIO_Port GPIOA -#define OTG_FS_DM_Pin GPIO_PIN_11 -#define OTG_FS_DM_GPIO_Port GPIOA -#define OTG_FS_DP_Pin GPIO_PIN_12 -#define OTG_FS_DP_GPIO_Port GPIOA -#define SWDIO_Pin GPIO_PIN_13 -#define SWDIO_GPIO_Port GPIOA -#define SWCLK_Pin GPIO_PIN_14 -#define SWCLK_GPIO_Port GPIOA -#define I2S3_SCK_Pin GPIO_PIN_10 -#define I2S3_SCK_GPIO_Port GPIOC -#define I2S3_SD_Pin GPIO_PIN_12 -#define I2S3_SD_GPIO_Port GPIOC -#define Audio_RST_Pin GPIO_PIN_4 -#define Audio_RST_GPIO_Port GPIOD -#define OTG_FS_OverCurrent_Pin GPIO_PIN_5 -#define OTG_FS_OverCurrent_GPIO_Port GPIOD -#define SWO_Pin GPIO_PIN_3 -#define SWO_GPIO_Port GPIOB -#define Audio_SCL_Pin GPIO_PIN_6 -#define Audio_SCL_GPIO_Port GPIOB -#define Audio_SDA_Pin GPIO_PIN_9 -#define Audio_SDA_GPIO_Port GPIOB -#define MEMS_INT2_Pin GPIO_PIN_1 -#define MEMS_INT2_GPIO_Port GPIOE -*/ - -#define LD4_Pin GPIO_PIN_12 -#define LD4_GPIO_Port GPIOD -#define LD3_Pin GPIO_PIN_13 -#define LD3_GPIO_Port GPIOD -#define LD5_Pin GPIO_PIN_14 -#define LD5_GPIO_Port GPIOD -#define LD6_Pin GPIO_PIN_15 -#define LD6_GPIO_Port GPIOD - #include "stm32f4xx_hal.h" #include "stm32f4/gpio.h" #include "common-hal/microcontroller/Pin.h" @@ -119,31 +39,12 @@ void stm32f4_peripherals_gpio_init(void) { __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pins : LD4_Pin LD3_Pin LD5_Pin LD6_Pin */ - GPIO_InitStruct.Pin = LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - //Status LED chain - stm32f4_peripherals_status_led(0,1); - stm32f4_peripherals_status_led(1,0); - stm32f4_peripherals_status_led(2,0); - stm32f4_peripherals_status_led(3,0); - //Never reset pins never_reset_pin_number(2,13); //PC13 anti tamp never_reset_pin_number(2,14); //PC14 OSC32_IN never_reset_pin_number(2,15); //PC15 OSC32_OUT never_reset_pin_number(0,13); //PA13 SWDIO never_reset_pin_number(0,14); //PA14 SWCLK - never_reset_pin_number(0,15); //PA15 JTDI - never_reset_pin_number(1,3); //PB3 JTDO - never_reset_pin_number(1,4); //PB4 JTRST // Port H is not included in GPIO port array // never_reset_pin_number(5,0); //PH0 JTDO @@ -152,18 +53,6 @@ void stm32f4_peripherals_gpio_init(void) { //LEDs are inverted on F411 DISCO void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { - switch(led) - { - case 0: HAL_GPIO_WritePin(GPIOD, LD4_Pin, (state ^ 1)); - break; - case 1: HAL_GPIO_WritePin(GPIOD, LD3_Pin, (state ^ 1)); - break; - case 2: HAL_GPIO_WritePin(GPIOD, LD5_Pin, (state ^ 1)); - break; - case 3: HAL_GPIO_WritePin(GPIOD, LD6_Pin, (state ^ 1)); - break; - default: break; - } } From b3ad823b4cb741e3c7120d0768f5cff2757b6361 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 21 Nov 2019 17:39:14 -0500 Subject: [PATCH 057/531] yaml additions --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d5793573f..0f37e1b957 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -132,6 +132,7 @@ jobs: - "pybadge" - "pybadge_airlift" - "pyboard_v11" + - "pyb_nano_v2" - "pygamer" - "pygamer_advance" - "pyportal" @@ -149,6 +150,7 @@ jobs: - "sparkfun_samd21_dev" - "sparkfun_samd21_mini" - "spresense" + - "stm32f411ce_blackpill" - "stm32f411ve_discovery" - "stm32f412zg_discovery" - "stringcar_m0_express" From 5b907aa076f39b24565ea2802be078fb0acc7887 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 21 Nov 2019 18:24:10 -0500 Subject: [PATCH 058/531] change order --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f37e1b957..c0ab6f68b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,10 +129,10 @@ jobs: - "pewpew10" - "pewpew_m4" - "pirkey_m0" + - "pyb_nano_v2" - "pybadge" - "pybadge_airlift" - "pyboard_v11" - - "pyb_nano_v2" - "pygamer" - "pygamer_advance" - "pyportal" From 6a7c8d634118f3e6214c64ea85029d3e84ead605 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 21 Nov 2019 20:56:05 -0500 Subject: [PATCH 059/531] minor fix --- ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c index ed1c33b642..2b0e2b2888 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c @@ -29,9 +29,7 @@ #include "common-hal/microcontroller/Pin.h" void stm32f4_peripherals_gpio_init(void) { - //Enable all GPIO for now - GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* GPIO Ports Clock Enable */ + //* GPIO Ports Clock Enable */ __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); From 0d8eb3cfb4ef0e2a01a657752603a4c259423e46 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 22 Nov 2019 10:54:35 -0500 Subject: [PATCH 060/531] add correct VID/PID pairs --- ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk | 2 +- ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk index 918f79f96e..d46ee0b08a 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x805A +USB_PID = 0x8068 USB_PRODUCT = "PYB LR Nano V2" USB_MANUFACTURER = "MicroPython Chinese Community" USB_DEVICES = "CDC,MSC" diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk index 4d3644d4f6..41c283a780 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk @@ -1,8 +1,8 @@ USB_VID = 0x239A -USB_PID = 0x805A +USB_PID = 0x806A USB_PRODUCT = "stm32f411ce-blackpill" USB_MANUFACTURER = "Unknown" -USB_DEVICES = "CDC,MSC" +USB_DEVICES = "CDC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE From 228a619af561246eed368926c0d0735c982c29e6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 22 Nov 2019 10:59:27 -0500 Subject: [PATCH 061/531] enable network, wiznet5k, and ps2io by default on M4 --- ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk | 1 - ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk | 4 ---- ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk | 4 ---- .../boards/grandcentral_m4_express/mpconfigboard.mk | 2 -- ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk | 4 ---- ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk | 1 - ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk | 2 ++ .../atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk | 4 ---- ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk | 4 ---- ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk | 1 - ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk | 3 --- ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk | 2 ++ ports/atmel-samd/boards/pybadge/mpconfigboard.mk | 2 -- ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk | 2 -- ports/atmel-samd/boards/pygamer/mpconfigboard.mk | 2 -- ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk | 2 -- ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk | 1 - ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk | 1 - ports/atmel-samd/mpconfigport.mk | 3 +++ 19 files changed, 7 insertions(+), 38 deletions(-) diff --git a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk index 86a7719b84..5cd3fe70ec 100644 --- a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk @@ -11,6 +11,5 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "W25Q128JV_PM" -CIRCUITPY_PS2IO = 1 # No I2S on SAMD51G. CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk index aa5f47d400..398c54a119 100644 --- a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk @@ -11,7 +11,3 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JV_IQ, W25Q16JV_IM" LONGINT_IMPL = MPZ - -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 -CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk index 176ebac82c..4faa073876 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk @@ -11,7 +11,3 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ - -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 -CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk index 423761c3f7..33542183b6 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk @@ -11,5 +11,3 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C" LONGINT_IMPL = MPZ - -CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk index 0d891abc82..375be283a5 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk @@ -11,7 +11,3 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q64C LONGINT_IMPL = MPZ - -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 -CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk index 5cab5bf43a..dca4e3706f 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk @@ -12,7 +12,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_PS2IO = 1 # No I2S on SAMD51G CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index 706e551c5d..163abfe1d3 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -12,5 +12,7 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = MPZ # Not needed. +CIRCUITPY_PS2IO = 0 +CIRCUITPY_NETWORK = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_DISPLAYIO = 0 diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk index 98d85ba826..bd837ebd6e 100644 --- a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk @@ -11,7 +11,3 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ - -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 -CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk index 68b6f64065..e4d8b9428e 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk @@ -11,7 +11,3 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ - -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 -CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk index 4bd1d6e522..eff8bfe08a 100644 --- a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk @@ -12,7 +12,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "W25Q16JV_IM" LONGINT_IMPL = MPZ -CIRCUITPY_PS2IO = 1 # No I2S on SAMD51G CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk index a3db7dc890..84d1285c5b 100644 --- a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk +++ b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk @@ -11,6 +11,3 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q64C LONGINT_IMPL = MPZ - -CIRCUITPY_AUDIOIO = 1 -CIRCUITPY_DISPLAYIO = 1 diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 54ec3d1d0e..bc2ae609ed 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -17,7 +17,9 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_NETWORK = 0 CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_PS2IO = 0 CIRCUITPY_RTC = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_USB_HID = 0 diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk index 7e2cb64398..b5a240c66b 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk @@ -12,8 +12,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_AUDIOIO = 1 -CIRCUITPY_DISPLAYIO = 1 CIRCUITPY_GAMEPAD = 1 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk index 7e77b0feaf..e78789d741 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk @@ -12,8 +12,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_AUDIOIO = 1 -CIRCUITPY_DISPLAYIO = 1 CIRCUITPY_GAMEPAD = 1 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk index 0fce468d9f..a455690e19 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk @@ -12,8 +12,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q64C LONGINT_IMPL = MPZ -CIRCUITPY_AUDIOIO = 1 -CIRCUITPY_DISPLAYIO = 1 CIRCUITPY_GAMEPAD = 1 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk index 8711738d4f..b6bb266308 100644 --- a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk @@ -12,8 +12,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q64C LONGINT_IMPL = MPZ -CIRCUITPY_AUDIOIO = 1 -CIRCUITPY_DISPLAYIO = 1 CIRCUITPY_GAMEPAD = 1 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk index 56f1617dbf..f18a3dbf46 100644 --- a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk @@ -14,7 +14,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ" LONGINT_IMPL = MPZ -CIRCUITPY_PS2IO = 1 # No I2S on SAMD51G CIRCUITPY_AUDIOBUSIO = 0 # Make room for more stuff diff --git a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk index ec37186c3a..bb0b7d1754 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk @@ -12,7 +12,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C" LONGINT_IMPL = MPZ -CIRCUITPY_PS2IO = 1 # No I2S on SAMD51G CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 88ddb49e01..9e6693d55e 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -27,6 +27,9 @@ endif # Put samd51-only choices here. ifeq ($(CHIP_FAMILY),samd51) +CIRCUITPY_NETWORK = 1 +MICROPY_PY_WIZNET5K = 5500 +CIRCUITPY_PS2IO = 1 CIRCUITPY_SAMD = 1 CIRCUITPY_TOUCHIO_USE_NATIVE = 0 endif From 352bd95f5a337eb79dee602e4ee7a7d7754dca7c Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 22 Nov 2019 11:19:39 -0500 Subject: [PATCH 062/531] remove blackpill --- .github/workflows/build.yml | 1 - .../boards/stm32f411ce_blackpill/board.c | 39 -- .../stm32f411ce_blackpill/mpconfigboard.h | 41 -- .../stm32f411ce_blackpill/mpconfigboard.mk | 17 - .../boards/stm32f411ce_blackpill/pins.c | 38 -- .../stm32f4xx_hal_conf.h | 440 ------------------ 6 files changed, 576 deletions(-) delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/board.c delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/pins.c delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0ab6f68b4..9e5a6654ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,7 +150,6 @@ jobs: - "sparkfun_samd21_dev" - "sparkfun_samd21_mini" - "spresense" - - "stm32f411ce_blackpill" - "stm32f411ve_discovery" - "stm32f412zg_discovery" - "stringcar_m0_express" diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/board.c b/ports/stm32f4/boards/stm32f411ce_blackpill/board.c deleted file mode 100644 index 82b0c506ed..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/board.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "boards/board.h" -#include "mpconfigboard.h" - -void board_init(void) { -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { - -} diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h deleted file mode 100644 index 8a482ce7dc..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "stm32f411ce-blackpill" -#define MICROPY_HW_MCU_NAME "STM32F411CE" - -#define FLASH_SIZE (0x80000) -#define FLASH_PAGE_SIZE (0x4000) - -#define BOARD_OSC_DIV 25 - -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk deleted file mode 100644 index 41c283a780..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk +++ /dev/null @@ -1,17 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x806A -USB_PRODUCT = "stm32f411ce-blackpill" -USB_MANUFACTURER = "Unknown" -USB_DEVICES = "CDC" - -INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = NONE - -MCU_SERIES = m4 -MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f411xe -MCU_PACKAGE = 48 -CMSIS_MCU = STM32F411xE -LD_FILE = boards/STM32F411VETx_FLASH.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c deleted file mode 100644 index 0846cee673..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_B12), MP_ROM_PTR(&pin_PB12) }, - { MP_ROM_QSTR(MP_QSTR_B13), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_B14), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_B15), MP_ROM_PTR(&pin_PB15) }, - { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_PA12) }, - { MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_PA15) }, - { MP_ROM_QSTR(MP_QSTR_B3), MP_ROM_PTR(&pin_PB03) }, - { MP_ROM_QSTR(MP_QSTR_B4), MP_ROM_PTR(&pin_PB04) }, - { MP_ROM_QSTR(MP_QSTR_B5), MP_ROM_PTR(&pin_PB05) }, - { MP_ROM_QSTR(MP_QSTR_B6), MP_ROM_PTR(&pin_PB06) }, - { MP_ROM_QSTR(MP_QSTR_B7), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_B8), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_B9), MP_ROM_PTR(&pin_PB09) }, - - { MP_ROM_QSTR(MP_QSTR_B10), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_B2), MP_ROM_PTR(&pin_PB02) }, - { MP_ROM_QSTR(MP_QSTR_B1), MP_ROM_PTR(&pin_PB01) }, - { MP_ROM_QSTR(MP_QSTR_B0), MP_ROM_PTR(&pin_PB00) }, - { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA03) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA02) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00) }, - { MP_ROM_QSTR(MP_QSTR_C15), MP_ROM_PTR(&pin_PC15) }, - { MP_ROM_QSTR(MP_QSTR_C14), MP_ROM_PTR(&pin_PC14) }, - { MP_ROM_QSTR(MP_QSTR_C13), MP_ROM_PTR(&pin_PC13) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h deleted file mode 100644 index 81d29f2420..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h +++ /dev/null @@ -1,440 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf_template.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32f4xx_hal_conf.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_H -#define __STM32F4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED - -#define HAL_ADC_MODULE_ENABLED -/* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CRC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ -#define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ -#define HAL_I2C_MODULE_ENABLED -#define HAL_I2S_MODULE_ENABLED -/* #define HAL_IWDG_MODULE_ENABLED */ -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_RNG_MODULE_ENABLED */ -/* #define HAL_RTC_MODULE_ENABLED */ -/* #define HAL_SAI_MODULE_ENABLED */ -/* #define HAL_SD_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ -/* #define HAL_PCD_MODULE_ENABLED */ -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_EXTI_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)40000) -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature. */ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) - -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver -* Activated: CRC code is present inside driver -* Deactivated: CRC code cleaned from driver -*/ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED - #include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED - #include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED - #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED - #include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED - #include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED - #include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED - #include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED - #include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED - #include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From f13ba7e8d9048802e960b45264f7d85cc16a1a4d Mon Sep 17 00:00:00 2001 From: David Grimes Date: Fri, 22 Nov 2019 13:47:13 -0500 Subject: [PATCH 063/531] * only make objects long lived if they are on the GC heap --- py/gc.c | 10 ---------- py/gc.h | 11 +++++++++++ py/gc_long_lived.c | 5 +++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/py/gc.c b/py/gc.c index ac584d5d20..a8a5fde125 100755 --- a/py/gc.c +++ b/py/gc.c @@ -53,9 +53,6 @@ // detect untraced object still in use #define CLEAR_ON_SWEEP (0) -#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_WORD) -#define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK) - // ATB = allocation table byte // 0b00 = FREE -- free block // 0b01 = HEAD -- head of a chain of blocks @@ -209,13 +206,6 @@ bool gc_is_locked(void) { return MP_STATE_MEM(gc_lock_depth) != 0; } -// ptr should be of type void* -#define VERIFY_PTR(ptr) ( \ - ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0 /* must be aligned on a block */ \ - && ptr >= (void*)MP_STATE_MEM(gc_pool_start) /* must be above start of pool */ \ - && ptr < (void*)MP_STATE_MEM(gc_pool_end) /* must be below end of pool */ \ - ) - #ifndef TRACE_MARK #if DEBUG_PRINT #define TRACE_MARK(block, ptr) DEBUG_printf("gc_mark(%p)\n", ptr) diff --git a/py/gc.h b/py/gc.h index 02bf451587..cd63ba94cf 100644 --- a/py/gc.h +++ b/py/gc.h @@ -29,8 +29,19 @@ #include #include "py/mpconfig.h" +#include "py/mpstate.h" #include "py/misc.h" +#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_WORD) +#define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK) + +// ptr should be of type void* +#define VERIFY_PTR(ptr) ( \ + ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0 /* must be aligned on a block */ \ + && ptr >= (void*)MP_STATE_MEM(gc_pool_start) /* must be above start of pool */ \ + && ptr < (void*)MP_STATE_MEM(gc_pool_end) /* must be below end of pool */ \ + ) + void gc_init(void *start, void *end); void gc_deinit(void); diff --git a/py/gc_long_lived.c b/py/gc_long_lived.c index 49bf1fcd79..01c22a7af7 100755 --- a/py/gc_long_lived.c +++ b/py/gc_long_lived.c @@ -126,6 +126,11 @@ mp_obj_t make_obj_long_lived(mp_obj_t obj, uint8_t max_depth){ if (obj == NULL) { return obj; } + // If not in the GC pool, do nothing. This can happen (at least) when + // there are frozen mp_type_bytes objects in ROM. + if (!VERIFY_PTR((void *)obj)) { + return obj; + } if (MP_OBJ_IS_TYPE(obj, &mp_type_fun_bc)) { mp_obj_fun_bc_t *fun_bc = MP_OBJ_TO_PTR(obj); return MP_OBJ_FROM_PTR(make_fun_bc_long_lived(fun_bc, max_depth)); From 2e9aa387002468b2c35e60853aefd84cfa877897 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 22 Nov 2019 13:49:33 -0500 Subject: [PATCH 064/531] turn off network in pewpew_m4 --- ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 54ec3d1d0e..1861b8ec45 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -17,6 +17,7 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_NETWORK = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_RTC = 0 CIRCUITPY_TOUCHIO = 0 From 1a62a9cb1757e8e583ed709c2a96427b35a74e2d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 22 Nov 2019 14:02:44 -0500 Subject: [PATCH 065/531] remove network from kicksat_sprite --- ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index 706e551c5d..08af43ee93 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -14,3 +14,4 @@ LONGINT_IMPL = MPZ # Not needed. CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_NETWORK = 0 From aabb56c840456dfdd065c8ca2e11854f32c5a63c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 22 Nov 2019 13:54:37 -0600 Subject: [PATCH 066/531] nrf: i2sout: Only update hold_value when appropriate If we put no samples into the buffer, then there is no last sample to fill out hold_value with. (and, in fact, the expression such as *(uint32_t*)(buffer-4) is outside an allocated region) Detect this condition, and leave the prior value in place. This improves clicks heard when pausing and resuming a waveform. --- ports/nrf/common-hal/audiobusio/I2SOut.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index ac369277f2..5a53f66d27 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -108,6 +108,7 @@ void choose_i2s_clocking(audiobusio_i2sout_obj_t *self, uint32_t sample_rate) { static void i2s_buffer_fill(audiobusio_i2sout_obj_t* self) { void *buffer = self->buffers[self->next_buffer]; + void *buffer_start = buffer; NRF_I2S->TXD.PTR = (uintptr_t)buffer; self->next_buffer = !self->next_buffer; size_t bytesleft = self->buffer_length; @@ -157,15 +158,17 @@ static void i2s_buffer_fill(audiobusio_i2sout_obj_t* self) { // Find the last frame of real audio data and replicate its samples until // you have 32 bits worth, which is the fundamental unit of nRF I2S DMA - if (self->bytes_per_sample == 1 && self->channel_count == 1) { - // For 8-bit mono, 4 copies of the final sample are required - self->hold_value = 0x01010101 * *(uint8_t*)(buffer-1); - } else if (self->bytes_per_sample == 2 && self->channel_count == 2) { - // For 16-bit stereo, 1 copy of the final sample is required - self->hold_value = *(uint32_t*)(buffer-4); - } else { - // For 8-bit stereo and 16-bit mono, 2 copies of the final sample are required - self->hold_value = 0x00010001 * *(uint16_t*)(buffer-2); + if(buffer != buffer_start) { + if (self->bytes_per_sample == 1 && self->channel_count == 1) { + // For 8-bit mono, 4 copies of the final sample are required + self->hold_value = 0x01010101 * *(uint8_t*)(buffer-1); + } else if (self->bytes_per_sample == 2 && self->channel_count == 2) { + // For 16-bit stereo, 1 copy of the final sample is required + self->hold_value = *(uint32_t*)(buffer-4); + } else { + // For 8-bit stereo and 16-bit mono, 2 copies of the final sample are required + self->hold_value = 0x00010001 * *(uint16_t*)(buffer-2); + } } // Emulate pausing and stopping by filling the DMA buffer with copies of From 1c6c9a3e1f041670c008e719be635f4205add6e9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 22 Nov 2019 14:15:07 -0600 Subject: [PATCH 067/531] nrf: i2sout: Ensure hardware I2S is stopped at deinit .. otherwise, it may be possible under some scenario, for the background task to continue and overwrite unrelated memory. --- ports/nrf/common-hal/audiobusio/I2SOut.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index 5a53f66d27..93e6d485d2 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -221,6 +221,8 @@ void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) { if (common_hal_audiobusio_i2sout_deinited(self)) { return; } + NRF_I2S->TASKS_STOP = 1; + NRF_I2S->ENABLE = I2S_ENABLE_ENABLE_Disabled; reset_pin_number(self->bit_clock_pin_number); self->bit_clock_pin_number = 0xff; reset_pin_number(self->word_select_pin_number); From eb44b2bb26ba4578ca97e459c9baa69d549c40a5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 20 Nov 2019 09:38:17 -0600 Subject: [PATCH 068/531] build.yml: Use a newer build toolchain .. the new version is not offered in .deb form, so the installation process also changes --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d5793573f..e34a2e10c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -168,7 +168,8 @@ jobs: run: | sudo apt-get install -y gettext pip install requests sh click setuptools awscli - wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb + wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 + sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 - name: Versions run: | gcc --version From bfdfe0e68191554b70103f249ae1fe08f7fc85f0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 22 Nov 2019 14:30:08 -0600 Subject: [PATCH 069/531] stm32: fix uses of ticks_ms global --- ports/stm32f4/common-hal/busio/UART.c | 4 ++-- ports/stm32f4/common-hal/microcontroller/__init__.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index c4ab237cd1..5ddfa6a4c7 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -250,10 +250,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t } size_t rx_bytes = 0; - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); // Wait for all bytes received or timeout, same as nrf - while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( (ringbuf_count(&self->rbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { RUN_BACKGROUND_TASKS; //restart if it failed in the callback if (errflag != HAL_OK) { diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c index c7493a4d60..ffab5d1e50 100644 --- a/ports/stm32f4/common-hal/microcontroller/__init__.c +++ b/ports/stm32f4/common-hal/microcontroller/__init__.c @@ -48,9 +48,9 @@ STATIC uint32_t get_us(void) { uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq()/1000000; uint32_t micros, sys_cycles; do { - micros = ticks_ms; + micros = supervisor_ticks_ms32(); sys_cycles = SysTick->VAL; //counts backwards - } while (micros != ticks_ms); //try again if ticks_ms rolled over + } while (micros != supervisor_ticks_ms32()); //try again if ticks_ms rolled over return (micros * 1000) + (ticks_per_us * 1000 - sys_cycles) / ticks_per_us; } From 13375d16f11d86f8c7c77e6be209d914d35b6372 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 22 Nov 2019 15:44:51 -0500 Subject: [PATCH 070/531] change mpconfigport.mk files so they can be overriden by mpconfigboard.mk --- .../boards/kicksat-sprite/mpconfigboard.mk | 3 +- ports/atmel-samd/mpconfigport.mk | 23 ++++++++++- ports/nrf/mpconfigport.mk | 17 +++++++-- ports/stm32f4/mpconfigport.mk | 38 +++++++++++++++++++ 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index 93e483928b..453be3b5ee 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -12,8 +12,7 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = MPZ # Not needed. -CIRCUITPY_PS2IO = 0 -CIRCUITPY_NETWORK = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_NETWORK = 0 +CIRCUITPY_PS2IO = 0 diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 9e6693d55e..8958550060 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -16,10 +16,18 @@ endif # Put samd21-only choices here. ifeq ($(CHIP_FAMILY),samd21) -# frequencyio not yet verified as working on SAMD21. +# frequencyio not yet verified as working on SAMD21, though make it possible to override. +ifndef CIRCUITPY_AUDIOMIXER CIRCUITPY_AUDIOMIXER = 0 +endif + +ifndef CIRCUITPY_FREQUENCYIO CIRCUITPY_FREQUENCYIO = 0 +endif + +ifndef CIRCUITPY_TOUCHIO_USE_NATIVE CIRCUITPY_TOUCHIO_USE_NATIVE = 1 +endif # SAMD21 needs separate endpoint pairs for MSC BULK IN and BULK OUT, otherwise it's erratic. USB_MSC_EP_NUM_OUT = 1 @@ -27,11 +35,22 @@ endif # Put samd51-only choices here. ifeq ($(CHIP_FAMILY),samd51) +# No native touchio on SAMD51. +CIRCUITPY_TOUCHIO_USE_NATIVE = 0 + +ifndef CIRCUITPY_NETWORK CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 +endif + +ifndef CIRCUITPY_PS2IO CIRCUITPY_PS2IO = 1 +endif + +ifndef CIRCUITPY_SAMD CIRCUITPY_SAMD = 1 -CIRCUITPY_TOUCHIO_USE_NATIVE = 0 +endif + endif INTERNAL_LIBM = 1 diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 02bde3effa..d070978b71 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -11,20 +11,31 @@ USB_SERIAL_NUMBER_LENGTH = 16 LONGINT_IMPL = MPZ # Audio via PWM +ifndef CIRCUITPY_AUDIOCORE CIRCUITPY_AUDIOCORE = 1 +endif + CIRCUITPY_AUDIOIO = 0 + +ifndef CIRCUITPY_AUDIOMIXER CIRCUITPY_AUDIOMIXER = 1 +endif + +ifndef CIRCUITPY_AUDIOPWMIO CIRCUITPY_AUDIOPWMIO = 1 +endif + +ifndef CIRCUITPY_AUDIOBUSIO CIRCUITPY_AUDIOBUSIO = 1 +endif # No I2CSlave implementation CIRCUITPY_I2CSLAVE = 0 -# enable NVM -CIRCUITPY_NVM = 1 - # enable RTC +ifndef CIRCUITPY_RTC CIRCUITPY_RTC = 1 +endif # frequencyio not yet implemented CIRCUITPY_FREQUENCYIO = 0 diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk index 928d53e67c..3ae0daaa08 100644 --- a/ports/stm32f4/mpconfigport.mk +++ b/ports/stm32f4/mpconfigport.mk @@ -15,18 +15,56 @@ LONGINT_IMPL = MPZ #Reduced feature set for early port CIRCUITPY_MINIMAL_BUILD = 1 +# The ifndef's allow overriding in mpconfigboard.mk. + +ifndef CIRCUITPY_BOARD CIRCUITPY_BOARD = 1 +endif + +ifndef CIRCUITPY_DIGITALIO CIRCUITPY_DIGITALIO = 1 +endif + +ifndef CIRCUITPY_ANALOGIO CIRCUITPY_ANALOGIO = 1 +endif + +ifndef CIRCUITPY_MICROCONTROLLER CIRCUITPY_MICROCONTROLLER = 1 +endif + +ifndef CIRCUITPY_BUSIO CIRCUITPY_BUSIO = 1 +endif + +ifndef CIRCUITPY_PULSEIO CIRCUITPY_PULSEIO = 1 +endif + +ifndef CIRCUITPY_OS CIRCUITPY_OS = 1 +endif + +ifndef CIRCUITPY_STORAGE CIRCUITPY_STORAGE = 1 +endif + +ifndef CIRCUITPY_RANDOM CIRCUITPY_RANDOM = 1 +endif + +ifndef CRICUITPY_USB_HID CIRCUITPY_USB_HID = 1 +endif + +ifndef CIRCUITPY_USB_MIDI CIRCUITPY_USB_MIDI = 1 +endif + +ifndef CIRCUITPY_NEOPIXEL_WRITE CIRCUITPY_NEOPIXEL_WRITE = 1 +endif + #ifeq ($(MCU_SUB_VARIANT), stm32f412zx) #endif From 1ccb7b4c5e4706943f8ee721eb1880ecb337fecc Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 22 Nov 2019 16:30:10 -0500 Subject: [PATCH 071/531] cosmetic commit, mostly to re-run --- ports/atmel-samd/mpconfigport.mk | 2 ++ ports/nrf/mpconfigport.mk | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 8958550060..df108664ad 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -38,6 +38,8 @@ ifeq ($(CHIP_FAMILY),samd51) # No native touchio on SAMD51. CIRCUITPY_TOUCHIO_USE_NATIVE = 0 +# The ifndef's allow overriding in mpconfigboard.mk. + ifndef CIRCUITPY_NETWORK CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index d070978b71..f61d9f8eae 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -17,6 +17,8 @@ endif CIRCUITPY_AUDIOIO = 0 +# The ifndef's allow overriding in mpconfigboard.mk. + ifndef CIRCUITPY_AUDIOMIXER CIRCUITPY_AUDIOMIXER = 1 endif From 5823f5ed04d9a213d5aed463cc157dc93abb4050 Mon Sep 17 00:00:00 2001 From: Ayan Pahwa Date: Sat, 23 Nov 2019 20:43:24 +0530 Subject: [PATCH 072/531] Add \n to file end --- supervisor/shared/filesystem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index 225dd8d047..d26491721a 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -73,11 +73,11 @@ static void make_empty_file(FATFS *fatfs, const char *path) { static void make_sample_code_file(FATFS *fatfs) { FIL fs; UINT *char_written = 0; - const byte buffer[] = "print('Hello World!')"; + const byte buffer[] = "print('Hello World!')\n"; //Create or modify existing code.py file f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS); - f_write(&fs, buffer, sizeof(buffer), char_written); + f_write(&fs, buffer, sizeof(buffer) - 1, char_written); f_close(&fs); } From 262cfd4ea3f80697baf8ca2ccfe63ec243c02870 Mon Sep 17 00:00:00 2001 From: Ayan Pahwa Date: Sat, 23 Nov 2019 20:47:30 +0530 Subject: [PATCH 073/531] Passing address of char_written at f_write --- supervisor/shared/filesystem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index d26491721a..261c481727 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -72,12 +72,12 @@ static void make_empty_file(FATFS *fatfs, const char *path) { static void make_sample_code_file(FATFS *fatfs) { FIL fs; - UINT *char_written = 0; + UINT char_written = 0; const byte buffer[] = "print('Hello World!')\n"; //Create or modify existing code.py file f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS); - f_write(&fs, buffer, sizeof(buffer) - 1, char_written); + f_write(&fs, buffer, sizeof(buffer) - 1, &char_written); f_close(&fs); } From 180b485f8b109baf64252a4b9793a37377af8c25 Mon Sep 17 00:00:00 2001 From: Ayan Pahwa Date: Sat, 23 Nov 2019 20:58:33 +0530 Subject: [PATCH 074/531] Enable creation of code.py only for full builds --- supervisor/shared/filesystem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index 261c481727..b4f6d8bb9f 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -75,10 +75,15 @@ static void make_sample_code_file(FATFS *fatfs) { UINT char_written = 0; const byte buffer[] = "print('Hello World!')\n"; + #if CIRCUITPY_FULL_BUILD == 0 + make_empty_file(&vfs_fat->fatfs, "/code.py"); + + #else //Create or modify existing code.py file f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS); f_write(&fs, buffer, sizeof(buffer) - 1, &char_written); f_close(&fs); + #endif } // we don't make this function static because it needs a lot of stack and we From c770ccd93917cf46a7b8cef7613ff389d7c3d18d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 12:09:26 -0500 Subject: [PATCH 075/531] make ->subscr take an instance to pass when instance_subscr is called from subscr. --- extmod/machine_mem.c | 2 +- extmod/modbtree.c | 2 +- extmod/moductypes.c | 2 +- ports/unix/modjni.c | 2 +- py/obj.c | 15 +++++++-------- py/obj.h | 3 ++- py/objarray.c | 2 +- py/objdict.c | 2 +- py/objlist.c | 2 +- py/objrange.c | 2 +- py/objstr.c | 2 +- py/objstrunicode.c | 2 +- py/objtuple.c | 2 +- py/objtuple.h | 2 +- py/objtype.c | 5 ++--- py/opmethods.c | 6 +++--- shared-bindings/_pixelbuf/PixelBuf.c | 6 +++--- shared-bindings/displayio/Bitmap.c | 2 +- shared-bindings/displayio/Group.c | 2 +- shared-bindings/displayio/Palette.c | 2 +- shared-bindings/displayio/TileGrid.c | 2 +- shared-bindings/nvm/ByteArray.c | 2 +- shared-bindings/pulseio/PulseIn.c | 2 +- 23 files changed, 35 insertions(+), 36 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index e0649290ef..b80eaea998 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -60,7 +60,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); } -STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 8b76885809..cfc614c137 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -246,7 +246,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } } -STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { // delete diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 9eea30bf3e..2165152eaf 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -518,7 +518,7 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 8ec5ae54d9..4aefb2476f 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -241,7 +241,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) { check_exception(); } -STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); char class_name[64]; diff --git a/py/obj.c b/py/obj.c index 6177f74b55..94c509be65 100644 --- a/py/obj.c +++ b/py/obj.c @@ -488,15 +488,14 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { + return mp_obj_subscr_impl(base, index, value, base); +} + +mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(base); - mp_obj_t instance = base; - // If we got an MP_OBJ_SENTINEL as the type, then we got called by instance_subscr - if (type == MP_OBJ_SENTINEL) { - instance = ((mp_obj_t *)base)[1]; - type = mp_obj_get_type(((mp_obj_t *)base)[2]); - } + if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(instance, index, value); + mp_obj_t ret = type->subscr(base, index, value, instance); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); if (ret != MP_OBJ_NULL) { @@ -551,7 +550,7 @@ STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) { mp_obj_type_t *type = mp_obj_get_type(self->obj); mp_obj_t current_length = type->unary_op(MP_UNARY_OP_LEN, self->obj); if (self->cur < MP_OBJ_SMALL_INT_VALUE(current_length)) { - mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL); + mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL, self->obj); self->cur += 1; return o_out; } else { diff --git a/py/obj.h b/py/obj.h index cf4216d02f..edeeb2a4b5 100644 --- a/py/obj.h +++ b/py/obj.h @@ -444,7 +444,7 @@ typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, cons typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t); typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); -typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); +typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance); typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); // Buffer protocol @@ -708,6 +708,7 @@ mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); +mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in); // cell diff --git a/py/objarray.c b/py/objarray.c index 9114a63c5a..70e57f1901 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -396,7 +396,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item // TODO implement diff --git a/py/objdict.c b/py/objdict.c index 683fcb748e..c13ad88e5d 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -174,7 +174,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } } -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete mp_obj_dict_delete(self_in, index); diff --git a/py/objlist.c b/py/objlist.c index ea38e64e55..b0c62a6ee6 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -158,7 +158,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete #if MICROPY_PY_BUILTINS_SLICE diff --git a/py/objrange.c b/py/objrange.c index 30d55c56cd..f8b960900b 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -158,7 +158,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs } #endif -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objstr.c b/py/objstr.c index 6ef9a15b5e..3d2cb338fe 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -431,7 +431,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s #endif // This is used for both bytes and 8-bit strings. This is not used for unicode strings. -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); if (value == MP_OBJ_SENTINEL) { diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 30000a51e7..e299266831 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -197,7 +197,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s return s; } -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objtuple.c b/py/objtuple.c index ed13cdcef2..625c53bdd3 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -177,7 +177,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objtuple.h b/py/objtuple.h index 7f20ab7b6f..4df3aeded9 100644 --- a/py/objtuple.h +++ b/py/objtuple.h @@ -45,7 +45,7 @@ extern const mp_obj_type_t mp_type_tuple; void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in); mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs); -mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value); +mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance); mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf); extern const mp_obj_type_t mp_type_attrtuple; diff --git a/py/objtype.c b/py/objtype.c index 7d41b86560..41ebe7b61e 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -823,7 +823,7 @@ STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t member[2] = {MP_OBJ_NULL}; struct class_lookup_data lookup = { @@ -850,8 +850,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value meth_args = 3; } if (member[0] == MP_OBJ_SENTINEL) { - mp_obj_t args[3] = {MP_OBJ_SENTINEL, self_in, self->subobj[0]}; - return mp_obj_subscr(args, index, value); + return mp_obj_subscr_impl(self->subobj[0], index, value, instance); } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw diff --git a/py/opmethods.c b/py/opmethods.c index 247fa5bbc8..d906ddb6a3 100644 --- a/py/opmethods.c +++ b/py/opmethods.c @@ -29,19 +29,19 @@ STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_SENTINEL); + return type->subscr(self_in, key_in, MP_OBJ_SENTINEL, self_in); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem); STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, value_in); + return type->subscr(self_in, key_in, value_in, self_in); } MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem); STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_NULL); + return type->subscr(self_in, key_in, MP_OBJ_NULL, self_in); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index aeed6f5043..851c3a2762 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -348,7 +348,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s //| //| Sets the pixel value at the given index. //| -STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item // slice deletion @@ -410,7 +410,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(self_in, 's'); + call_show(instance, 's'); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -430,7 +430,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(self_in, 'i'); + call_show(instance, 'i'); return mp_const_none; } } diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 91c17f2d13..764313e1ec 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -133,7 +133,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| bitmap[0,1] = 3 //| -STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { +STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { if (value_obj == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index dd7600eb9c..2288026dcd 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -310,7 +310,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| //| del group[0] //| -STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { +STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { displayio_group_t *self = native_group(self_in); if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) { diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index dda58e3c53..491f9343b5 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -95,7 +95,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| -STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item return MP_OBJ_NULL; // op not supported diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 288eb4b236..5acf8496f8 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -349,7 +349,7 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = { //| //| grid[0,0] = 10 //| -STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { +STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { displayio_tilegrid_t *self = native_tilegrid(self_in); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 31bedeacc0..5ac46b260c 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -70,7 +70,7 @@ STATIC const mp_rom_map_elem_t nvm_bytearray_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict_table); -STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item // slice deletion diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 8b69109f04..5947329a54 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -272,7 +272,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| pulses = pulseio.PulseIn(pin) //| print(pulses[0]) //| -STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { +STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { if (value == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); From 27979f51ace467215d5d823e0ce9f4f2ef690369 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 12:15:12 -0500 Subject: [PATCH 076/531] use base for errors --- py/obj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/obj.c b/py/obj.c index 94c509be65..54822c9771 100644 --- a/py/obj.c +++ b/py/obj.c @@ -507,21 +507,21 @@ mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_ob mp_raise_TypeError(translate("object does not support item deletion")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item deletion"), mp_obj_get_type_str(instance)); + translate("'%s' object does not support item deletion"), mp_obj_get_type_str(base)); } } else if (value == MP_OBJ_SENTINEL) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object is not subscriptable")); } else { mp_raise_TypeError_varg( - translate("'%s' object is not subscriptable"), mp_obj_get_type_str(instance)); + translate("'%s' object is not subscriptable"), mp_obj_get_type_str(base)); } } else { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object does not support item assignment")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item assignment"), mp_obj_get_type_str(instance)); + translate("'%s' object does not support item assignment"), mp_obj_get_type_str(base)); } } } From 03b892379ad9f427e4f3381ce4c572a27392a7f6 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:38:51 -0500 Subject: [PATCH 077/531] Try to fix frozen to fix CI --- frozen/Adafruit_CircuitPython_DotStar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 02758607e2..01e89a8437 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 02758607e26bedd356a0ff004d0493b1783950dd +Subproject commit 01e89a8437c78b62d4d655c745ded57e26dc747a From 75e1e7da4b2cae6adae2b3e12ec4fb6de628598d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:40:03 -0500 Subject: [PATCH 078/531] Try to fix frozen to fix CI --- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index 443626b5e5..b94f06d85c 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit 443626b5e5df688a5b4cc077c4a2c4fdd8fbb49a +Subproject commit b94f06d85c2678d608d904c23e9c0c4172c76b15 From a9baa441c94bf4ba9fe676a34e8a47fee6001559 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:52:14 -0500 Subject: [PATCH 079/531] disable -Wunused-parameter on subscr functions --- extmod/machine_mem.c | 1 + extmod/modbtree.c | 1 + extmod/moductypes.c | 1 + ports/unix/modjni.c | 1 + py/objarray.c | 1 + py/objdict.c | 1 + py/objlist.c | 1 + py/objrange.c | 1 + py/objstr.c | 1 + py/objstrunicode.c | 1 + py/objtuple.c | 1 + shared-bindings/displayio/Bitmap.c | 1 + shared-bindings/displayio/Group.c | 1 + shared-bindings/displayio/Palette.c | 1 + 14 files changed, 14 insertions(+) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index b80eaea998..826c59d0f0 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -60,6 +60,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/extmod/modbtree.c b/extmod/modbtree.c index cfc614c137..97a4de3d5b 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -246,6 +246,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 2165152eaf..722f4bb872 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -518,6 +518,7 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 4aefb2476f..50dd10dd25 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -241,6 +241,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) { check_exception(); } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); diff --git a/py/objarray.c b/py/objarray.c index 70e57f1901..6fffa84125 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -396,6 +396,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item diff --git a/py/objdict.c b/py/objdict.c index c13ad88e5d..2c07331e7c 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -174,6 +174,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete diff --git a/py/objlist.c b/py/objlist.c index b0c62a6ee6..c544c27f05 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -158,6 +158,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete diff --git a/py/objrange.c b/py/objrange.c index f8b960900b..328416303d 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -158,6 +158,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs } #endif +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load diff --git a/py/objstr.c b/py/objstr.c index 4e17153226..fd802fe852 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -439,6 +439,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s #endif // This is used for both bytes and 8-bit strings. This is not used for unicode strings. +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objstrunicode.c b/py/objstrunicode.c index e299266831..dc8c0743d3 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -197,6 +197,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s return s; } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); diff --git a/py/objtuple.c b/py/objtuple.c index 625c53bdd3..b6640def51 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -177,6 +177,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 764313e1ec..7c77d05eda 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -133,6 +133,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| bitmap[0,1] = 3 //| +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { if (value_obj == mp_const_none) { // delete item diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 2288026dcd..40f2704c05 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -310,6 +310,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| //| del group[0] //| +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { displayio_group_t *self = native_group(self_in); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 491f9343b5..2fa65867aa 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -95,6 +95,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item From 7422f430b2e2f398c8d0eac72fb84d188866cf04 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:59:44 -0500 Subject: [PATCH 080/531] update translations --- locale/ID.po | 14 +++++--------- locale/circuitpython.pot | 14 +++++--------- locale/de_DE.po | 26 ++++++++++++++------------ locale/en_US.po | 14 +++++--------- locale/en_x_pirate.po | 14 +++++--------- locale/es.po | 19 +++++++++---------- locale/fil.po | 20 ++++++++++---------- locale/fr.po | 22 ++++++++++++---------- locale/it_IT.po | 19 +++++++++---------- locale/ko.po | 32 +++++++++++--------------------- locale/pl.po | 20 +++++++++++--------- locale/pt_BR.po | 14 +++++--------- locale/zh_Latn_pinyin.po | 20 +++++++++++--------- 13 files changed, 112 insertions(+), 136 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 58ba02f0f8..ece73442ba 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -843,6 +843,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -938,10 +942,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2614,10 +2614,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 9b71b722da..da189a7178 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -832,6 +832,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -926,10 +930,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2582,10 +2582,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index c87f0de82e..58cf8c1535 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -847,6 +847,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "Muss eine %q Unterklasse sein." +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Kein CCCD für diese Charakteristik" @@ -947,10 +951,6 @@ msgstr "" "Nur monochrome, indizierte 4bpp oder 8bpp, und 16bpp oder größere BMPs " "unterstützt: %d bpp wurden gegeben" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Oversample muss ein Vielfaches von 8 sein." @@ -1464,9 +1464,8 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "byteorder ist keine Instanz von ByteOrder (%s erhalten)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2648,10 +2647,6 @@ msgstr "value_count muss größer als 0 sein" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "write_args muss eine Liste, ein Tupel oder None sein" - #: py/objstr.c msgid "wrong number of arguments" msgstr "falsche Anzahl an Argumenten" @@ -2941,6 +2936,10 @@ msgstr "" #~ msgid "buffer too long" #~ msgstr "Buffer zu lang" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "byteorder ist keine Instanz von ByteOrder (%s erhalten)" + #~ msgid "expected a DigitalInOut" #~ msgstr "erwarte DigitalInOut" @@ -3007,3 +3006,6 @@ msgstr "" #~ msgid "wifi_set_ip_info() failed" #~ msgstr "wifi_set_ip_info() fehlgeschlagen" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "write_args muss eine Liste, ein Tupel oder None sein" diff --git a/locale/en_US.po b/locale/en_US.po index 7d0eaca6e3..07c7a42f97 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -832,6 +832,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -926,10 +930,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2582,10 +2582,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 3a88493111..2018f47bdc 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -836,6 +836,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -930,10 +934,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2586,10 +2586,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/es.po b/locale/es.po index 7b955923b6..6e93dc5f60 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -846,6 +846,10 @@ msgstr "Micrófono demora de inicio debe estar en el rango 0.0 a 1.0" msgid "Must be a %q subclass." msgstr "Debe de ser una subclase de %q" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -944,11 +948,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "solo se admiten segmentos con step=1 (alias None)" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "El sobremuestreo debe ser un múltiplo de 8" @@ -2645,10 +2644,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "numero erroneo de argumentos" @@ -2890,6 +2885,10 @@ msgstr "paso cero" #~ "Solo se admiten BMP monocromos, indexados de 8bpp y 16bpp o superiores:% " #~ "d bppdado" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "solo se admiten segmentos con step=1 (alias None)" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Solo color verdadero (24 bpp o superior) BMP admitido %x" diff --git a/locale/fil.po b/locale/fil.po index 75229b48f6..a506d5dbdd 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -852,6 +852,10 @@ msgstr "Ang delay ng startup ng mikropono ay dapat na nasa 0.0 hanggang 1.0" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -949,11 +953,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Oversample ay dapat multiple ng 8." @@ -2654,10 +2653,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "mali ang bilang ng argumento" @@ -2873,6 +2868,11 @@ msgstr "zero step" #~ msgid "Only bit maps of 8 bit color or less are supported" #~ msgstr "Tanging bit maps na may 8 bit color o mas mababa ang supportado" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "" +#~ "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Dapat true color (24 bpp o mas mataas) BMP lamang ang supportado %x" diff --git a/locale/fr.po b/locale/fr.po index 560007d5f2..04452a64b1 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -860,6 +860,10 @@ msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -960,11 +964,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "seuls les slices avec 'step=1' (cad 'None') sont supportées" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Le sur-échantillonage doit être un multiple de 8." @@ -2695,10 +2694,6 @@ msgstr "'value_count' doit être > 0" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "'write_args' doit être une liste, un tuple ou 'None'" - #: py/objstr.c msgid "wrong number of arguments" msgstr "mauvais nombres d'arguments" @@ -2945,6 +2940,10 @@ msgstr "'step' nul" #~ "Seul les BMP monochromes, 8bit indexé et 16bit sont supportés: %d bpp " #~ "fourni" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "seuls les slices avec 'step=1' (cad 'None') sont supportées" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Seul les BMP 24bits ou plus sont supportés %x" @@ -3107,3 +3106,6 @@ msgstr "'step' nul" #~ msgid "wifi_set_ip_info() failed" #~ msgstr "wifi_set_ip_info() a échoué" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "'write_args' doit être une liste, un tuple ou 'None'" diff --git a/locale/it_IT.po b/locale/it_IT.po index 50b4dea8e6..87784829db 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -852,6 +852,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -950,11 +954,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "solo slice con step=1 (aka None) sono supportate" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "L'oversampling deve essere multiplo di 8." @@ -2653,10 +2652,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "numero di argomenti errato" @@ -2883,6 +2878,10 @@ msgstr "zero step" #~ msgid "Only bit maps of 8 bit color or less are supported" #~ msgstr "Sono supportate solo bitmap con colori a 8 bit o meno" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "solo slice con step=1 (aka None) sono supportate" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Solo BMP true color (24 bpp o superiore) sono supportati %x" diff --git a/locale/ko.po b/locale/ko.po index 1452bd7e70..dfe49efe6c 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -378,11 +378,6 @@ msgstr "바이트는 0에서 255 사이 여야합니다." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -703,6 +698,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -837,6 +836,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -931,10 +934,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -1422,8 +1421,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2103,7 +2101,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2284,10 +2282,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2593,10 +2587,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index e024c2d4ec..cabeb5ed7b 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -842,6 +842,10 @@ msgstr "Opóźnienie włączenia mikrofonu musi być w zakresie od 0.0 do 1.0" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -936,10 +940,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "Wspierane są tylko fragmenty z step=1 (albo None)" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Nadpróbkowanie musi być wielokrotnością 8." @@ -2609,10 +2609,6 @@ msgstr "value_count musi być > 0" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "write_args musi być listą, krotką lub None" - #: py/objstr.c msgid "wrong number of arguments" msgstr "zła liczba argumentów" @@ -2773,6 +2769,9 @@ msgstr "zerowy krok" #~ "bpp given" #~ msgstr "Wspierane są tylko pliki BMP czarno-białe, 8bpp i 16bpp: %d bpp " +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "Wspierane są tylko fragmenty z step=1 (albo None)" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Soft device assert, id: 0x%08lX, pc: 0x%08lX" @@ -2807,3 +2806,6 @@ msgstr "zerowy krok" #~ msgid "tile index out of bounds" #~ msgstr "indeks kafelka poza zakresem" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "write_args musi być listą, krotką lub None" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 51189f8145..ffa7e72905 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -844,6 +844,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -941,10 +945,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2606,10 +2606,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index fe2622c383..c2303f8e22 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -842,6 +842,10 @@ msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi msgid "Must be a %q subclass." msgstr "Bìxū shì %q zi lèi." +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Zhège tèzhēng méiyǒu CCCD" @@ -939,10 +943,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "Jǐn zhīchí 1 bù qiēpiàn" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Guò cǎiyàng bìxū shì 8 de bèishù." @@ -2622,10 +2622,6 @@ msgstr "zhí jìshù bìxū wèi > 0" msgid "window must be <= interval" msgstr "Chuāngkǒu bìxū shì <= jiàngé" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "xiě cānshù bìxū shì yuán zǔ, lièbiǎo huò None" - #: py/objstr.c msgid "wrong number of arguments" msgstr "cānshù shù cuòwù" @@ -2828,6 +2824,9 @@ msgstr "líng bù" #~ msgstr "" #~ "Jǐn zhīchí dān sè, suǒyǐn 8bpp hé 16bpp huò gèng dà de BMP: %d bpp tígōng" +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "Jǐn zhīchí 1 bù qiēpiàn" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Ruǎn shèbèi wéihù, id: 0X%08lX, pc: 0X%08lX" @@ -2873,3 +2872,6 @@ msgstr "líng bù" #~ msgid "unsupported bitmap type" #~ msgstr "bù zhīchí de bitmap lèixíng" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "xiě cānshù bìxū shì yuán zǔ, lièbiǎo huò None" From 19d122e546016f02b4315a5b4a35a3e6884e127f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 25 Nov 2019 09:07:20 -0600 Subject: [PATCH 081/531] nrf: i2sout: Fix double-increment when copying samples This caused two problems when playing unsigned samples: * When an even number of samples were present, it "worked" but only every other sample was copied into the output, changing the waveform * When an odd number of samples were present, the copy continued beyond the end of the buffers and caused a hard fault --- ports/nrf/common-hal/audiobusio/I2SOut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index ac369277f2..b8d7ec8a26 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -139,14 +139,14 @@ static void i2s_buffer_fill(audiobusio_i2sout_obj_t* self) { uint16_t *bp = (uint16_t*)buffer; uint16_t *be = (uint16_t*)(buffer + bytecount); uint16_t *sp = (uint16_t*)self->sample_data; - for (; bp != be; bp++) { + for (; bp != be;) { *bp++ = *sp++ + 0x8000; } } else { uint8_t *bp = (uint8_t*)buffer; uint8_t *be = (uint8_t*)(buffer + bytecount); uint8_t *sp = (uint8_t*)self->sample_data; - for (; bp != be; bp++) { + for (; bp != be;) { *bp++ = *sp++ + 0x80; } } From c9946dfd63c642fc5378b222b33171f5607fc324 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 25 Nov 2019 09:17:02 -0600 Subject: [PATCH 082/531] nrf: i2sout: Use <, not !=, for loop condition This is good C style, h/t @danh --- ports/nrf/common-hal/audiobusio/I2SOut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index b8d7ec8a26..04c4151962 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -139,14 +139,14 @@ static void i2s_buffer_fill(audiobusio_i2sout_obj_t* self) { uint16_t *bp = (uint16_t*)buffer; uint16_t *be = (uint16_t*)(buffer + bytecount); uint16_t *sp = (uint16_t*)self->sample_data; - for (; bp != be;) { + for (; bp < be;) { *bp++ = *sp++ + 0x8000; } } else { uint8_t *bp = (uint8_t*)buffer; uint8_t *be = (uint8_t*)(buffer + bytecount); uint8_t *sp = (uint8_t*)self->sample_data; - for (; bp != be;) { + for (; bp < be;) { *bp++ = *sp++ + 0x80; } } From 5115fdaa6f651ae4e1236e5cf7194438fe1c0533 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 25 Nov 2019 09:53:55 -0600 Subject: [PATCH 083/531] shared-bindings: I2SOut: Ensure object is deinitialised (or deinitialized, for those of us on this side of the pond) Otherwise, a sequence like ``` audio = audiobusio.I2SOut(bit_clock=board.D6, word_select=board.D9, data=board.D10) sine_wave_sample = audiocore.RawSample(sine_wave) audio.play(sine_wave_sample, loop=True) del audio ``` could free the memory associated with audio without stopping the related background task. Later, when fresh objects are allocated within a now-freed memory region, they can get overwritten in the background task, leading to a hard crash. This presumably can affect multiple I2S implementations, but it was reported against the nRF one. --- shared-bindings/audiobusio/I2SOut.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 81383c7776..8f7382fde5 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -117,7 +117,7 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a assert_pin(data_obj, false); const mcu_pin_obj_t *data = MP_OBJ_TO_PTR(data_obj); - audiobusio_i2sout_obj_t *self = m_new_obj(audiobusio_i2sout_obj_t); + audiobusio_i2sout_obj_t *self = m_new_obj_with_finaliser(audiobusio_i2sout_obj_t); self->base.type = &audiobusio_i2sout_type; common_hal_audiobusio_i2sout_construct(self, bit_clock, word_select, data, args[ARG_left_justified].u_bool); @@ -268,6 +268,7 @@ const mp_obj_property_t audiobusio_i2sout_paused_obj = { STATIC const mp_rom_map_elem_t audiobusio_i2sout_locals_dict_table[] = { // Methods + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&audiobusio_i2sout_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiobusio_i2sout_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiobusio_i2sout___exit___obj) }, From fc71ed9789243d4aec94eec7bdc13e3ac75319c2 Mon Sep 17 00:00:00 2001 From: Thomas Sarlandie Date: Fri, 15 Nov 2019 21:05:42 -0800 Subject: [PATCH 084/531] add shirtty board - hackaday supercon 2019 addon --- ports/atmel-samd/boards/shirtty/board.c | 37 ++++++++++ .../atmel-samd/boards/shirtty/mpconfigboard.h | 67 +++++++++++++++++++ .../boards/shirtty/mpconfigboard.mk | 15 +++++ ports/atmel-samd/boards/shirtty/pins.c | 36 ++++++++++ 4 files changed, 155 insertions(+) create mode 100644 ports/atmel-samd/boards/shirtty/board.c create mode 100644 ports/atmel-samd/boards/shirtty/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/shirtty/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/shirtty/pins.c diff --git a/ports/atmel-samd/boards/shirtty/board.c b/ports/atmel-samd/boards/shirtty/board.c new file mode 100644 index 0000000000..d7e856d611 --- /dev/null +++ b/ports/atmel-samd/boards/shirtty/board.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/shirtty/mpconfigboard.h b/ports/atmel-samd/boards/shirtty/mpconfigboard.h new file mode 100644 index 0000000000..d5ad8e4bd1 --- /dev/null +++ b/ports/atmel-samd/boards/shirtty/mpconfigboard.h @@ -0,0 +1,67 @@ +#define MICROPY_HW_BOARD_NAME "@sarfata shIRtty" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define MICROPY_HW_LED_STATUS (&pin_PA16) + +#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define CIRCUITPY_INTERNAL_NVM_SIZE 256 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +// #define IGNORE_PIN_PA00 1 +// #define IGNORE_PIN_PA01 1 +// #define IGNORE_PIN_PA02 1 +#define IGNORE_PIN_PA03 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA11 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA17 1 +#define IGNORE_PIN_PA18 1 +#define IGNORE_PIN_PA19 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 1 +#define IGNORE_PIN_PA22 1 +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 +#define IGNORE_PIN_PA27 1 +#define IGNORE_PIN_PA28 1 +#define IGNORE_PIN_PA30 1 +#define IGNORE_PIN_PA31 1 +#define IGNORE_PIN_PB01 1 +#define IGNORE_PIN_PB02 1 +#define IGNORE_PIN_PB03 1 +#define IGNORE_PIN_PB04 1 +#define IGNORE_PIN_PB05 1 +#define IGNORE_PIN_PB06 1 +#define IGNORE_PIN_PB07 1 +#define IGNORE_PIN_PB08 1 +#define IGNORE_PIN_PB09 1 +#define IGNORE_PIN_PB10 1 +#define IGNORE_PIN_PB11 1 +#define IGNORE_PIN_PB12 1 +#define IGNORE_PIN_PB13 1 +#define IGNORE_PIN_PB14 1 +#define IGNORE_PIN_PB15 1 +#define IGNORE_PIN_PB16 1 +#define IGNORE_PIN_PB17 1 +#define IGNORE_PIN_PB22 1 +#define IGNORE_PIN_PB23 1 +#define IGNORE_PIN_PB30 1 +#define IGNORE_PIN_PB31 1 +#define IGNORE_PIN_PB00 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PA09) +#define DEFAULT_I2C_BUS_SDA (&pin_PA08) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA07) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA06) +#define DEFAULT_SPI_BUS_MISO (&pin_PA09) + +#define DEFAULT_UART_BUS_RX (&pin_PA07) +#define DEFAULT_UART_BUS_TX (&pin_PA06) diff --git a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk new file mode 100644 index 0000000000..e713a36b73 --- /dev/null +++ b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk @@ -0,0 +1,15 @@ +LD_FILE = boards/samd21x18-bootloader.ld +USB_VID = 0x239A +USB_PID = 0x801F +USB_PRODUCT = "shIRtty" +USB_MANUFACTURER = "@sarfata" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 +CIRCUITPY_I2CSLAVE = 1 + +SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/shirtty/pins.c b/ports/atmel-samd/boards/shirtty/pins.c new file mode 100644 index 0000000000..40e8192341 --- /dev/null +++ b/ports/atmel-samd/boards/shirtty/pins.c @@ -0,0 +1,36 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_IR_RX), MP_ROM_PTR(&pin_PA10) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA07) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA06) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA16) }, + + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_IR_TX), MP_ROM_PTR(&pin_PA23) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 3091952c9006327fddbcf1f8a77a6ec70bfaa5fc Mon Sep 17 00:00:00 2001 From: Thomas Sarlandie Date: Mon, 25 Nov 2019 17:58:00 +0100 Subject: [PATCH 085/531] ci: add shirtty to build matrix per instructions --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d5793573f..bc22361bde 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -140,6 +140,7 @@ jobs: - "robohatmm1_m4" - "sam32" - "serpente" + - "shirtty" - "snekboard" - "sparkfun_lumidrive" - "sparkfun_nrf52840_mini" From 8f4bab2d2478719450fb6ddb2b695709388add69 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 25 Nov 2019 10:59:21 -0600 Subject: [PATCH 086/531] i2sout: Correctly retrieve channel_count The meaning of the "single channel" parameter is not well-documented, but in fact it seems that "true" must be passed or else the returned channel_count is always 1. This caused stereo samples to be played incorrectly. --- ports/nrf/common-hal/audiobusio/I2SOut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index 04c4151962..4590356603 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -240,7 +240,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, uint32_t max_buffer_length; bool single_buffer, samples_signed; - audiosample_get_buffer_structure(sample, /* single channel */ false, + audiosample_get_buffer_structure(sample, /* single channel */ true, &single_buffer, &samples_signed, &max_buffer_length, &self->channel_count); self->single_buffer = single_buffer; From 9c6466cffb0ac3a303e49bd0b685a47807a30367 Mon Sep 17 00:00:00 2001 From: Ayan Pahwa Date: Mon, 25 Nov 2019 22:31:01 +0530 Subject: [PATCH 087/531] Fix build failure for boards with less memory --- supervisor/shared/filesystem.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index b4f6d8bb9f..6745c496d5 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -71,14 +71,13 @@ static void make_empty_file(FATFS *fatfs, const char *path) { static void make_sample_code_file(FATFS *fatfs) { + #if CIRCUITPY_FULL_BUILD == 0 + make_empty_file(fatfs, "/code.py"); + + #else FIL fs; UINT char_written = 0; const byte buffer[] = "print('Hello World!')\n"; - - #if CIRCUITPY_FULL_BUILD == 0 - make_empty_file(&vfs_fat->fatfs, "/code.py"); - - #else //Create or modify existing code.py file f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS); f_write(&fs, buffer, sizeof(buffer) - 1, &char_written); From 47a6eaa297216d3d1120f99dbc6a574797384700 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 25 Nov 2019 11:43:29 -0600 Subject: [PATCH 088/531] nrf: i2sout: Assign SWIDTH The sample width register was never set, so all samples were played as though they were 16 bit. After this change, 8-bit samples no longer produce audio on the MAX 98357A BOB, because only 16-, 24-, and 32-bit samples are supported by the hardware. This will be addressed by a future change to pad samples to 16 bits; see #2323 and the 98357A datasheet page 6. --- ports/nrf/common-hal/audiobusio/I2SOut.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index 4590356603..1110c84463 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -246,6 +246,10 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, self->single_buffer = single_buffer; self->samples_signed = samples_signed; + + NRF_I2S->CONFIG.SWIDTH = self->bytes_per_sample == 1 + ? I2S_CONFIG_SWIDTH_SWIDTH_8Bit + : I2S_CONFIG_SWIDTH_SWIDTH_16Bit; choose_i2s_clocking(self, sample_rate); /* Allocate buffers based on a maximum duration * This duration was chosen empirically based on what would From 1ee35fd6fde6ef6e1aa9fd8d5d15cfd821f2a83d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 25 Nov 2019 11:43:51 -0600 Subject: [PATCH 089/531] nrf: i2sout: move register settings closer together .. just for consistency's sake --- ports/nrf/common-hal/audiobusio/I2SOut.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index 1110c84463..9958e5f00b 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -250,6 +250,10 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, NRF_I2S->CONFIG.SWIDTH = self->bytes_per_sample == 1 ? I2S_CONFIG_SWIDTH_SWIDTH_8Bit : I2S_CONFIG_SWIDTH_SWIDTH_16Bit; + NRF_I2S->CONFIG.CHANNELS = self->channel_count == 1 + ? I2S_CONFIG_CHANNELS_CHANNELS_Left + : I2S_CONFIG_CHANNELS_CHANNELS_Stereo; + choose_i2s_clocking(self, sample_rate); /* Allocate buffers based on a maximum duration * This duration was chosen empirically based on what would @@ -273,9 +277,6 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, self->stopping = false; i2s_buffer_fill(self); - NRF_I2S->CONFIG.CHANNELS = self->channel_count == 1 ? I2S_CONFIG_CHANNELS_CHANNELS_Left : I2S_CONFIG_CHANNELS_CHANNELS_Stereo; - - NRF_I2S->RXTXD.MAXCNT = self->buffer_length / 4; NRF_I2S->ENABLE = I2S_ENABLE_ENABLE_Enabled; From 5e1740d11f9cc446611281210a89b68013be8090 Mon Sep 17 00:00:00 2001 From: Ayan Pahwa Date: Tue, 26 Nov 2019 00:06:03 +0530 Subject: [PATCH 090/531] Not creating code.py file for non-express boards --- supervisor/shared/filesystem.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index 6745c496d5..a0c2b915fa 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -71,10 +71,7 @@ static void make_empty_file(FATFS *fatfs, const char *path) { static void make_sample_code_file(FATFS *fatfs) { - #if CIRCUITPY_FULL_BUILD == 0 - make_empty_file(fatfs, "/code.py"); - - #else + #if CIRCUITPY_FULL_BUILD == 1 FIL fs; UINT char_written = 0; const byte buffer[] = "print('Hello World!')\n"; From 718a28c886b996c7793ad563334070f5b7517477 Mon Sep 17 00:00:00 2001 From: Ayan Pahwa Date: Tue, 26 Nov 2019 01:13:46 +0530 Subject: [PATCH 091/531] update filesystem.c --- supervisor/shared/filesystem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index a0c2b915fa..92727f6fb8 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -71,7 +71,7 @@ static void make_empty_file(FATFS *fatfs, const char *path) { static void make_sample_code_file(FATFS *fatfs) { - #if CIRCUITPY_FULL_BUILD == 1 + #if CIRCUITPY_FULL_BUILD FIL fs; UINT char_written = 0; const byte buffer[] = "print('Hello World!')\n"; From 11dc572bcea048f8b2bd6c055d6014101d2adc04 Mon Sep 17 00:00:00 2001 From: Thomas Sarlandie Date: Mon, 25 Nov 2019 21:56:42 +0100 Subject: [PATCH 092/531] feature: our own PID - thanks @ladyada --- ports/atmel-samd/boards/shirtty/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk index e713a36b73..1e5f415d30 100644 --- a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk +++ b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk @@ -1,6 +1,6 @@ LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A -USB_PID = 0x801F +USB_PID = 0x806C USB_PRODUCT = "shIRtty" USB_MANUFACTURER = "@sarfata" From d4ed258b74ccf526ebd2a206b5d8ef035380c535 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 25 Nov 2019 20:20:51 -0500 Subject: [PATCH 093/531] remove unnecessary qstrs --- shared-bindings/_pixelbuf/__init__.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index e5cb652672..75482cbc26 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -85,24 +85,6 @@ const int32_t colorwheel(float pos) { STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, - { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_QSTR(MP_QSTR_RGB) }, - { MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_QSTR(MP_QSTR_RBG) }, - { MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_QSTR(MP_QSTR_GRB) }, - { MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_QSTR(MP_QSTR_GBR) }, - { MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_QSTR(MP_QSTR_BRG) }, - { MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_QSTR(MP_QSTR_BGR) }, - { MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_QSTR(MP_QSTR_RGBW) }, - { MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_QSTR(MP_QSTR_RBGW) }, - { MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_QSTR(MP_QSTR_GRBW) }, - { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_QSTR(MP_QSTR_GBRW) }, - { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_QSTR(MP_QSTR_BRGW) }, - { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_QSTR(MP_QSTR_BGRW) }, - { MP_ROM_QSTR(MP_QSTR_PRGB), MP_ROM_QSTR(MP_QSTR_PRGB) }, - { MP_ROM_QSTR(MP_QSTR_PRBG), MP_ROM_QSTR(MP_QSTR_PRBG) }, - { MP_ROM_QSTR(MP_QSTR_PGRB), MP_ROM_QSTR(MP_QSTR_PGRB) }, - { MP_ROM_QSTR(MP_QSTR_PGBR), MP_ROM_QSTR(MP_QSTR_PGBR) }, - { MP_ROM_QSTR(MP_QSTR_PBRG), MP_ROM_QSTR(MP_QSTR_PBRG) }, - { MP_ROM_QSTR(MP_QSTR_PBGR), MP_ROM_QSTR(MP_QSTR_PBGR) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, }; From 0ef9344c17343aa01aadc5a261eba21012325132 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 25 Nov 2019 20:21:00 -0500 Subject: [PATCH 094/531] make pixelbuf iterable --- shared-bindings/_pixelbuf/PixelBuf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 851c3a2762..0b1bd3e897 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -454,6 +454,7 @@ const mp_obj_type_t pixelbuf_pixelbuf_type = { .subscr = pixelbuf_pixelbuf_subscr, .make_new = pixelbuf_pixelbuf_make_new, .unary_op = pixelbuf_pixelbuf_unary_op, + .getiter = mp_obj_new_generic_iterator, .print = NULL, .locals_dict = (mp_obj_t)&pixelbuf_pixelbuf_locals_dict, }; From 8f24ea48fbddf19429e02a211bae62c3913e4f9d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Nov 2019 08:33:22 -0600 Subject: [PATCH 095/531] time: struct_time: allow construction from another struct_time This doesn't cover ALL the cases that CPython permits for construction of a struct_time, but it at least makes constructing from any namedtuple work. Closes: #2326 --- shared-bindings/time/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 2654de09aa..7f9e5816ea 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -87,7 +87,7 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp if (n_args != 1 || (kw_args != NULL && kw_args->used > 0)) { mp_raise_TypeError(translate("time.struct_time() takes exactly 1 argument")); } - if (!MP_OBJ_IS_TYPE(args[0], &mp_type_tuple) || ((mp_obj_tuple_t*) MP_OBJ_TO_PTR(args[0]))->len != 9) { + if (mp_obj_get_type(args[0])->getiter != mp_obj_tuple_getiter || ((mp_obj_tuple_t*) MP_OBJ_TO_PTR(args[0]))->len != 9) { mp_raise_TypeError(translate("time.struct_time() takes a 9-sequence")); } From e188ae8b230c464d1deb4cc4a1e853c32d093c4d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Nov 2019 08:45:07 -0600 Subject: [PATCH 096/531] time: struct_time: allow construction like a namedtuple, too Whenever there is more than one argument, delegate the operation to namedtuple_make_new. This allows other circuitpython-compatible idioms, like with keywords time.struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=14, tm_wday=5, tm_yday=5, tm_isdst=-1) with 9 positional arguments, etc. The only vaguely plausible CPython behavior still not permitted in CircuitPython that I found is constructing a timetuple from a length-9 list, a la time.struct_time(list(time.localtime()) Even better, by getting rid of an error message, the build shrinks a tiny bit. --- shared-bindings/time/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 7f9e5816ea..b3e4604b51 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -85,7 +85,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep); #if MICROPY_PY_COLLECTIONS mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { if (n_args != 1 || (kw_args != NULL && kw_args->used > 0)) { - mp_raise_TypeError(translate("time.struct_time() takes exactly 1 argument")); + return namedtuple_make_new(type, n_args, args, kw_args); } if (mp_obj_get_type(args[0])->getiter != mp_obj_tuple_getiter || ((mp_obj_tuple_t*) MP_OBJ_TO_PTR(args[0]))->len != 9) { mp_raise_TypeError(translate("time.struct_time() takes a 9-sequence")); From 2e4a6b94e71edd3c27cb66eaa56aec9b1e42be33 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 21 Nov 2019 09:57:20 -0600 Subject: [PATCH 097/531] atmel-samd: get most constrained m0 builds to work again By tweaking the optimizer flags, we can get back a few hundred bytes and allow these builds to work with the gcc9 compiler. --- ports/atmel-samd/Makefile | 5 +++++ ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk | 2 ++ ports/atmel-samd/boards/pyruler/mpconfigboard.mk | 2 ++ ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk | 2 ++ 4 files changed, 11 insertions(+) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 11e6874edd..f26d1f53ec 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -122,7 +122,12 @@ else ifdef CFLAGS_INLINE_LIMIT CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT) endif + CFLAGS += -flto -flto-partition=none + + ifdef CFLAGS_BOARD + CFLAGS += $(CFLAGS_BOARD) + endif endif CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index 686c9099fc..fe48db1411 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -29,3 +29,5 @@ SUPEROPT_GC = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote + +CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk index 9663944a38..2fbc178afd 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk @@ -12,3 +12,5 @@ LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 + +CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index b4a00b654a..7cbfc36305 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -12,3 +12,5 @@ LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 + +CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 From 3ed6de7bafb3e128a77af749492a1267fb208f3a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 21 Nov 2019 09:57:20 -0600 Subject: [PATCH 098/531] atmel-samd: reduce inlining on pyruler again By tweaking the optimizer flags further, this build also fits --- ports/atmel-samd/boards/pyruler/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk index 2fbc178afd..44537cea76 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk @@ -13,4 +13,4 @@ CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 -CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 +CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=15 From 82f55dc046ace450a518ed3700cffa72e1183c4f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 22 Nov 2019 14:27:44 -0600 Subject: [PATCH 099/531] atmel-samd: reduce inlining on constrained boards again pewpew10, pirkey_m0, and uchip all fit now. However, pirkey_m0 now has just 76 bytes flash available. --- ports/atmel-samd/boards/pewpew10/mpconfigboard.mk | 2 ++ ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk | 2 +- ports/atmel-samd/boards/uchip/mpconfigboard.mk | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk index e24a290519..f9094db913 100644 --- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk @@ -23,3 +23,5 @@ CIRCUITPY_USB_MIDI = 0 SUPEROPT_GC = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x + +CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=15 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index fe48db1411..18a1ad8686 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -30,4 +30,4 @@ FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote -CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 +CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=12 diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.mk b/ports/atmel-samd/boards/uchip/mpconfigboard.mk index 109492b764..3967b76ee9 100644 --- a/ports/atmel-samd/boards/uchip/mpconfigboard.mk +++ b/ports/atmel-samd/boards/uchip/mpconfigboard.mk @@ -10,3 +10,5 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 + +CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 From 58ad38a88ed3e7dc33ca911f889f5a6b3aebae22 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 26 Nov 2019 09:31:44 -0800 Subject: [PATCH 100/531] Remove DotStar from pIRkey M0 for now to free up space Once we use PixelBuf, the library will be much smaller. --- ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index 686c9099fc..6ce25cf690 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -26,6 +26,6 @@ CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar +# FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote From 2647ea0754f891243664a34c8d1059a46d71d65c Mon Sep 17 00:00:00 2001 From: Thomas Sarlandie Date: Tue, 26 Nov 2019 19:26:18 +0100 Subject: [PATCH 101/531] fix: disable touchio to save some space --- ports/atmel-samd/boards/shirtty/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk index 1e5f415d30..9f3710e5ae 100644 --- a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk +++ b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk @@ -11,5 +11,6 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 CIRCUITPY_I2CSLAVE = 1 +CIRCUITPY_TOUCHIO = 0 SUPEROPT_GC = 0 From e77046d49b739129f6fb25b8494c368bc7aec948 Mon Sep 17 00:00:00 2001 From: Thea Flowers Date: Tue, 26 Nov 2019 10:59:12 -0800 Subject: [PATCH 102/531] Set USB_INTERFACE_NAME for winterbloom_sol --- ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk index aa94af6a40..1f624df998 100644 --- a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk +++ b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_VID = 0x239A USB_PID = 0x8062 USB_PRODUCT = "Sol" USB_MANUFACTURER = "Winterbloom" +USB_INTERFACE_NAME = "Sol" CHIP_VARIANT = SAMD51J20A CHIP_FAMILY = samd51 From d32dc814d3f0d3e845e54a043467f37a5908f5f0 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 26 Nov 2019 12:48:36 -0800 Subject: [PATCH 103/531] Fix ePaper so it works after a GC. We weren't correctly collecting the start and stop sequences. As a result, the GC would free the space and allocate other info there. Thanks to JacobT on Discord for the bug report! --- shared-module/displayio/EPaperDisplay.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index df1d5162b7..252b39eb74 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -26,6 +26,7 @@ #include "shared-bindings/displayio/EPaperDisplay.h" +#include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/displayio/FourWire.h" @@ -298,7 +299,7 @@ bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t* self, c } bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t* self) { - + if (self->refreshing && self->busy.base.type == &digitalio_digitalinout_type) { if (common_hal_digitalio_digitalinout_get_value(&self->busy) != self->busy_state) { self->refreshing = false; @@ -365,6 +366,8 @@ void release_epaperdisplay(displayio_epaperdisplay_obj_t* self) { void displayio_epaperdisplay_collect_ptrs(displayio_epaperdisplay_obj_t* self) { displayio_display_core_collect_ptrs(&self->core); + gc_collect_ptr(self->start_sequence); + gc_collect_ptr(self->stop_sequence); } bool maybe_refresh_epaperdisplay(void) { From 84e1d7f304fc92f69eb1120682fe91dff7188ddc Mon Sep 17 00:00:00 2001 From: Thea Flowers Date: Tue, 12 Nov 2019 12:33:52 -0800 Subject: [PATCH 104/531] Make the @micropython.native decorator no-op if support isn't enabled When adding the ability for boards to turn on the `@micropython.native`, `viper`, and `asm_thumb` decorators it was pointed out that it's somewhat awkward to write libraries and drivers that can take advantage of this since the decorators raise `SyntaxErrors` if they aren't enabled. In the case of `viper` and `asm_thumb` this behavior makes sense as they require writing non-normative code. Drivers could have a normal and viper/thumb implementation and implement them as such: ```python try: import _viper_impl as _impl except SyntaxError: import _python_impl as _impl def do_thing(): return _impl.do_thing() ``` For `native`, however, this behavior and the pattern to work around it is less than ideal. Since `native` code should also be valid Python code (although not necessarily the other way around) using the pattern above means *duplicating* the Python implementation and adding `@micropython.native` in the code. This is an unnecessary maintenance burden. This commit *modifies* the behavior of the `@micropython.native` decorator. On boards with `CIRCUITPY_ENABLE_MPY_NATIVE` turned on it operates as usual. On boards with it turned off it does *nothing*- it doesn't raise a `SyntaxError` and doesn't apply optimizations. This means we can write our drivers/libraries once and take advantage of speedups on boards where they are enabled. --- py/compile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/py/compile.c b/py/compile.c index 8b17935bda..77715d3fe5 100644 --- a/py/compile.c +++ b/py/compile.c @@ -775,13 +775,22 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_ qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]); if (attr == MP_QSTR_bytecode) { *emit_options = MP_EMIT_OPT_BYTECODE; -#if MICROPY_EMIT_NATIVE + // @micropython.native decorator. } else if (attr == MP_QSTR_native) { + // Different from MicroPython: native doesn't raise SyntaxError if native support isn't + // compiled, it just passes through the function unmodified. + #if MICROPY_EMIT_NATIVE *emit_options = MP_EMIT_OPT_NATIVE_PYTHON; + #else + return true; + #endif + #if MICROPY_EMIT_NATIVE + // @micropython.viper decorator. } else if (attr == MP_QSTR_viper) { *emit_options = MP_EMIT_OPT_VIPER; -#endif + #endif #if MICROPY_EMIT_INLINE_ASM + // @micropython.asm_thumb decorator. } else if (attr == ASM_DECORATOR_QSTR) { *emit_options = MP_EMIT_OPT_ASM; #endif From 0b0aa5c5cf69189a619c6888fdd62c3eee063480 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 26 Nov 2019 18:12:46 -0500 Subject: [PATCH 105/531] Undo github workflow workaround --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7da73cb2de..1d5793573f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,10 +15,7 @@ jobs: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} - run: python -c "import os; print os.environ['GITHUB_CONTEXT']" - - name: Fail if not a release publish # workaround has `on` doesn't have this filter - run: exit 1 - if: github.event_name == 'release' && (github.event.action != 'published' && github.event.action != 'rerequested') + run: echo "$GITHUB_CONTEXT" - name: Set up Python 3.5 uses: actions/setup-python@v1 with: From 56720eae0a9eb6fe8845cf20eb1298c3fb68a373 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 26 Nov 2019 18:39:08 -0500 Subject: [PATCH 106/531] remove unnecessary intermediate mp_obj_subscr wrapper --- extmod/modurandom.c | 2 +- extmod/vfs.c | 2 +- ports/unix/modjni.c | 2 +- py/obj.c | 6 +----- py/obj.h | 3 +-- py/objreversed.c | 2 +- py/objtype.c | 2 +- py/vm.c | 4 ++-- shared-bindings/random/__init__.c | 2 +- shared-module/os/__init__.c | 2 +- 10 files changed, 11 insertions(+), 16 deletions(-) diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 1512a3fd4a..101c80cf8a 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -150,7 +150,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len > 0) { - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL, seq); } else { nlr_raise(mp_obj_new_exception(&mp_type_IndexError)); } diff --git a/extmod/vfs.c b/extmod/vfs.c index 7d6e6999bd..7599739e0c 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -373,7 +373,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { mp_obj_t dir_list = mp_obj_new_list(0, NULL); mp_obj_t next; while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, next)); } return dir_list; } diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 50dd10dd25..8f0eac5a9d 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -311,7 +311,7 @@ STATIC mp_obj_t jobject_unary_op(mp_unary_op_t op, mp_obj_t self_in) { // TODO: subscr_load_adaptor & subscr_getiter convenience functions // should be moved to common location for reuse. STATIC mp_obj_t subscr_load_adaptor(mp_obj_t self_in, mp_obj_t index_in) { - return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL); + return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL, self_in); } MP_DEFINE_CONST_FUN_OBJ_2(subscr_load_adaptor_obj, subscr_load_adaptor); diff --git a/py/obj.c b/py/obj.c index 54822c9771..47aa1aebfc 100644 --- a/py/obj.c +++ b/py/obj.c @@ -487,11 +487,7 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } } -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { - return mp_obj_subscr_impl(base, index, value, base); -} - -mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(base); if (type->subscr != NULL) { diff --git a/py/obj.h b/py/obj.h index edeeb2a4b5..ff97b34d83 100644 --- a/py/obj.h +++ b/py/obj.h @@ -707,8 +707,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); -mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in); // cell diff --git a/py/objreversed.c b/py/objreversed.c index 4937d08189..0b21e69380 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -66,7 +66,7 @@ STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) { // pre-decrement and index sequence self->cur_index -= 1; - return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL); + return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL, self->seq); } const mp_obj_type_t mp_type_reversed = { diff --git a/py/objtype.c b/py/objtype.c index 7d0760a106..9608a9242d 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -852,7 +852,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value meth_args = 3; } if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr_impl(self->subobj[0], index, value, instance); + return mp_obj_subscr(self->subobj[0], index, value, instance); } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw diff --git a/py/vm.c b/py/vm.c index 353fc88100..2fe8d32370 100644 --- a/py/vm.c +++ b/py/vm.c @@ -386,7 +386,7 @@ dispatch_loop: ENTRY(MP_BC_LOAD_SUBSCR): { MARK_EXC_IP_SELECTIVE(); mp_obj_t index = POP(); - SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL)); + SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL, TOP())); DISPATCH(); } @@ -464,7 +464,7 @@ dispatch_loop: ENTRY(MP_BC_STORE_SUBSCR): MARK_EXC_IP_SELECTIVE(); - mp_obj_subscr(sp[-1], sp[0], sp[-2]); + mp_obj_subscr(sp[-1], sp[0], sp[-2], sp[-1]); sp -= 3; DISPATCH(); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index 83698eac57..fdef914438 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -145,7 +145,7 @@ STATIC mp_obj_t random_choice(mp_obj_t seq) { if (len == 0) { mp_raise_IndexError(translate("empty sequence")); } - return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL); + return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL, seq); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index 8060eec4f3..ad76251c81 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -127,7 +127,7 @@ mp_obj_t common_hal_os_listdir(const char* path) { mp_obj_t next; while ((next = mp_iternext(iter_obj)) != MP_OBJ_STOP_ITERATION) { // next[0] is the filename. - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, dir_list)); RUN_BACKGROUND_TASKS; } return dir_list; From a9624fff253a33c6c71e992ab438bf0c63ed3a5f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 26 Nov 2019 21:28:41 -0500 Subject: [PATCH 107/531] add show --- shared-bindings/_pixelbuf/PixelBuf.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 0b1bd3e897..8ddcf6648a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -230,7 +230,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_show(self_in, 'b'); + call_show(self_in); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -253,7 +253,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } -mp_obj_t call_show(mp_obj_t self_in, char origin) { +mp_obj_t call_show(mp_obj_t self_in) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); return mp_call_method_n_kw(0, 0, dest); @@ -340,6 +340,25 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); + +//| .. method:: fill(color) +//| +//| Fills the entire buffer with the given color. +//| + +STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + + for (size_t offset = 0; offset < self->pixels; offset++) { + pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, + self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); + if (self->auto_write) + call_show(self_in); + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_fill); + + //| .. method:: __getitem__(index) //| //| Returns the pixel value at the given index. @@ -410,7 +429,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(instance, 's'); + call_show(instance); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -430,7 +449,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(instance, 'i'); + call_show(instance); return mp_const_none; } } @@ -443,6 +462,7 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, + { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_pixelbuf_fill_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_locals_dict_table); From b32a9192df04c6fb36027b2b9b3e0e3a3548005a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 27 Nov 2019 12:52:11 -0500 Subject: [PATCH 108/531] make UART.write be blocking on SAMD; add timeout property --- ports/atmel-samd/common-hal/busio/UART.c | 36 +++++---- ports/cxd56/common-hal/busio/UART.c | 12 ++- ports/cxd56/common-hal/busio/UART.h | 2 +- ports/nrf/common-hal/busio/UART.c | 24 +++--- ports/stm32f4/common-hal/busio/UART.c | 98 +++++++++++++----------- shared-bindings/board/__init__.c | 6 ++ shared-bindings/busio/UART.c | 46 +++++++++-- shared-bindings/busio/UART.h | 3 +- shared-module/board/__init__.c | 2 +- 9 files changed, 144 insertions(+), 85 deletions(-) diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 2505e894af..d869f70ff4 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -323,29 +323,23 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, struct io_descriptor *io; usart_async_get_io_descriptor(usart_desc_p, &io); + // Start writing characters. This is non-blocking and will + // return immediately after setting up the write. if (io_write(io, data, len) < 0) { *errcode = MP_EAGAIN; return MP_STREAM_ERROR; } - // Wait until write is complete or timeout. - bool done = false; - uint64_t start_ticks = ticks_ms; - // Busy-wait for timeout. - while (ticks_ms - start_ticks < self->timeout_ms) { - if (usart_async_is_tx_empty(usart_desc_p)) { - done = true; + // Busy-wait until all characters transmitted. + struct usart_async_status async_status; + while (true) { + usart_async_get_status(usart_desc_p, &async_status); + if (async_status.txcnt >= len) { break; } RUN_BACKGROUND_TASKS; } - if (!done) { - *errcode = MP_EAGAIN; - return MP_STREAM_ERROR; - } - - // All the characters got written. return len; } @@ -368,6 +362,14 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat self->baudrate = baudrate; } +mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) { + return (mp_float_t) (self->timeout_ms / 1000.0f); +} + +void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) { + self->timeout_ms = timeout * 1000; +} + uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { // This assignment is only here because the usart_async routines take a *const argument. struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc; @@ -383,12 +385,14 @@ void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) { } +// True if there are no characters still to be written. bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { if (self->tx_pin == NO_PIN) { return false; } // This assignment is only here because the usart_async routines take a *const argument. - const struct _usart_async_device * const usart_device_p = - (struct _usart_async_device * const) &self->usart_desc.device; - return _usart_async_is_byte_sent(usart_device_p); + struct usart_async_descriptor * const usart_desc_p = (struct usart_async_descriptor * const) &self->usart_desc; + struct usart_async_status async_status; + usart_async_get_status(usart_desc_p, &async_status); + return !(async_status.flags & USART_ASYNC_STATUS_BUSY); } diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c index 4a1376f19a..6ae2403c13 100644 --- a/ports/cxd56/common-hal/busio/UART.c +++ b/ports/cxd56/common-hal/busio/UART.c @@ -102,7 +102,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->tx_pin = tx; self->rx_pin = rx; self->baudrate = baudrate; - self->timeout = timeout; + self->timeout_us = timeout * 1000000; } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { @@ -135,7 +135,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t FD_SET(busio_uart_dev[self->number].fd, &rfds); tv.tv_sec = 0; - tv.tv_usec = self->timeout * 1000; + tv.tv_usec = self->timeout_us; retval = select(busio_uart_dev[self->number].fd + 1, &rfds, NULL, NULL, &tv); @@ -172,6 +172,14 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat ioctl(busio_uart_dev[self->number].fd, TCFLSH, (long unsigned int)NULL); } +mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) { + return (mp_float_t) (self->timeout / 1000000.0f); +} + +void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) { + self->timeout_us = timeout * 1000000; +} + uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { int count = 0; diff --git a/ports/cxd56/common-hal/busio/UART.h b/ports/cxd56/common-hal/busio/UART.h index e1d8161491..a69c470566 100644 --- a/ports/cxd56/common-hal/busio/UART.h +++ b/ports/cxd56/common-hal/busio/UART.h @@ -37,7 +37,7 @@ typedef struct { const mcu_pin_obj_t *tx_pin; const mcu_pin_obj_t *rx_pin; uint32_t baudrate; - uint32_t timeout; + uint32_t timeout_us; } busio_uart_obj_t; void busio_uart_reset(void); diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 54a66ddbe7..a0ae8af00e 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -265,19 +265,6 @@ size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, if ( len == 0 ) return 0; - uint64_t start_ticks = ticks_ms; - - // Wait for on-going transfer to complete - while ( nrfx_uarte_tx_in_progress(self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) { - RUN_BACKGROUND_TASKS; - } - - // Time up - if ( !(ticks_ms - start_ticks < self->timeout_ms) ) { - *errcode = MP_EAGAIN; - return MP_STREAM_ERROR; - } - // EasyDMA can only access SRAM uint8_t * tx_buf = (uint8_t*) data; if ( !nrfx_is_in_ram(data) ) { @@ -290,7 +277,8 @@ size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, _VERIFY_ERR(*errcode); (*errcode) = 0; - while ( nrfx_uarte_tx_in_progress(self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) { + // Wait for write to complete. + while ( nrfx_uarte_tx_in_progress(self->uarte) ) { RUN_BACKGROUND_TASKS; } @@ -310,6 +298,14 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat nrf_uarte_baudrate_set(self->uarte->p_reg, get_nrf_baud(baudrate)); } +mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) { + return (mp_float_t) (self->timeout_ms / 1000.0f); +} + +void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) { + self->timeout_ms = timeout * 1000; +} + uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { return ringbuf_count(&self->rbuf); } diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index c4ab237cd1..f0e0cc9eb4 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -36,7 +36,7 @@ #include "supervisor/shared/translate.h" #include "tick.h" -#include "stm32f4xx_hal.h" +#include "stm32f4xx_hal.h" #define ALL_UARTS 0xFFFF @@ -55,7 +55,7 @@ void uart_reset(void) { uart_clock_disable(ALL_UARTS); } -STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eval, +STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eval, int uart_index, bool uart_taken) { if (pin_eval) { //assign a root pointer pointer for IRQ @@ -82,7 +82,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, uint8_t rx_len = sizeof(mcu_uart_rx_list)/sizeof(*mcu_uart_rx_list); bool uart_taken = false; uint8_t uart_index = 0; //origin 0 corrected - + //Can have both pins, or either if ((tx != mp_const_none) && (rx != mp_const_none)) { //normal find loop if both pins exist @@ -90,7 +90,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, if (mcu_uart_tx_list[i].pin == tx) { //rx for (uint j = 0; j < rx_len; j++) { - if (mcu_uart_rx_list[j].pin == rx + if (mcu_uart_rx_list[j].pin == rx && mcu_uart_rx_list[j].uart_index == mcu_uart_tx_list[i].uart_index) { //keep looking if the UART is taken, edge case if (reserved_uart[mcu_uart_tx_list[i].uart_index - 1]) { @@ -106,7 +106,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, } } uart_index = self->tx->uart_index - 1; - USARTx = assign_uart_or_throw(self, (self->tx != NULL && self->rx != NULL), + USARTx = assign_uart_or_throw(self, (self->tx != NULL && self->rx != NULL), uart_index, uart_taken); } else if (tx == mp_const_none) { //If there is no tx, run only rx @@ -123,7 +123,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, } } uart_index = self->rx->uart_index - 1; - USARTx = assign_uart_or_throw(self, (self->rx != NULL), + USARTx = assign_uart_or_throw(self, (self->rx != NULL), uart_index, uart_taken); } else if (rx == mp_const_none) { //If there is no rx, run only tx @@ -140,7 +140,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, } } uart_index = self->tx->uart_index - 1; - USARTx = assign_uart_or_throw(self, (self->tx != NULL), + USARTx = assign_uart_or_throw(self, (self->tx != NULL), uart_index, uart_taken); } else { //both pins cannot be empty @@ -173,7 +173,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = self->rx->altfn_index; + GPIO_InitStruct.Alternate = self->rx->altfn_index; HAL_GPIO_Init(pin_port(rx->port), &GPIO_InitStruct); } @@ -186,7 +186,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, self->handle.Init.BaudRate = baudrate; self->handle.Init.WordLength = (bits == 9) ? UART_WORDLENGTH_9B : UART_WORDLENGTH_8B; self->handle.Init.StopBits = (stop > 1) ? UART_STOPBITS_2 : UART_STOPBITS_1; - self->handle.Init.Parity = (parity == PARITY_ODD) ? UART_PARITY_ODD : + self->handle.Init.Parity = (parity == PARITY_ODD) ? UART_PARITY_ODD : (parity == PARITY_EVEN) ? UART_PARITY_EVEN : UART_PARITY_NONE; self->handle.Init.Mode = (self->tx != NULL && self->rx != NULL) ? UART_MODE_TX_RX : @@ -234,7 +234,7 @@ bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { if (common_hal_busio_uart_deinited(self)) return; - + reset_pin_number(self->tx->pin->port,self->tx->pin->number); reset_pin_number(self->rx->pin->port,self->rx->pin->number); self->tx = mp_const_none; @@ -279,7 +279,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t *errcode = EAGAIN; return MP_STREAM_ERROR; } - return rx_bytes; + return rx_bytes; } // Write characters. @@ -290,13 +290,15 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, bool write_err = false; //write error shouldn't disable interrupts HAL_NVIC_DisableIRQ(self->irq); - if (HAL_UART_Transmit(&self->handle, (uint8_t*)data, len, self->timeout_ms) != HAL_OK) { + if (HAL_UART_Transmit(&self->handle, (uint8_t*)data, len, HAL_MAX_DELAY) != HAL_OK) { write_err = true; } HAL_UART_Receive_IT(&self->handle, &self->rx_char, 1); HAL_NVIC_EnableIRQ(self->irq); - if (write_err) mp_raise_ValueError(translate("UART write error")); + if (write_err) { + mp_raise_ValueError(translate("UART write error")); + } return len; } @@ -312,7 +314,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *handle) } ringbuf_put_n(&context->rbuf, &context->rx_char, 1); errflag = HAL_UART_Receive_IT(handle, &context->rx_char, 1); - + return; } } @@ -360,6 +362,14 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat self->baudrate = baudrate; } +mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) { + return (mp_float_t) (self->timeout_ms / 1000.0f); +} + +void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) { + self->timeout_ms = timeout * 1000; +} + uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { return ringbuf_count(&self->rbuf); } @@ -414,71 +424,71 @@ STATIC void uart_clock_enable(uint16_t mask) { if (mask & (1 << 0)) { __HAL_RCC_USART1_FORCE_RESET(); __HAL_RCC_USART1_RELEASE_RESET(); - __HAL_RCC_USART1_CLK_ENABLE(); + __HAL_RCC_USART1_CLK_ENABLE(); } #endif #ifdef USART2 if (mask & (1 << 1)) { __HAL_RCC_USART2_FORCE_RESET(); __HAL_RCC_USART2_RELEASE_RESET(); - __HAL_RCC_USART2_CLK_ENABLE(); + __HAL_RCC_USART2_CLK_ENABLE(); } #endif #ifdef USART3 if (mask & (1 << 2)) { __HAL_RCC_USART3_FORCE_RESET(); __HAL_RCC_USART3_RELEASE_RESET(); - __HAL_RCC_USART3_CLK_ENABLE(); + __HAL_RCC_USART3_CLK_ENABLE(); } #endif #ifdef UART4 if (mask & (1 << 3)) { __HAL_RCC_UART4_FORCE_RESET(); __HAL_RCC_UART4_RELEASE_RESET(); - __HAL_RCC_UART4_CLK_ENABLE(); + __HAL_RCC_UART4_CLK_ENABLE(); } #endif #ifdef UART5 if (mask & (1 << 4)) { __HAL_RCC_UART5_FORCE_RESET(); __HAL_RCC_UART5_RELEASE_RESET(); - __HAL_RCC_UART5_CLK_ENABLE(); + __HAL_RCC_UART5_CLK_ENABLE(); } #endif #ifdef USART6 if (mask & (1 << 5)) { __HAL_RCC_USART6_FORCE_RESET(); __HAL_RCC_USART6_RELEASE_RESET(); - __HAL_RCC_USART6_CLK_ENABLE(); - } + __HAL_RCC_USART6_CLK_ENABLE(); + } #endif #ifdef UART7 if (mask & (1 << 6)) { __HAL_RCC_UART7_FORCE_RESET(); __HAL_RCC_UART7_RELEASE_RESET(); - __HAL_RCC_UART7_CLK_ENABLE(); - } + __HAL_RCC_UART7_CLK_ENABLE(); + } #endif #ifdef UART8 if (mask & (1 << 7)) { __HAL_RCC_UART8_FORCE_RESET(); __HAL_RCC_UART8_RELEASE_RESET(); - __HAL_RCC_UART8_CLK_ENABLE(); - } + __HAL_RCC_UART8_CLK_ENABLE(); + } #endif #ifdef UART9 if (mask & (1 << 8)) { __HAL_RCC_UART9_FORCE_RESET(); __HAL_RCC_UART9_RELEASE_RESET(); - __HAL_RCC_UART9_CLK_ENABLE(); - } + __HAL_RCC_UART9_CLK_ENABLE(); + } #endif #ifdef UART10 if (mask & (1 << 9)) { __HAL_RCC_UART10_FORCE_RESET(); __HAL_RCC_UART10_RELEASE_RESET(); - __HAL_RCC_UART10_CLK_ENABLE(); - } + __HAL_RCC_UART10_CLK_ENABLE(); + } #endif } @@ -487,71 +497,71 @@ STATIC void uart_clock_disable(uint16_t mask) { if (mask & (1 << 0)) { __HAL_RCC_USART1_FORCE_RESET(); __HAL_RCC_USART1_RELEASE_RESET(); - __HAL_RCC_USART1_CLK_DISABLE(); + __HAL_RCC_USART1_CLK_DISABLE(); } #endif #ifdef USART2 if (mask & (1 << 1)) { __HAL_RCC_USART2_FORCE_RESET(); __HAL_RCC_USART2_RELEASE_RESET(); - __HAL_RCC_USART2_CLK_DISABLE(); + __HAL_RCC_USART2_CLK_DISABLE(); } #endif #ifdef USART3 if (mask & (1 << 2)) { __HAL_RCC_USART3_FORCE_RESET(); __HAL_RCC_USART3_RELEASE_RESET(); - __HAL_RCC_USART3_CLK_DISABLE(); + __HAL_RCC_USART3_CLK_DISABLE(); } #endif #ifdef UART4 if (mask & (1 << 3)) { __HAL_RCC_UART4_FORCE_RESET(); __HAL_RCC_UART4_RELEASE_RESET(); - __HAL_RCC_UART4_CLK_DISABLE(); + __HAL_RCC_UART4_CLK_DISABLE(); } #endif #ifdef UART5 if (mask & (1 << 4)) { __HAL_RCC_UART5_FORCE_RESET(); __HAL_RCC_UART5_RELEASE_RESET(); - __HAL_RCC_UART5_CLK_DISABLE(); + __HAL_RCC_UART5_CLK_DISABLE(); } #endif #ifdef USART6 if (mask & (1 << 5)) { __HAL_RCC_USART6_FORCE_RESET(); __HAL_RCC_USART6_RELEASE_RESET(); - __HAL_RCC_USART6_CLK_DISABLE(); - } + __HAL_RCC_USART6_CLK_DISABLE(); + } #endif #ifdef UART7 if (mask & (1 << 6)) { __HAL_RCC_UART7_FORCE_RESET(); __HAL_RCC_UART7_RELEASE_RESET(); - __HAL_RCC_UART7_CLK_DISABLE(); - } + __HAL_RCC_UART7_CLK_DISABLE(); + } #endif #ifdef UART8 if (mask & (1 << 7)) { __HAL_RCC_UART8_FORCE_RESET(); __HAL_RCC_UART8_RELEASE_RESET(); - __HAL_RCC_UART8_CLK_DISABLE(); - } + __HAL_RCC_UART8_CLK_DISABLE(); + } #endif #ifdef UART9 if (mask & (1 << 8)) { __HAL_RCC_UART9_FORCE_RESET(); __HAL_RCC_UART9_RELEASE_RESET(); - __HAL_RCC_UART9_CLK_DISABLE(); - } + __HAL_RCC_UART9_CLK_DISABLE(); + } #endif #ifdef UART10 if (mask & (1 << 9)) { __HAL_RCC_UART10_FORCE_RESET(); __HAL_RCC_UART10_RELEASE_RESET(); - __HAL_RCC_UART10_CLK_DISABLE(); - } + __HAL_RCC_UART10_CLK_DISABLE(); + } #endif } diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 47e2d64bc8..3dda59fb8e 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -93,6 +93,12 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi); //| //| Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton. //| +//| The object created uses the default parameter values for `busio.UART`. If you need to set +//| parameters that are not changeable after creation, such as ``receiver_buffer_size``, +//| do not use `board.UART()`; instead create a `busio.UART` object explicitly with the +//| desired parameters. +//| +//| #if BOARD_UART mp_obj_t board_uart(void) { mp_obj_t singleton = common_hal_board_get_uart(); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index c7eef8c438..9606c77e9e 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -57,7 +57,7 @@ //| :param int bits: the number of bits per byte, 7, 8 or 9. //| :param Parity parity: the parity used for error checking. //| :param int stop: the number of stop bits, 1 or 2. -//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters. Raises ``ValueError`` if timeout >100 seconds. +//| :param float timeout: the timeout in seconds to wait for the first character and between subsequent characters when reading. Raises ``ValueError`` if timeout >100 seconds. //| :param int receiver_buffer_size: the character length of the read buffer (0 to disable). (When a character is 9 bits the buffer will be 2 * receiver_buffer_size bytes.) //| //| *New in CircuitPython 4.0:* ``timeout`` has incompatibly changed units from milliseconds to seconds. @@ -69,6 +69,12 @@ typedef struct { extern const busio_uart_parity_obj_t busio_uart_parity_even_obj; extern const busio_uart_parity_obj_t busio_uart_parity_odd_obj; +STATIC void validate_timeout(mp_float_t timeout) { + if (timeout < (mp_float_t) 0.0f || timeout > (mp_float_t) 100.0f) { + mp_raise_ValueError(translate("timeout must be 0.0-100.0 (units are now seconds, not msecs)")); + } +} + STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { // Always initially allocate the UART object within the long-lived heap. // This is needed to avoid crashes with certain UART implementations which @@ -116,9 +122,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co } mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); - if (timeout > (mp_float_t)100.0) { - mp_raise_ValueError(translate("timeout >100 (units are now seconds, not msecs)")); - } + validate_timeout(timeout); common_hal_busio_uart_construct(self, tx, rx, args[ARG_baudrate].u_int, bits, parity, stop, timeout, @@ -286,6 +290,35 @@ const mp_obj_property_t busio_uart_in_waiting_obj = { (mp_obj_t)&mp_const_none_obj}, }; +//| .. attribute:: timeout +//| +//| The current timeout, in seconds (float). +//| +STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) { + busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return mp_obj_new_float(common_hal_busio_uart_get_timeout(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_get_timeout_obj, busio_uart_obj_get_timeout); + +STATIC mp_obj_t busio_uart_obj_set_timeout(mp_obj_t self_in, mp_obj_t timeout) { + busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + mp_float_t timeout_float = mp_obj_get_float(timeout); + validate_timeout(timeout_float); + common_hal_busio_uart_set_timeout(self, timeout_float); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(busio_uart_set_timeout_obj, busio_uart_obj_set_timeout); + + +const mp_obj_property_t busio_uart_timeout_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&busio_uart_get_timeout_obj, + (mp_obj_t)&busio_uart_set_timeout_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + //| .. method:: reset_input_buffer() //| //| Discard any unread characters in the input buffer. @@ -355,8 +388,9 @@ STATIC const mp_rom_map_elem_t busio_uart_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_reset_input_buffer), MP_ROM_PTR(&busio_uart_reset_input_buffer_obj) }, // Properties - { MP_ROM_QSTR(MP_QSTR_baudrate), MP_ROM_PTR(&busio_uart_baudrate_obj) }, - { MP_ROM_QSTR(MP_QSTR_in_waiting), MP_ROM_PTR(&busio_uart_in_waiting_obj) }, + { MP_ROM_QSTR(MP_QSTR_baudrate), MP_ROM_PTR(&busio_uart_baudrate_obj) }, + { MP_ROM_QSTR(MP_QSTR_in_waiting), MP_ROM_PTR(&busio_uart_in_waiting_obj) }, + { MP_ROM_QSTR(MP_QSTR_timeout), MP_ROM_PTR(&busio_uart_timeout_obj) }, // Nested Enum-like Classes. { MP_ROM_QSTR(MP_QSTR_Parity), MP_ROM_PTR(&busio_uart_parity_type) }, diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h index 776a996be8..cfd2c800c3 100644 --- a/shared-bindings/busio/UART.h +++ b/shared-bindings/busio/UART.h @@ -57,7 +57,8 @@ extern size_t common_hal_busio_uart_write(busio_uart_obj_t *self, extern uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self); extern void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate); - +extern mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self); +extern void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout); extern uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self); extern void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self); diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index dd07d7190c..914bc43137 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -101,7 +101,7 @@ mp_obj_t common_hal_board_create_uart(void) { const mcu_pin_obj_t* rx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RX); const mcu_pin_obj_t* tx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_TX); - common_hal_busio_uart_construct(self, tx, rx, 9600, 8, PARITY_NONE, 1, 1000, 64); + common_hal_busio_uart_construct(self, tx, rx, 9600, 8, PARITY_NONE, 1, 1.0f, 64); MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self); return MP_STATE_VM(shared_uart_bus); } From 778a7a73e55b906cca170f9bfc961b87c18b4455 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 27 Nov 2019 13:13:29 -0500 Subject: [PATCH 109/531] make translate --- locale/ID.po | 20 ++++++++------------ locale/circuitpython.pot | 8 ++------ locale/de_DE.po | 19 ++----------------- locale/en_US.po | 8 ++------ locale/en_x_pirate.po | 8 ++------ locale/es.po | 26 ++++++++++---------------- locale/fil.po | 28 +++++++++++++++------------- locale/fr.po | 31 +++++++++++++++---------------- locale/it_IT.po | 25 +++++++++++-------------- locale/ko.po | 8 ++------ locale/pl.po | 25 +++++++++---------------- locale/pt_BR.po | 20 ++++++++------------ locale/zh_Latn_pinyin.po | 28 +++++++++------------------- 13 files changed, 95 insertions(+), 159 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index fdbf3863bb..55dd77d54c 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2454,12 +2454,8 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c @@ -2734,7 +2730,7 @@ msgstr "" #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Gagal untuk melaporkan nilai atribut, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Gagal untuk membaca nilai atribut, status: 0x%08lX" @@ -2742,11 +2738,11 @@ msgstr "" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Gagal untuk membaca nilai atribut, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "Gagal untuk menambahkan Vendor Spesific UUID, status: 0x%08lX" @@ -2766,7 +2762,7 @@ msgstr "" #~ msgid "Failed to start scanning" #~ msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" @@ -2778,11 +2774,11 @@ msgstr "" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Gagal untuk menulis nilai atribut, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 24278f33c1..0fbb0d5cb9 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2423,12 +2423,8 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/de_DE.po b/locale/de_DE.po index ff4edd3705..6f0e57978a 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -2484,12 +2484,8 @@ msgstr "threshold muss im Intervall 0-65536 liegen" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c @@ -2720,7 +2716,6 @@ msgstr "" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Characteristic wird bereits von einem anderen Dienst verwendet." -#, c-format #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Konnte ble_uuid nicht decodieren. Status: 0x%04x" @@ -2749,7 +2744,6 @@ msgstr "" #~ msgid "Failed to add characteristic, err 0x%04x" #~ msgstr "Hinzufügen des Characteristic ist gescheitert. Status: 0x%04x" -#, c-format #~ msgid "Failed to add descriptor, err 0x%04x" #~ msgstr "Deskriptor konnte nicht hinzugefügt werden. Status: 0x%04x" @@ -2789,22 +2783,18 @@ msgstr "" #~ msgid "Failed to pair" #~ msgstr "Koppeln fehlgeschlagen" -#, c-format #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Kann CCCD value nicht lesen. Status: 0x%04x" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Kann den Attributwert nicht lesen. Status: 0x%04x" -#, c-format #~ msgid "Failed to read attribute value, err 0x%04x" #~ msgstr "Kann Attributwert nicht lesen, Status: 0x%04x" -#, c-format #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "gatts value konnte nicht gelesen werden. Status: 0x%04x" -#, c-format #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "Kann keine herstellerspezifische UUID hinzufügen. Status: 0x%04x" @@ -2820,7 +2810,6 @@ msgstr "" #~ msgid "Failed to start advertising, err 0x%04x" #~ msgstr "Kann advertisement nicht starten. Status: 0x%04x" -#, c-format #~ msgid "Failed to start connecting, error 0x%04x" #~ msgstr "Verbindung konnte nicht hergestellt werden. Status: 0x%04x" @@ -2830,7 +2819,6 @@ msgstr "" #~ msgid "Failed to start scanning" #~ msgstr "Der Scanvorgang kann nicht gestartet werden" -#, c-format #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%04x" @@ -2840,15 +2828,12 @@ msgstr "" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Kann advertisement nicht stoppen. Status: 0x%04x" -#, c-format #~ msgid "Failed to write CCCD, err 0x%04x" #~ msgstr "Konnte CCCD nicht schreiben, Status: 0x%04x" -#, c-format #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Kann den Attributwert nicht schreiben. Status: 0x%04x" -#, c-format #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "gatts value konnte nicht geschrieben werden. Status: 0x%04x" diff --git a/locale/en_US.po b/locale/en_US.po index b8025aa98e..4f07b2aa4c 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -2423,12 +2423,8 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index a307167aad..1593d935ea 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -2427,12 +2427,8 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/es.po b/locale/es.po index 07ad7fe1b3..e71527cb27 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -2487,13 +2487,9 @@ msgstr "limite debe ser en el rango 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() toma un sequencio 9" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "time.struct_time() acepta exactamente 1 argumento" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" -msgstr "timepo muerto >100 (unidades en segundos)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" @@ -2718,7 +2714,6 @@ msgstr "paso cero" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Características ya esta en uso por otro Serivice" -#, c-format #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "No se puede descodificar ble_uuid, err 0x%04x" @@ -2785,11 +2780,9 @@ msgstr "paso cero" #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "No se puede notificar el valor del anuncio. status: 0x%02x" -#, c-format #~ msgid "Failed to notify or indicate attribute value, err 0x%04x" #~ msgstr "Error al notificar o indicar el valor del atributo, err 0x%04x" -#, c-format #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "No se puede leer el valor del atributo. err 0x%02x" @@ -2797,15 +2790,13 @@ msgstr "paso cero" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "No se puede leer el valor del atributo. status 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read attribute value, err 0x%04x" #~ msgstr "Error al leer valor del atributo, err 0x%04" -#, c-format #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "No se puede escribir el valor del atributo. status: 0x%02x" -#, c-format #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "Fallo al registrar el Vendor-Specific UUID, err 0x%04x" @@ -2824,7 +2815,6 @@ msgstr "paso cero" #~ msgid "Failed to start scanning" #~ msgstr "No se puede iniciar el escaneo. status: 0x%02x" -#, c-format #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "No se puede iniciar el escaneo. err 0x%04x" @@ -2835,11 +2825,9 @@ msgstr "paso cero" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "No se puede detener el anuncio. err: 0x%04x" -#, c-format #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "No se puede escribir el valor del atributo. err: 0x%04x" -#, c-format #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "No se puede escribir el valor del atributo. err: 0x%04x" @@ -3039,6 +3027,12 @@ msgstr "paso cero" #~ msgid "tile index out of bounds" #~ msgstr "el indice del tile fuera de limite" +#~ msgid "time.struct_time() takes exactly 1 argument" +#~ msgstr "time.struct_time() acepta exactamente 1 argumento" + +#~ msgid "timeout >100 (units are now seconds, not msecs)" +#~ msgstr "timepo muerto >100 (unidades en segundos)" + #~ msgid "too many arguments" #~ msgstr "muchos argumentos" diff --git a/locale/fil.po b/locale/fil.po index 8cf49583ac..90d2bc54bb 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -2495,13 +2495,9 @@ msgstr "ang threshold ay dapat sa range 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() kumukuha ng 9-sequence" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "time.struct_time() kumukuha ng 1 argument" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" -msgstr "timeout >100 (units ay seconds, hindi na msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2789,7 +2785,7 @@ msgstr "zero step" #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Hindi mabalitaan ang attribute value, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX" @@ -2797,11 +2793,11 @@ msgstr "zero step" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "Hindi maisulat ang gatts value, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "" #~ "Hindi matagumpay ang paglagay ng Vender Specific UUID, status: 0x%08lX" @@ -2822,7 +2818,7 @@ msgstr "zero step" #~ msgid "Failed to start scanning" #~ msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" @@ -2834,11 +2830,11 @@ msgstr "zero step" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Hindi mahinto ang advertisement, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Hindi maisulat ang attribute value, status: 0x%08lX" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Hindi maisulat ang gatts value, status: 0x%08lX" @@ -3006,6 +3002,12 @@ msgstr "zero step" #~ msgid "scan failed" #~ msgstr "nabigo ang pag-scan" +#~ msgid "time.struct_time() takes exactly 1 argument" +#~ msgstr "time.struct_time() kumukuha ng 1 argument" + +#~ msgid "timeout >100 (units are now seconds, not msecs)" +#~ msgstr "timeout >100 (units ay seconds, hindi na msecs)" + #~ msgid "too many arguments" #~ msgstr "masyadong maraming argumento" diff --git a/locale/fr.po b/locale/fr.po index 3a3f81653c..c6987c1615 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -2535,13 +2535,9 @@ msgstr "le seuil doit être dans la gamme 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() prend une séquence de longueur 9" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "time.struct_time() prend exactement 1 argument" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" -msgstr "timeout >100 (exprimé en secondes, pas en ms)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2769,7 +2765,6 @@ msgstr "'step' nul" #~ msgid "Characteristic already in use by another Service." #~ msgstr "'Characteristic' déjà en utilisation par un autre service" -#, c-format #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Impossible de décoder le 'ble_uuid', err 0x%04x" @@ -2840,12 +2835,11 @@ msgstr "'step' nul" #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Impossible de notifier la valeur de l'attribut. status: 0x%08lX" -#, c-format #~ msgid "Failed to notify or indicate attribute value, err 0x%04x" #~ msgstr "" #~ "Impossible de notifier ou d'indiquer la valeur de l'attribut, err 0x%04x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Impossible de lire la valeur 'CCCD', err 0x%04x" @@ -2853,15 +2847,14 @@ msgstr "'step' nul" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Impossible de lire la valeur de l'attribut. status: 0x%08lX" -#, c-format #~ msgid "Failed to read attribute value, err 0x%04x" #~ msgstr "Impossible de lire la valeur de l'attribut, err 0x%04x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "Impossible de lire la valeur de 'gatts', err 0x%04x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "Echec de l'ajout de l'UUID du fournisseur, err 0x%04x" @@ -2881,7 +2874,7 @@ msgstr "'step' nul" #~ msgid "Failed to start scanning" #~ msgstr "Impossible de commencer à scanner" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Impossible de commencer à scanner, err 0x%04x" @@ -2893,11 +2886,11 @@ msgstr "'step' nul" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Echec de l'arrêt de diffusion, err 0x%04x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Impossible d'écrire la valeur de l'attribut, err 0x%04x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Impossible d'écrire la valeur de 'gatts', err 0x%04x" @@ -3091,6 +3084,12 @@ msgstr "'step' nul" #~ msgid "tile index out of bounds" #~ msgstr "indice de tuile hors limites" +#~ msgid "time.struct_time() takes exactly 1 argument" +#~ msgstr "time.struct_time() prend exactement 1 argument" + +#~ msgid "timeout >100 (units are now seconds, not msecs)" +#~ msgstr "timeout >100 (exprimé en secondes, pas en ms)" + #~ msgid "too many arguments" #~ msgstr "trop d'arguments" diff --git a/locale/it_IT.po b/locale/it_IT.po index 30d843142c..9c72bd6071 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -2494,12 +2494,8 @@ msgstr "la soglia deve essere nell'intervallo 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "time.struct_time() prende esattamente un argomento" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c @@ -2790,11 +2786,10 @@ msgstr "zero step" #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Impossibile notificare valore dell'attributo. status: 0x%02x" -#, c-format #~ msgid "Failed to notify or indicate attribute value, err 0x%04x" #~ msgstr "Notificamento o indicazione di attribute value fallito, err 0x%04x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" @@ -2802,15 +2797,14 @@ msgstr "zero step" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" -#, c-format #~ msgid "Failed to read attribute value, err 0x%04x" #~ msgstr "Tentative leggere attribute value fallito, err 0x%04x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "Non è possibile aggiungere l'UUID del vendor specifico da 128-bit" @@ -2830,7 +2824,7 @@ msgstr "zero step" #~ msgid "Failed to start scanning" #~ msgstr "Impossible iniziare la scansione. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Impossible iniziare la scansione. status: 0x%02x" @@ -2842,11 +2836,11 @@ msgstr "zero step" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Impossibile fermare advertisement. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" @@ -3008,6 +3002,9 @@ msgstr "zero step" #~ msgid "scan failed" #~ msgstr "scansione fallita" +#~ msgid "time.struct_time() takes exactly 1 argument" +#~ msgstr "time.struct_time() prende esattamente un argomento" + #~ msgid "too many arguments" #~ msgstr "troppi argomenti" diff --git a/locale/ko.po b/locale/ko.po index 1452bd7e70..868bb640ad 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -2428,12 +2428,8 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/pl.po b/locale/pl.po index ed57964325..857d7f7ab4 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -2450,13 +2450,9 @@ msgstr "threshold musi być w zakresie 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() wymaga 9-elementowej sekwencji" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "time.struct_time() wymaga jednego argumentu" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" -msgstr "timeout > 100 (jednostkami są sekundy)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" @@ -2664,7 +2660,6 @@ msgstr "zerowy krok" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Charakterystyka w użyciu w innym serwisie" -#, c-format #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Nie można zdekodować ble_uuid, błąd 0x%04x" @@ -2708,23 +2703,18 @@ msgstr "zerowy krok" #~ msgid "Failed to get softdevice state" #~ msgstr "Nie udało się odczytać stanu softdevice" -#, c-format #~ msgid "Failed to notify or indicate attribute value, err 0x%04x" #~ msgstr "Nie udało się powiadomić o wartości atrybutu, błąd 0x%04x" -#, c-format #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Nie udało się odczytać CCCD, błąd 0x%04x" -#, c-format #~ msgid "Failed to read attribute value, err 0x%04x" #~ msgstr "Nie udało się odczytać wartości atrybutu, błąd 0x%04x" -#, c-format #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "Nie udało się odczytać gatts, błąd 0x%04x" -#, c-format #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "Nie udało się zarejestrować UUID dostawcy, błąd 0x%04x" @@ -2740,7 +2730,6 @@ msgstr "zerowy krok" #~ msgid "Failed to start scanning" #~ msgstr "Nie udało się rozpocząć skanowania" -#, c-format #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Nie udało się rozpocząć skanowania, błąd 0x%04x" @@ -2750,11 +2739,9 @@ msgstr "zerowy krok" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Nie udało się zatrzymać rozgłaszania, błąd 0x%04x" -#, c-format #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Nie udało się zapisać atrybutu, błąd 0x%04x" -#, c-format #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Nie udało się zapisać gatts, błąd 0x%04x" @@ -2805,3 +2792,9 @@ msgstr "zerowy krok" #~ msgid "tile index out of bounds" #~ msgstr "indeks kafelka poza zakresem" + +#~ msgid "time.struct_time() takes exactly 1 argument" +#~ msgstr "time.struct_time() wymaga jednego argumentu" + +#~ msgid "timeout >100 (units are now seconds, not msecs)" +#~ msgstr "timeout > 100 (jednostkami są sekundy)" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 715a8345d6..24dd56637e 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -2447,12 +2447,8 @@ msgstr "Limite deve estar no alcance de 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c @@ -2712,7 +2708,7 @@ msgstr "passo zero" #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" @@ -2720,11 +2716,11 @@ msgstr "passo zero" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "" #~ "Não é possível adicionar o UUID de 128 bits específico do fornecedor." @@ -2745,7 +2741,7 @@ msgstr "passo zero" #~ msgid "Failed to start scanning" #~ msgstr "Não é possível iniciar o anúncio. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Não é possível iniciar o anúncio. status: 0x%02x" @@ -2757,11 +2753,11 @@ msgstr "passo zero" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Não pode parar propaganda. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" -#, fuzzy, c-format +#, fuzzy #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index fae8b1b329..a7d66bbcd5 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-27 13:13-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -2463,13 +2463,9 @@ msgstr "yùzhí bìxū zài fànwéi 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() xūyào 9 xùliè" -#: shared-bindings/time/__init__.c -msgid "time.struct_time() takes exactly 1 argument" -msgstr "time.struct_time() xūyào wánquán 1 cānshù" - #: shared-bindings/busio/UART.c -msgid "timeout >100 (units are now seconds, not msecs)" -msgstr "chāoshí >100 (dānwèi shì miǎo, ér bùshì háomiǎo)" +msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" @@ -2680,7 +2676,6 @@ msgstr "líng bù" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Qítā fúwù bùmén yǐ shǐyòng de gōngnéng." -#, c-format #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Wúfǎ jiěmǎ kě dú_uuid, err 0x%04x" @@ -2696,7 +2691,6 @@ msgstr "líng bù" #~ msgid "Failed to add characteristic, err 0x%04x" #~ msgstr "Tiānjiā tèxìng shībài, err 0x%04x" -#, c-format #~ msgid "Failed to add descriptor, err 0x%04x" #~ msgstr "Wúfǎ tiānjiā miáoshù fú, err 0x%04x" @@ -2733,26 +2727,21 @@ msgstr "líng bù" #~ msgid "Failed to get softdevice state" #~ msgstr "Wúfǎ huòdé ruǎnjiàn shèbèi zhuàngtài" -#, c-format #~ msgid "Failed to notify or indicate attribute value, err 0x%04x" #~ msgstr "Wúfǎ tōngzhī huò xiǎnshì shǔxìng zhí, err 0x%04x" #~ msgid "Failed to pair" #~ msgstr "Pèiduì shībài" -#, c-format #~ msgid "Failed to read CCCD value, err 0x%04x" #~ msgstr "Dòu qǔ CCCD zhí, err 0x%04x shībài" -#, c-format #~ msgid "Failed to read attribute value, err 0x%04x" #~ msgstr "Dòu qǔ shǔxìng zhí shībài, err 0x%04x" -#, c-format #~ msgid "Failed to read gatts value, err 0x%04x" #~ msgstr "Wúfǎ dòu qǔ gatts zhí, err 0x%04x" -#, c-format #~ msgid "Failed to register Vendor-Specific UUID, err 0x%04x" #~ msgstr "Wúfǎ zhùcè màizhǔ tèdìng de UUID, err 0x%04x" @@ -2768,7 +2757,6 @@ msgstr "líng bù" #~ msgid "Failed to start advertising, err 0x%04x" #~ msgstr "Qǐdòng guǎnggào shībài, err 0x%04x" -#, c-format #~ msgid "Failed to start connecting, error 0x%04x" #~ msgstr "Wúfǎ kāishǐ liánjiē, cuòwù 0x%04x" @@ -2778,7 +2766,6 @@ msgstr "líng bù" #~ msgid "Failed to start scanning" #~ msgstr "Qǐdòng sǎomiáo shībài" -#, c-format #~ msgid "Failed to start scanning, err 0x%04x" #~ msgstr "Qǐdòng sǎomiáo shībài, err 0x%04x" @@ -2788,15 +2775,12 @@ msgstr "líng bù" #~ msgid "Failed to stop advertising, err 0x%04x" #~ msgstr "Wúfǎ tíngzhǐ guǎnggào, err 0x%04x" -#, c-format #~ msgid "Failed to write CCCD, err 0x%04x" #~ msgstr "Wúfǎ xiě rù CCCD, cuòwù 0x%04x" -#, c-format #~ msgid "Failed to write attribute value, err 0x%04x" #~ msgstr "Xiě rù shǔxìng zhí shībài, err 0x%04x" -#, c-format #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Xiě rù gatts zhí,err 0x%04x shībài" @@ -2866,6 +2850,12 @@ msgstr "líng bù" #~ msgid "tile index out of bounds" #~ msgstr "kuài suǒyǐn chāochū fànwéi" +#~ msgid "time.struct_time() takes exactly 1 argument" +#~ msgstr "time.struct_time() xūyào wánquán 1 cānshù" + +#~ msgid "timeout >100 (units are now seconds, not msecs)" +#~ msgstr "chāoshí >100 (dānwèi shì miǎo, ér bùshì háomiǎo)" + #~ msgid "too many arguments" #~ msgstr "tài duō cānshù" From dd6dfeb30a4e688339612d509fb491bc2e72d078 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 27 Nov 2019 14:47:35 -0500 Subject: [PATCH 110/531] Squeeze pyruler zh_Latn_pinyin --- ports/atmel-samd/boards/pyruler/mpconfigboard.mk | 4 ++++ ports/cxd56/common-hal/busio/UART.c | 2 +- shared-bindings/busio/UART.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk index 9663944a38..9d9e4ba349 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk @@ -12,3 +12,7 @@ LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 + +ifeq ($(TRANSLATION), zh_Latn_pinyin) +CFLAGS_INLINE_LIMIT = 35 +endif diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c index 6ae2403c13..40ae3b7614 100644 --- a/ports/cxd56/common-hal/busio/UART.c +++ b/ports/cxd56/common-hal/busio/UART.c @@ -173,7 +173,7 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat } mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) { - return (mp_float_t) (self->timeout / 1000000.0f); + return (mp_float_t) (self->timeout_us / 1000000.0f); } void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) { diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 9606c77e9e..4c0655e268 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -71,7 +71,7 @@ extern const busio_uart_parity_obj_t busio_uart_parity_odd_obj; STATIC void validate_timeout(mp_float_t timeout) { if (timeout < (mp_float_t) 0.0f || timeout > (mp_float_t) 100.0f) { - mp_raise_ValueError(translate("timeout must be 0.0-100.0 (units are now seconds, not msecs)")); + mp_raise_ValueError(translate("timeout must be 0.0-100.0")); } } From d089f16656f4b6de1f524c691d2135dd0fcbc37d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 27 Nov 2019 14:49:39 -0500 Subject: [PATCH 111/531] 'seconds' --- shared-bindings/busio/UART.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 4c0655e268..7a3b48e895 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -71,7 +71,7 @@ extern const busio_uart_parity_obj_t busio_uart_parity_odd_obj; STATIC void validate_timeout(mp_float_t timeout) { if (timeout < (mp_float_t) 0.0f || timeout > (mp_float_t) 100.0f) { - mp_raise_ValueError(translate("timeout must be 0.0-100.0")); + mp_raise_ValueError(translate("timeout must be 0.0-100.0 seconds")); } } From ae52ec7c8591450b4953426f6bc21fe17d221531 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 27 Nov 2019 14:54:35 -0500 Subject: [PATCH 112/531] make translate again --- locale/ID.po | 4 ++-- locale/circuitpython.pot | 4 ++-- locale/de_DE.po | 4 ++-- locale/en_US.po | 4 ++-- locale/en_x_pirate.po | 4 ++-- locale/es.po | 4 ++-- locale/fil.po | 4 ++-- locale/fr.po | 4 ++-- locale/it_IT.po | 4 ++-- locale/ko.po | 4 ++-- locale/pl.po | 4 ++-- locale/pt_BR.po | 4 ++-- locale/zh_Latn_pinyin.po | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 55dd77d54c..6a0b73b6f7 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2455,7 +2455,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 0fbb0d5cb9..a24ab186a4 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2424,7 +2424,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/de_DE.po b/locale/de_DE.po index 6f0e57978a..37937b94f7 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -2485,7 +2485,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/en_US.po b/locale/en_US.po index 4f07b2aa4c..e0e63e4fd4 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -2424,7 +2424,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 1593d935ea..b22687469c 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -2428,7 +2428,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/es.po b/locale/es.po index e71527cb27..4e8df4195b 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -2488,7 +2488,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() toma un sequencio 9" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/fil.po b/locale/fil.po index 90d2bc54bb..f3f2b7e3b0 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -2496,7 +2496,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() kumukuha ng 9-sequence" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/fr.po b/locale/fr.po index c6987c1615..098bd8d1fc 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -2536,7 +2536,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() prend une séquence de longueur 9" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/it_IT.po b/locale/it_IT.po index 9c72bd6071..154dda932e 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -2495,7 +2495,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/ko.po b/locale/ko.po index 868bb640ad..5fc91553b2 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -2429,7 +2429,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/pl.po b/locale/pl.po index 857d7f7ab4..edfce95c62 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -2451,7 +2451,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() wymaga 9-elementowej sekwencji" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 24dd56637e..a2b259fc46 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -2448,7 +2448,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index a7d66bbcd5..b45650d87e 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 13:13-0500\n" +"POT-Creation-Date: 2019-11-27 14:54-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -2464,7 +2464,7 @@ msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() xūyào 9 xùliè" #: shared-bindings/busio/UART.c -msgid "timeout must be 0.0-100.0 (units are now seconds, not msecs)" +msgid "timeout must be 0.0-100.0 seconds" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c From d843156a5e2018a8dd763dbcce325e62cca38cc2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 29 Nov 2019 10:51:16 -0600 Subject: [PATCH 113/531] samd: Consolidate small build optimization flags .. inline-unit-growth was the same across all boards, and the highest max-inline-insns-auto parameter was shared across 2 of 5 boards, so it's worth a little work to follow the DRY principle --- ports/atmel-samd/Makefile | 4 ++++ ports/atmel-samd/boards/pewpew10/mpconfigboard.mk | 2 +- ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk | 2 +- ports/atmel-samd/boards/pyruler/mpconfigboard.mk | 2 +- ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk | 2 -- ports/atmel-samd/boards/uchip/mpconfigboard.mk | 2 -- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index f26d1f53ec..5d47fd0871 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -125,6 +125,10 @@ else CFLAGS += -flto -flto-partition=none + ifeq ($(CIRCUITPY_SMALL_BUILD),1) + CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20 + endif + ifdef CFLAGS_BOARD CFLAGS += $(CFLAGS_BOARD) endif diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk index f9094db913..8a1d6b16a4 100644 --- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk @@ -24,4 +24,4 @@ SUPEROPT_GC = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x -CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=15 +CFLAGS_BOARD = --param max-inline-insns-auto=15 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index 18a1ad8686..12d6ace0c8 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -30,4 +30,4 @@ FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote -CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=12 +CFLAGS_BOARD = --param max-inline-insns-auto=12 diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk index 44537cea76..72893be8da 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk @@ -13,4 +13,4 @@ CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 -CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=15 +CFLAGS_BOARD = --param max-inline-insns-auto=15 diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index 7cbfc36305..b4a00b654a 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -12,5 +12,3 @@ LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.mk b/ports/atmel-samd/boards/uchip/mpconfigboard.mk index 3967b76ee9..109492b764 100644 --- a/ports/atmel-samd/boards/uchip/mpconfigboard.mk +++ b/ports/atmel-samd/boards/uchip/mpconfigboard.mk @@ -10,5 +10,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 - -CFLAGS_BOARD = --param inline-unit-growth=15 --param max-inline-insns-auto=20 From 5a49e58fb4191af58cef39035c7b69f2251b2924 Mon Sep 17 00:00:00 2001 From: hexthat Date: Sun, 1 Dec 2019 09:38:39 -0800 Subject: [PATCH 114/531] Update zh_Latn_pinyin.po Added Translations --- locale/zh_Latn_pinyin.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index b45650d87e..de78d35b5f 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -673,11 +673,11 @@ msgstr "Shūrù/shūchū cuòwù" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient authentication" -msgstr "" +msgstr "Rènzhèng bùzú" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient encryption" -msgstr "" +msgstr "Jiāmì bùzú" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -2465,7 +2465,7 @@ msgstr "time.struct_time() xūyào 9 xùliè" #: shared-bindings/busio/UART.c msgid "timeout must be 0.0-100.0 seconds" -msgstr "" +msgstr "Chāo shí shíjiān bìxū wèi 0.0 Dào 100.0 Miǎo" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" From 002f5c0f1cb0f44a471dac0fafcc7850521a246f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 2 Dec 2019 08:25:48 -0600 Subject: [PATCH 115/531] samd: trinket_m0: make board fit again --- ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index b4a00b654a..af8b561a21 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -12,3 +12,9 @@ LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 + +CFLAGS_BOARD = --param max-inline-insns-auto=15 +ifeq ($(TRANSLATION), zh_Latn_pinyin) +CFLAGS_INLINE_LIMIT = 35 +endif + From e06a3bbceb548432969bfcfa1076dc4363478151 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 2 Dec 2019 08:41:03 -0600 Subject: [PATCH 116/531] translation: Compress as unicode, not bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By treating each unicode code-point as a single entity for huffman compression, the overall compression rate can be somewhat improved without changing the algorithm. On the decompression side, when compressed values above 127 are encountered, they need to be converted from a 16-bit Unicode code point into a UTF-8 byte sequence. Doing this returns approximately 1.5kB of flash storage with the zh_Latn_pinyin translation. (292 -> 1768 bytes remaining in my build of trinket_m0) Other "more ASCII" translations benefit less, and in fact zh_Latn_pinyin is no longer the most constrained translation! (de_DE 1156 -> 1384 bytes free in flash, I didn't check others before pushing for CI) English is slightly pessimized, 2840 -> 2788 bytes, probably mostly because the "values" array was changed from uint8_t to uint16_t, which is strictly not required for an all-ASCII translation. This could probably be avoided in this case, but as English is not the most constrained translation it doesn't really matter. Testing performed: built for feather nRF52840 express and trinket m0 in English and zh_Latn_pinyin; ran and verified the localized messages such as Àn xià rènhé jiàn jìnrù REPL. Shǐyòng CTRL-D chóngxīn jiāzài. and Press any key to enter the REPL. Use CTRL-D to reload. were properly displayed. --- py/makeqstrdata.py | 36 ++++++++++++++++------------------- supervisor/shared/translate.c | 20 +++++++++++++++++-- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 8e3835d861..b9c0ce3e11 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -103,14 +103,10 @@ def compute_huffman_coding(translations, qstrs, compression_filename): # go through each qstr and print it out for _, _, qstr in qstrs.values(): all_strings.append(qstr) - all_strings_concat = "".join(all_strings).encode("utf-8") + all_strings_concat = "".join(all_strings) counts = collections.Counter(all_strings_concat) - # add other values - for i in range(256): - if i not in counts: - counts[i] = 0 cb = huffman.codebook(counts.items()) - values = bytearray() + values = [] length_count = {} renumbered = 0 last_l = None @@ -124,26 +120,26 @@ def compute_huffman_coding(translations, qstrs, compression_filename): if last_l: renumbered <<= (l - last_l) canonical[ch] = '{0:0{width}b}'.format(renumbered, width=l) - if chr(ch) in C_ESCAPES: - s = C_ESCAPES[chr(ch)] - else: - s = chr(ch) - print("//", ch, s, counts[ch], canonical[ch], renumbered) + s = C_ESCAPES.get(ch, ch) + print("//", ord(ch), s, counts[ch], canonical[ch], renumbered) renumbered += 1 last_l = l lengths = bytearray() - for i in range(1, max(length_count) + 1): + print("// length count", length_count) + for i in range(1, max(length_count) + 2): lengths.append(length_count.get(i, 0)) + print("// values", values, "lengths", len(lengths), lengths) + print("// estimated total memory size", len(lengths) + 2*len(values) + sum(len(cb[u]) for u in all_strings_concat)) print("//", values, lengths) with open(compression_filename, "w") as f: f.write("const uint8_t lengths[] = {{ {} }};\n".format(", ".join(map(str, lengths)))) - f.write("const uint8_t values[256] = {{ {} }};\n".format(", ".join(map(str, values)))) + f.write("const uint16_t values[] = {{ {} }};\n".format(", ".join(str(ord(u)) for u in values))) return values, lengths def decompress(encoding_table, length, encoded): values, lengths = encoding_table #print(l, encoded) - dec = bytearray(length) + dec = [] this_byte = 0 this_bit = 7 b = encoded[this_byte] @@ -173,14 +169,14 @@ def decompress(encoding_table, length, encoded): searched_length += lengths[bit_length] v = values[searched_length + bits - max_code] - dec[i] = v - return dec + dec.append(v) + return ''.join(dec) def compress(encoding_table, decompressed): - if not isinstance(decompressed, bytes): + if not isinstance(decompressed, str): raise TypeError() values, lengths = encoding_table - enc = bytearray(len(decompressed) * 2) + enc = bytearray(len(decompressed) * 3) #print(decompressed) #print(lengths) current_bit = 7 @@ -347,9 +343,9 @@ def print_qstr_data(encoding_table, qcfgs, qstrs, i18ns): total_text_compressed_size = 0 for original, translation in i18ns: translation_encoded = translation.encode("utf-8") - compressed = compress(encoding_table, translation_encoded) + compressed = compress(encoding_table, translation) total_text_compressed_size += len(compressed) - decompressed = decompress(encoding_table, len(translation_encoded), compressed).decode("utf-8") + decompressed = decompress(encoding_table, len(translation_encoded), compressed) for c in C_ESCAPES: decompressed = decompressed.replace(c, C_ESCAPES[c]) print("TRANSLATION(\"{}\", {}, {{ {} }}) // {}".format(original, len(translation_encoded)+1, ", ".join(["0x{:02x}".format(x) for x in compressed]), decompressed)) diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c index aa5e4517c2..187d5ff8a5 100644 --- a/supervisor/shared/translate.c +++ b/supervisor/shared/translate.c @@ -42,12 +42,28 @@ void serial_write_compressed(const compressed_string_t* compressed) { serial_write(decompressed); } +STATIC int put_utf8(char *buf, int u) { + if(u <= 0x7f) { + *buf = u; + return 1; + } else if(u <= 0x07ff) { + *buf++ = 0b11000000 | (u >> 6); + *buf = 0b10000000 | (u & 0b00111111); + return 2; + } else { // u <= 0xffff) + *buf++ = 0b11000000 | (u >> 12); + *buf = 0b10000000 | ((u >> 6) & 0b00111111); + *buf = 0b10000000 | (u & 0b00111111); + return 3; + } +} + char* decompress(const compressed_string_t* compressed, char* decompressed) { uint8_t this_byte = 0; uint8_t this_bit = 7; uint8_t b = compressed->data[this_byte]; // Stop one early because the last byte is always NULL. - for (uint16_t i = 0; i < compressed->length - 1; i++) { + for (uint16_t i = 0; i < compressed->length - 1;) { uint32_t bits = 0; uint8_t bit_length = 0; uint32_t max_code = lengths[0]; @@ -72,7 +88,7 @@ char* decompress(const compressed_string_t* compressed, char* decompressed) { max_code = (max_code << 1) + lengths[bit_length]; searched_length += lengths[bit_length]; } - decompressed[i] = values[searched_length + bits - max_code]; + i += put_utf8(decompressed + i, values[searched_length + bits - max_code]); } decompressed[compressed->length-1] = '\0'; From 879e1041c9bb0067bc06337870f2515922469cf0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 2 Dec 2019 10:18:48 -0600 Subject: [PATCH 117/531] makeqstrdata: fix printing of 'increased length' message --- py/makeqstrdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index b9c0ce3e11..9df1a82b6b 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -224,7 +224,7 @@ def compress(encoding_table, decompressed): if current_bit != 7: current_byte += 1 if current_byte > len(decompressed): - print("Note: compression increased length", repr(decompressed.decode('utf-8')), len(decompressed), current_byte, file=sys.stderr) + print("Note: compression increased length", repr(decompressed), len(decompressed), current_byte, file=sys.stderr) return enc[:current_byte] def qstr_escape(qst): From 12737e282152d7bed7dac540029af9dd5b423ec6 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 2 Dec 2019 12:28:48 -0500 Subject: [PATCH 118/531] remove F401 additions to streamline --- ports/stm32f4/peripherals/stm32f4/periph.h | 6 - .../peripherals/stm32f4/stm32f401xe/clocks.c | 61 ------- .../peripherals/stm32f4/stm32f401xe/gpio.c | 54 ------ .../peripherals/stm32f4/stm32f401xe/periph.c | 172 ------------------ .../peripherals/stm32f4/stm32f401xe/periph.h | 57 ------ .../peripherals/stm32f4/stm32f401xe/pins.c | 123 ------------- .../peripherals/stm32f4/stm32f401xe/pins.h | 121 ------------ 7 files changed, 594 deletions(-) delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h diff --git a/ports/stm32f4/peripherals/stm32f4/periph.h b/ports/stm32f4/peripherals/stm32f4/periph.h index ac98b89320..0d1374e850 100644 --- a/ports/stm32f4/peripherals/stm32f4/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/periph.h @@ -140,12 +140,6 @@ typedef struct { //Starter Lines -#ifdef STM32F401xE -#define HAS_DAC 0 -#define HAS_TRNG 0 -#include "stm32f401xe/periph.h" -#endif - #ifdef STM32F411xE #define HAS_DAC 0 #define HAS_TRNG 0 diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c deleted file mode 100644 index 883c252d51..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c +++ /dev/null @@ -1,61 +0,0 @@ - -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" - -void stm32f4_peripherals_clocks_init(void) { - //System clock init - RCC_ClkInitTypeDef RCC_ClkInitStruct; - RCC_OscInitTypeDef RCC_OscInitStruct; - - /* Enable Power Control clock */ - __HAL_RCC_PWR_CLK_ENABLE(); - - /* The voltage scaling allows optimizing the power consumption when the device is - clocked below the maximum system frequency, to update the voltage scaling value - regarding system frequency refer to product datasheet. */ - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); - - /* Enable HSE Oscillator and activate PLL with HSE as source */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 8; - RCC_OscInitStruct.PLL.PLLN = 336; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 7; - HAL_RCC_OscConfig(&RCC_OscInitStruct); - - /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 - clocks dividers */ - RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); -} diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c deleted file mode 100644 index 45dc8fc6fa..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" -#include "stm32f4/gpio.h" -#include "common-hal/microcontroller/Pin.h" - -void stm32f4_peripherals_gpio_init(void) { - //Enable all GPIO for now - GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - - //Never reset pins - never_reset_pin_number(2,13); //PC13 anti tamp - never_reset_pin_number(2,14); //PC14 OSC32_IN - never_reset_pin_number(2,15); //PC15 OSC32_OUT - never_reset_pin_number(0,13); //PA13 SWDIO - never_reset_pin_number(0,14); //PA14 SWCLK -} - -//LEDs are inverted on F411 DISCO -void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { -} - - diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c deleted file mode 100644 index 859e9a1adb..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c +++ /dev/null @@ -1,172 +0,0 @@ - /* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" -#include "py/mphal.h" -#include "stm32f4/pins.h" -#include "stm32f4/periph.h" - -// I2C - -I2C_TypeDef * mcu_i2c_banks[3] = {I2C1, I2C2, I2C3}; - -const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5] = { - I2C_SDA(1, 4, &pin_PB07), - I2C_SDA(1, 4, &pin_PB09), - I2C_SDA(2, 9, &pin_PB03), - I2C_SDA(3, 4, &pin_PC09), - I2C_SDA(3, 9, &pin_PB04), -}; - -const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { - I2C_SCL(1, 4, &pin_PB06), - I2C_SCL(1, 4, &pin_PB08), - I2C_SCL(2, 4, &pin_PB10), - I2C_SCL(3, 4, &pin_PA08) -}; - -// SPI - -SPI_TypeDef * mcu_spi_banks[4] = {SPI1, SPI2, SPI3, SPI4}; - -const mcu_spi_sck_obj_t mcu_spi_sck_list[9] = { - SPI(1, 5, &pin_PA05), - SPI(1, 5, &pin_PB03), - SPI(2, 5, &pin_PB10), - SPI(2, 5, &pin_PB13), - SPI(2, 5, &pin_PD03), - SPI(3, 6, &pin_PB03), - SPI(3, 6, &pin_PC10), - SPI(4, 5, &pin_PE02), - SPI(4, 5, &pin_PE12), -}; - -const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9] = { - SPI(1, 5, &pin_PA07), - SPI(1, 5, &pin_PB05), - SPI(2, 5, &pin_PB15), - SPI(2, 5, &pin_PC03), - SPI(3, 6, &pin_PB05), - SPI(3, 6, &pin_PC12), - SPI(3, 5, &pin_PD06), - SPI(4, 5, &pin_PE06), - SPI(4, 5, &pin_PE14), -}; - -const mcu_spi_miso_obj_t mcu_spi_miso_list[8] = { - SPI(1, 5, &pin_PA06), - SPI(1, 5, &pin_PB04), - SPI(2, 5, &pin_PB14), - SPI(2, 5, &pin_PC02), - SPI(3, 6, &pin_PB04), - SPI(3, 6, &pin_PC11), - SPI(4, 5, &pin_PE05), - SPI(4, 5, &pin_PE13), -}; - -const mcu_spi_nss_obj_t mcu_spi_nss_list[9] = { - SPI(1, 5, &pin_PA04), - SPI(1, 5, &pin_PA15), - SPI(2, 5, &pin_PB09), - SPI(2, 5, &pin_PB12), - SPI(3, 6, &pin_PA04), - SPI(3, 6, &pin_PA15), - SPI(4, 6, &pin_PB12), - SPI(4, 5, &pin_PE04), - SPI(4, 5, &pin_PE11), -}; - -USART_TypeDef * mcu_uart_banks[MAX_UART] = {USART1, USART2, NULL, NULL, NULL, USART6}; -bool mcu_uart_has_usart[MAX_UART] = {true, true, false, false, false, true}; - -const mcu_uart_tx_obj_t mcu_uart_tx_list[6] = { - UART(2, 7, &pin_PA02), - UART(1, 7, &pin_PA09), - UART(6, 8, &pin_PA11), - UART(1, 7, &pin_PB06), - UART(6, 8, &pin_PC06), - UART(2, 7, &pin_PD05), -}; - -const mcu_uart_rx_obj_t mcu_uart_rx_list[6] = { - UART(2, 7, &pin_PA03), - UART(1, 7, &pin_PA10), - UART(6, 8, &pin_PA12), - UART(1, 7, &pin_PB07), - UART(6, 8, &pin_PC07), - UART(2, 7, &pin_PD06), -}; - -//Timers -//TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins -TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10, - TIM11, NULL, NULL, NULL}; - -const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { - TIM(2,1,1,&pin_PA00), - TIM(5,2,1,&pin_PA00), - TIM(2,1,2,&pin_PA01), - TIM(5,2,2,&pin_PA01), - TIM(2,1,3,&pin_PA02), - TIM(5,2,3,&pin_PA02), - TIM(2,1,4,&pin_PA03), - TIM(5,2,4,&pin_PA03), - TIM(9,3,1,&pin_PA02), - TIM(9,3,2,&pin_PA03), - TIM(3,2,1,&pin_PA06), - TIM(3,2,2,&pin_PA07), - TIM(1,1,1,&pin_PA08), - TIM(1,1,2,&pin_PA09), - TIM(1,1,3,&pin_PA10), - TIM(1,1,4,&pin_PA11), - TIM(2,1,1,&pin_PA15), - TIM(3,2,3,&pin_PB00), - TIM(3,2,4,&pin_PB01), - TIM(2,1,2,&pin_PB03), - TIM(3,2,1,&pin_PB04), - TIM(3,2,2,&pin_PB05), - TIM(4,2,1,&pin_PB06), - TIM(4,2,2,&pin_PB07), - TIM(4,2,3,&pin_PB08), - TIM(10,2,1,&pin_PB08), - TIM(4,2,4,&pin_PB09), - TIM(11,2,1,&pin_PB09), - TIM(2,1,3,&pin_PB10), - TIM(3,2,1,&pin_PC06), - TIM(3,2,2,&pin_PC07), - TIM(3,2,3,&pin_PC08), - TIM(3,2,4,&pin_PC09), - TIM(4,2,1,&pin_PD12), - TIM(4,2,2,&pin_PD13), - TIM(4,2,3,&pin_PD14), - TIM(4,2,4,&pin_PD15), - TIM(9,3,1,&pin_PE05), - TIM(9,3,2,&pin_PE06), - TIM(1,1,1,&pin_PE09), - TIM(1,1,2,&pin_PE11), - TIM(1,1,3,&pin_PE13), - TIM(1,1,4,&pin_PE14), -}; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h deleted file mode 100644 index 7d3f4dca22..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H -#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H - -//I2C -extern I2C_TypeDef * mcu_i2c_banks[3]; - -extern const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5]; -extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; - -//SPI -extern SPI_TypeDef * mcu_spi_banks[4]; - -extern const mcu_spi_sck_obj_t mcu_spi_sck_list[9]; -extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9]; -extern const mcu_spi_miso_obj_t mcu_spi_miso_list[8]; -extern const mcu_spi_nss_obj_t mcu_spi_nss_list[9]; - -//UART -extern USART_TypeDef * mcu_uart_banks[MAX_UART]; -extern bool mcu_uart_has_usart[MAX_UART]; - -extern const mcu_uart_tx_obj_t mcu_uart_tx_list[6]; -extern const mcu_uart_rx_obj_t mcu_uart_rx_list[6]; - -//Timers -#define TIM_BANK_ARRAY_LEN 14 -#define TIM_PIN_ARRAY_LEN 44 -TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN]; -const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; - -#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c deleted file mode 100644 index 7e88c3dcba..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c +++ /dev/null @@ -1,123 +0,0 @@ - /* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" -#include "py/mphal.h" -#include "stm32f4/pins.h" - -const mcu_pin_obj_t pin_PE02 = PIN(4, 2, NO_ADC); -const mcu_pin_obj_t pin_PE03 = PIN(4, 3, NO_ADC); -const mcu_pin_obj_t pin_PE04 = PIN(4, 4, NO_ADC); -const mcu_pin_obj_t pin_PE05 = PIN(4, 5, NO_ADC); -const mcu_pin_obj_t pin_PE06 = PIN(4, 6, NO_ADC); - -const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); //anti-tamp -const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); //OSC32_IN -const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); //OSC32_OUT - -const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_1,10)); -const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_1,11)); -const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_1,12)); -const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_1,13)); - -const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1,0)); -const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1,1)); -const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1,2)); -const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1,3)); -const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1,4)); -const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1,5)); -const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1,6)); -const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1,7)); - -const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_1,14)); -const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_1,15)); - -const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1,8)); -const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1,9)); -const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); - -const mcu_pin_obj_t pin_PE07 = PIN(4, 7, NO_ADC); -const mcu_pin_obj_t pin_PE08 = PIN(4, 8, NO_ADC); -const mcu_pin_obj_t pin_PE09 = PIN(4, 9, NO_ADC); -const mcu_pin_obj_t pin_PE10 = PIN(4, 10, NO_ADC); -const mcu_pin_obj_t pin_PE11 = PIN(4, 11, NO_ADC); -const mcu_pin_obj_t pin_PE12 = PIN(4, 12, NO_ADC); -const mcu_pin_obj_t pin_PE13 = PIN(4, 13, NO_ADC); -const mcu_pin_obj_t pin_PE14 = PIN(4, 14, NO_ADC); -const mcu_pin_obj_t pin_PE15 = PIN(4, 15, NO_ADC); - -const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); -const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); -const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); -const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); -const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); - -const mcu_pin_obj_t pin_PD08 = PIN(3, 8, NO_ADC); -const mcu_pin_obj_t pin_PD09 = PIN(3, 9, NO_ADC); -const mcu_pin_obj_t pin_PD10 = PIN(3, 10, NO_ADC); -const mcu_pin_obj_t pin_PD11 = PIN(3, 11, NO_ADC); -const mcu_pin_obj_t pin_PD12 = PIN(3, 12, NO_ADC); -const mcu_pin_obj_t pin_PD13 = PIN(3, 13, NO_ADC); -const mcu_pin_obj_t pin_PD14 = PIN(3, 14, NO_ADC); -const mcu_pin_obj_t pin_PD15 = PIN(3, 15, NO_ADC); - -const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); -const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); -const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); -const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); - -const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); -const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); -const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); -const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); -const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); -const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); //SWDIO -const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); //SWCLK -const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); //JTDI - -const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); -const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); -const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); - -const mcu_pin_obj_t pin_PD00 = PIN(3, 0, NO_ADC); -const mcu_pin_obj_t pin_PD01 = PIN(3, 1, NO_ADC); -const mcu_pin_obj_t pin_PD02 = PIN(3, 2, NO_ADC); -const mcu_pin_obj_t pin_PD03 = PIN(3, 3, NO_ADC); -const mcu_pin_obj_t pin_PD04 = PIN(3, 4, NO_ADC); -const mcu_pin_obj_t pin_PD05 = PIN(3, 5, NO_ADC); -const mcu_pin_obj_t pin_PD06 = PIN(3, 6, NO_ADC); -const mcu_pin_obj_t pin_PD07 = PIN(3, 7, NO_ADC); - -const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); -const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); -const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); -const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); -const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); -const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); -const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); - -const mcu_pin_obj_t pin_PE00 = PIN(4, 0, NO_ADC); -const mcu_pin_obj_t pin_PE01 = PIN(4, 1, NO_ADC); \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h deleted file mode 100644 index 37d3a5cf11..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H -#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H - -//Pins in datasheet order: DocID026289 Rev 7 page 38. LQFP100 only -//pg 38 -extern const mcu_pin_obj_t pin_PE02; -extern const mcu_pin_obj_t pin_PE03; -extern const mcu_pin_obj_t pin_PE04; -extern const mcu_pin_obj_t pin_PE05; -//pg 39 -extern const mcu_pin_obj_t pin_PE06; -extern const mcu_pin_obj_t pin_PC13; -extern const mcu_pin_obj_t pin_PC14; -extern const mcu_pin_obj_t pin_PC15; -extern const mcu_pin_obj_t pin_PC00; -extern const mcu_pin_obj_t pin_PC01; -extern const mcu_pin_obj_t pin_PC02; -extern const mcu_pin_obj_t pin_PC03; -//pg 40 -extern const mcu_pin_obj_t pin_PA00; -extern const mcu_pin_obj_t pin_PA01; -extern const mcu_pin_obj_t pin_PA02; -extern const mcu_pin_obj_t pin_PA03; -extern const mcu_pin_obj_t pin_PA04; -extern const mcu_pin_obj_t pin_PA05; -extern const mcu_pin_obj_t pin_PA06; -extern const mcu_pin_obj_t pin_PA07; -//pg 41 -extern const mcu_pin_obj_t pin_PC04; -extern const mcu_pin_obj_t pin_PC05; -extern const mcu_pin_obj_t pin_PB00; -extern const mcu_pin_obj_t pin_PB01; -extern const mcu_pin_obj_t pin_PB02; -extern const mcu_pin_obj_t pin_PE07; -extern const mcu_pin_obj_t pin_PE08; -extern const mcu_pin_obj_t pin_PE09; -extern const mcu_pin_obj_t pin_PE10; -extern const mcu_pin_obj_t pin_PE11; -extern const mcu_pin_obj_t pin_PE12; -extern const mcu_pin_obj_t pin_PE13; -extern const mcu_pin_obj_t pin_PE14; -extern const mcu_pin_obj_t pin_PE15; -//pg 42 -extern const mcu_pin_obj_t pin_PB10; -extern const mcu_pin_obj_t pin_PB12; -extern const mcu_pin_obj_t pin_PB13; -extern const mcu_pin_obj_t pin_PB14; -extern const mcu_pin_obj_t pin_PB15; -extern const mcu_pin_obj_t pin_PD08; -extern const mcu_pin_obj_t pin_PD09; -extern const mcu_pin_obj_t pin_PD10; -extern const mcu_pin_obj_t pin_PD11; -extern const mcu_pin_obj_t pin_PD12; -//pg 43 -extern const mcu_pin_obj_t pin_PD13; -extern const mcu_pin_obj_t pin_PD14; -extern const mcu_pin_obj_t pin_PD15; -extern const mcu_pin_obj_t pin_PC06; -extern const mcu_pin_obj_t pin_PC07; -extern const mcu_pin_obj_t pin_PC08; -extern const mcu_pin_obj_t pin_PC09; -extern const mcu_pin_obj_t pin_PA08; -extern const mcu_pin_obj_t pin_PA09; -//pg 44 -extern const mcu_pin_obj_t pin_PA10; -extern const mcu_pin_obj_t pin_PA11; -extern const mcu_pin_obj_t pin_PA12; -extern const mcu_pin_obj_t pin_PA13; -extern const mcu_pin_obj_t pin_PA14; -extern const mcu_pin_obj_t pin_PA15; -extern const mcu_pin_obj_t pin_PC10; -extern const mcu_pin_obj_t pin_PC11; -extern const mcu_pin_obj_t pin_PC12; -//pg 45 -extern const mcu_pin_obj_t pin_PD00; -extern const mcu_pin_obj_t pin_PD01; -extern const mcu_pin_obj_t pin_PD02; -extern const mcu_pin_obj_t pin_PD03; -extern const mcu_pin_obj_t pin_PD04; -extern const mcu_pin_obj_t pin_PD05; -extern const mcu_pin_obj_t pin_PD06; -extern const mcu_pin_obj_t pin_PD07; -extern const mcu_pin_obj_t pin_PB03; -extern const mcu_pin_obj_t pin_PB04; -extern const mcu_pin_obj_t pin_PB05; -extern const mcu_pin_obj_t pin_PB06; -//pg 46 -extern const mcu_pin_obj_t pin_PB07; -extern const mcu_pin_obj_t pin_PB08; -extern const mcu_pin_obj_t pin_PB09; -extern const mcu_pin_obj_t pin_PE00; -extern const mcu_pin_obj_t pin_PE01; - - -#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H From 659dcce635a0302625fd1f702843f1c793191e76 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 2 Dec 2019 14:07:46 -0500 Subject: [PATCH 119/531] run translate --- locale/circuitpython.pot | 2 +- locale/pl.po | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d93ebb3bee..1d2b8ad867 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-02 14:06-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/pl.po b/locale/pl.po index 73b08a8a73..f13bed53b9 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-02 14:06-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -2794,11 +2794,11 @@ msgstr "zerowy krok" #~ msgid "tile index out of bounds" #~ msgstr "indeks kafelka poza zakresem" -#~ msgid "write_args must be a list, tuple, or None" -#~ msgstr "write_args musi być listą, krotką lub None" - #~ msgid "time.struct_time() takes exactly 1 argument" #~ msgstr "time.struct_time() wymaga jednego argumentu" #~ msgid "timeout >100 (units are now seconds, not msecs)" #~ msgstr "timeout > 100 (jednostkami są sekundy)" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "write_args musi być listą, krotką lub None" From 0d267eaee13ec2e4f5a48947974fb612cdab6b96 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 2 Dec 2019 14:25:57 -0500 Subject: [PATCH 120/531] fix compile fails --- shared-bindings/_pixelbuf/PixelBuf.c | 3 ++- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 8ddcf6648a..d0be2b61df 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -355,8 +355,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { if (self->auto_write) call_show(self_in); } + return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_fill); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); //| .. method:: __getitem__(index) diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 18caa9219a..aa09e92613 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -48,6 +48,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -mp_obj_t call_show(mp_obj_t self_in, char origin); +mp_obj_t call_show(mp_obj_t self_in); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H From 1a0dcb5caaaa2d9f0dc25d87735b76f1bf5f2c24 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 2 Dec 2019 14:49:23 -0600 Subject: [PATCH 121/531] makeqstrdata: reclaim some more bytes on some translations If a translation only has unicode code points 255 and below, the "values" array can be 8 bits instead of 16 bits. This reclaims some code size, e.g., in a local build, trinket_m0 / en_US reclaimed 112 bytes and de_DE reclaimed 104 bytes. However, languages like zh_Latn_pinyin, which use code points above 255, did not benefit. --- py/makeqstrdata.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 9df1a82b6b..0d667959d9 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -131,9 +131,10 @@ def compute_huffman_coding(translations, qstrs, compression_filename): print("// values", values, "lengths", len(lengths), lengths) print("// estimated total memory size", len(lengths) + 2*len(values) + sum(len(cb[u]) for u in all_strings_concat)) print("//", values, lengths) + values_type = "uint16_t" if max(ord(u) for u in values) > 255 else "uint8_t" with open(compression_filename, "w") as f: f.write("const uint8_t lengths[] = {{ {} }};\n".format(", ".join(map(str, lengths)))) - f.write("const uint16_t values[] = {{ {} }};\n".format(", ".join(str(ord(u)) for u in values))) + f.write("const {} values[] = {{ {} }};\n".format(values_type, ", ".join(str(ord(u)) for u in values))) return values, lengths def decompress(encoding_table, length, encoded): From 45a6b03d404c7a43766e94661f43036d9528511d Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 3 Dec 2019 15:30:12 -0500 Subject: [PATCH 122/531] copy from busted branch --- .../common-hal/digitalio/DigitalInOut.c | 6 +++--- .../common-hal/neopixel_write/__init__.c | 20 ++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ports/stm32f4/common-hal/digitalio/DigitalInOut.c b/ports/stm32f4/common-hal/digitalio/DigitalInOut.c index 51b1fde738..36c1075e23 100644 --- a/ports/stm32f4/common-hal/digitalio/DigitalInOut.c +++ b/ports/stm32f4/common-hal/digitalio/DigitalInOut.c @@ -47,7 +47,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct( GPIO_InitStruct.Pin = pin_mask(self->pin->number); GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct); return DIGITALINOUT_OK; @@ -73,7 +73,7 @@ void common_hal_digitalio_digitalinout_switch_to_input( GPIO_InitStruct.Pin = pin_mask(self->pin->number); GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct); common_hal_digitalio_digitalinout_set_pull(self, pull); @@ -114,7 +114,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode( GPIO_InitStruct.Mode = (drive_mode == DRIVE_MODE_OPEN_DRAIN ? GPIO_MODE_OUTPUT_OD : GPIO_MODE_OUTPUT_PP); GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct); } diff --git a/ports/stm32f4/common-hal/neopixel_write/__init__.c b/ports/stm32f4/common-hal/neopixel_write/__init__.c index fd46825d03..23fe7870f5 100644 --- a/ports/stm32f4/common-hal/neopixel_write/__init__.c +++ b/ports/stm32f4/common-hal/neopixel_write/__init__.c @@ -28,6 +28,8 @@ #include "shared-bindings/neopixel_write/__init__.h" #include "tick.h" +#include "py/mperrno.h" +#include "py/runtime.h" #include "common-hal/microcontroller/Pin.h" #include "stm32f4xx_hal.h" #include "stm32f4xx_ll_gpio.h" @@ -40,6 +42,9 @@ uint32_t next_start_tick_us = 1000; #define MAGIC_800_T0H 2800000 // ~0.36 us -> 0.44 field #define MAGIC_800_T1H 1350000 // ~0.74 us -> 0.84 field +#pragma GCC push_options +#pragma GCC optimize ("Os") + void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) { uint8_t *p = pixels, *end = p + numBytes, pix = *p++, mask = 0x80; @@ -48,7 +53,7 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout //assumes 800_000Hz frequency //Theoretical values here are 800_000 -> 1.25us, 2500000->0.4us, 1250000->0.8us - //But they don't work, possibly due to bad optimization? Use tested magic values instead + //TODO: try to get dynamic weighting working again uint32_t sys_freq = HAL_RCC_GetSysClockFreq(); uint32_t interval = sys_freq/MAGIC_800_INT; uint32_t t0 = (sys_freq/MAGIC_800_T0H); @@ -63,23 +68,26 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout __disable_irq(); // Enable DWT in debug core. Useable when interrupts disabled, as opposed to Systick->VAL - //ITM->LAR = 0xC5ACCE55; //this should be required but isn't CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; DWT->CYCCNT = 0; for(;;) { + cyc = (pix & mask) ? t1 : t0; start = DWT->CYCCNT; LL_GPIO_SetOutputPin(p_port, p_mask); - cyc = (pix & mask) ? t1 : t0; - while(DWT->CYCCNT - start < cyc); + while((DWT->CYCCNT - start) < cyc) { + __asm__ __volatile__("nop"); + } LL_GPIO_ResetOutputPin(p_port, p_mask); + while((DWT->CYCCNT - start) < interval) { + __asm__ __volatile__("nop"); + } if(!(mask >>= 1)) { if(p >= end) break; pix = *p++; mask = 0x80; } - while(DWT->CYCCNT - start < interval); //wait for interval to finish } // Enable interrupts again @@ -94,3 +102,5 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout next_start_tick_us -= 100; } } + +#pragma GCC pop_options \ No newline at end of file From 012b3bdf1869114a383baeef29300b588c234d81 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 3 Dec 2019 16:18:49 -0500 Subject: [PATCH 123/531] Add I2C never reset, SPI bugfix --- ports/stm32f4/common-hal/busio/I2C.c | 25 +++++++++++++++++++++---- ports/stm32f4/common-hal/busio/SPI.c | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index c2f5dbe0a2..d2292845ea 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -36,6 +36,7 @@ #include "common-hal/microcontroller/Pin.h" STATIC bool reserved_i2c[3]; +STATIC bool never_reset[3]; void i2c_reset(void) { //Note: I2Cs are also forcibly reset in construct, due to silicon error @@ -48,11 +49,24 @@ void i2c_reset(void) { __HAL_RCC_I2C2_CLK_DISABLE(); #endif #ifdef I2C3 - reserved_i2c[3] = false; + reserved_i2c[2] = false; __HAL_RCC_I2C3_CLK_DISABLE(); #endif } +void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { + for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) { + if (self->handle.Instance == mcu_i2c_banks[i]) { + never_reset[i] = true; + + never_reset_pin_number(self->scl->pin->port, self->scl->pin->number); + never_reset_pin_number(self->sda->pin->port, self->scl->pin->number); + break; + } + } +} + + void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) { @@ -166,19 +180,22 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { } #ifdef I2C1 if(self->handle.Instance==I2C1) { - reserved_i2c[0] = 0; + never_reset[0] = false; + reserved_i2c[0] = false; __HAL_RCC_I2C1_CLK_DISABLE(); } #endif #ifdef I2C2 if(self->handle.Instance==I2C2) { - reserved_i2c[1] = 0; + never_reset[1] = false; + reserved_i2c[1] = false; __HAL_RCC_I2C2_CLK_DISABLE(); } #endif #ifdef I2C3 if(self->handle.Instance==I2C3) { - reserved_i2c[3] = 0; + never_reset[2] = false; + reserved_i2c[2] = false; __HAL_RCC_I2C3_CLK_DISABLE(); } #endif diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index b5517f470f..1142657b7f 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -191,7 +191,8 @@ bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) { void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { spi_clock_disable(1<<(self->sck->spi_index - 1)); - reserved_spi[self->sck->spi_index - 1] = true; + reserved_spi[self->sck->spi_index - 1] = false; + never_reset_spi[self->sck->spi_index - 1] = false; reset_pin_number(self->sck->pin->port,self->sck->pin->number); reset_pin_number(self->mosi->pin->port,self->mosi->pin->number); From e6b45656f9ce93aee719542ff8aa3e966d6b1a67 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 3 Dec 2019 17:18:42 -0500 Subject: [PATCH 124/531] Add module and empty parallelbus --- .../common-hal/displayio/ParallelBus.c | 68 +++++++++++++++++++ .../common-hal/displayio/ParallelBus.h | 36 ++++++++++ ports/stm32f4/mpconfigport.mk | 3 + 3 files changed, 107 insertions(+) create mode 100644 ports/stm32f4/common-hal/displayio/ParallelBus.c create mode 100644 ports/stm32f4/common-hal/displayio/ParallelBus.h diff --git a/ports/stm32f4/common-hal/displayio/ParallelBus.c b/ports/stm32f4/common-hal/displayio/ParallelBus.c new file mode 100644 index 0000000000..1b808ec025 --- /dev/null +++ b/ports/stm32f4/common-hal/displayio/ParallelBus.c @@ -0,0 +1,68 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/displayio/ParallelBus.h" + +#include + +#include "common-hal/microcontroller/Pin.h" +#include "py/runtime.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/microcontroller/__init__.h" + +#include "tick.h" + +void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self, + const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select, + const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) { + + mp_raise_NotImplementedError(translate("ParallelBus not yet supported")); +} + +void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self) { + +} + +bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { + return false; +} + +bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { + return false; +} + +bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { + + return false; +} + +void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) { + +} + +void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { + +} diff --git a/ports/stm32f4/common-hal/displayio/ParallelBus.h b/ports/stm32f4/common-hal/displayio/ParallelBus.h new file mode 100644 index 0000000000..85d100715e --- /dev/null +++ b/ports/stm32f4/common-hal/displayio/ParallelBus.h @@ -0,0 +1,36 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H + +#include "common-hal/digitalio/DigitalInOut.h" + +typedef struct { + mp_obj_base_t base; +} displayio_parallelbus_obj_t; + +#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk index 3ae0daaa08..88636a9d89 100644 --- a/ports/stm32f4/mpconfigport.mk +++ b/ports/stm32f4/mpconfigport.mk @@ -65,6 +65,9 @@ ifndef CIRCUITPY_NEOPIXEL_WRITE CIRCUITPY_NEOPIXEL_WRITE = 1 endif +ifndef +CIRCUITPY_DISPLAYIO = 1 +endif #ifeq ($(MCU_SUB_VARIANT), stm32f412zx) #endif From 238e12123690debaf2cf8488fb2a4d4003a06506 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 3 Dec 2019 14:50:37 -0600 Subject: [PATCH 125/531] protocols: Allow them to be (optionally) type-safe Protocols are nice, but there is no way for C code to verify whether a type's "protocol" structure actually implements some particular protocol. As a result, you can pass an object that implements the "vfs" protocol to one that expects the "stream" protocol, and the opposite of awesomeness ensues. This patch adds an OPTIONAL (but enabled by default) protocol identifier as the first member of any protocol structure. This identifier is simply a unique QSTR chosen by the protocol designer and used by each protocol implementer. When checking for protocol support, instead of just checking whether the object's type has a non-NULL protocol field, use `mp_proto_get` which implements the protocol check when possible. The existing protocols are now named: protocol_framebuf protocol_i2c protocol_pin protocol_stream protocol_spi protocol_vfs (most of these are unused in CP and are just inherited from MP; vfs and stream are definitely used though) I did not find any crashing examples, but here's one to give a flavor of what is improved, using `micropython_coverage`. Before the change, the vfs "ioctl" protocol is invoked, and the result is not intelligible as json (but it could have resulted in a hard fault, potentially): >>> import uos, ujson >>> u = uos.VfsPosix('/tmp') >>> ujson.load(u) Traceback (most recent call last): File "", line 1, in ValueError: syntax error in JSON After the change, the vfs object is correctly detected as not supporting the stream protocol: >>> ujson.load(p) Traceback (most recent call last): File "", line 1, in OSError: stream operation not supported --- extmod/machine_i2c.c | 21 ++++---- extmod/machine_i2c.h | 2 + extmod/machine_pinbase.c | 1 + extmod/machine_signal.c | 8 +-- extmod/machine_spi.c | 7 +-- extmod/machine_spi.h | 2 + extmod/modframebuf.c | 16 +++--- extmod/modlwip.c | 1 + extmod/modussl_axtls.c | 1 + extmod/modussl_mbedtls.c | 1 + extmod/moduzlib.c | 1 + extmod/modwebrepl.c | 1 + extmod/modwebsocket.c | 1 + extmod/vfs.c | 2 +- extmod/vfs.h | 2 + extmod/vfs_fat.c | 1 + extmod/vfs_fat_file.c | 2 + extmod/vfs_posix.c | 1 + extmod/vfs_posix_file.c | 2 + extmod/virtpin.c | 5 +- extmod/virtpin.h | 2 + lib/utils/sys_stdio_mphal.c | 2 + ports/unix/coverage.c | 2 + ports/unix/file.c | 2 + ports/unix/modusocket.c | 1 + py/modio.c | 2 + py/objstringio.c | 2 + py/proto.c | 50 +++++++++++++++++++ py/proto.h | 43 ++++++++++++++++ py/py.mk | 1 + py/stream.c | 11 ++-- py/stream.h | 4 +- shared-bindings/_bleio/CharacteristicBuffer.c | 1 + shared-bindings/busio/UART.c | 1 + shared-bindings/socket/__init__.c | 1 + shared-bindings/terminalio/Terminal.c | 1 + shared-bindings/usb_midi/PortIn.c | 1 + shared-bindings/usb_midi/PortOut.c | 1 + 38 files changed, 170 insertions(+), 36 deletions(-) create mode 100644 py/proto.c create mode 100644 py/proto.h diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c index 85b46a9f6b..4129ace0a0 100644 --- a/extmod/machine_i2c.c +++ b/extmod/machine_i2c.c @@ -318,7 +318,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_init_obj, 1, machine_i2c_obj_init); STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) { mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); mp_obj_t list = mp_obj_new_list(0, NULL); // 7-bit addresses 0b0000xxx and 0b1111xxx are reserved for (int addr = 0x08; addr < 0x78; ++addr) { @@ -333,7 +333,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_scan_obj, machine_i2c_scan); STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); if (i2c_p->start == NULL) { mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); } @@ -347,7 +347,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_start_obj, machine_i2c_start); STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); if (i2c_p->stop == NULL) { mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); } @@ -361,7 +361,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_stop_obj, machine_i2c_stop); STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); if (i2c_p->read == NULL) { mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); } @@ -385,7 +385,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readinto_obj, 2, 3, machine_i2c_ STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); if (i2c_p->write == NULL) { mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); } @@ -407,7 +407,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_write_obj, machine_i2c_write); STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); mp_int_t addr = mp_obj_get_int(args[1]); vstr_t vstr; vstr_init_len(&vstr, mp_obj_get_int(args[2])); @@ -422,7 +422,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_obj, 3, 4, machine_i2c_ STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); mp_int_t addr = mp_obj_get_int(args[1]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE); @@ -437,7 +437,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_into_obj, 3, 4, machine STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); mp_int_t addr = mp_obj_get_int(args[1]); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); @@ -453,7 +453,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writeto_obj, 3, 4, machin STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); uint8_t memaddr_buf[4]; size_t memaddr_len = 0; for (int16_t i = addrsize - 8; i >= 0; i -= 8) { @@ -473,7 +473,7 @@ STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t a STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) { mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); - mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; + mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c); // need some memory to create the buffer to send; try to use stack if possible uint8_t buf2_stack[MAX_MEMADDR_SIZE + BUF_STACK_SIZE]; @@ -621,6 +621,7 @@ int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t } STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_i2c) .start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start, .stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop, .read = mp_machine_soft_i2c_read, diff --git a/extmod/machine_i2c.h b/extmod/machine_i2c.h index f5af6656f5..7f5ee568e3 100644 --- a/extmod/machine_i2c.h +++ b/extmod/machine_i2c.h @@ -27,10 +27,12 @@ #define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H #include "py/obj.h" +#include "py/proto.h" // I2C protocol // the first 4 methods can be NULL, meaning operation is not supported typedef struct _mp_machine_i2c_p_t { + MP_PROTOCOL_HEAD int (*start)(mp_obj_base_t *obj); int (*stop)(mp_obj_base_t *obj); int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack); diff --git a/extmod/machine_pinbase.c b/extmod/machine_pinbase.c index 997a6fd991..6cd14c187e 100644 --- a/extmod/machine_pinbase.c +++ b/extmod/machine_pinbase.c @@ -74,6 +74,7 @@ mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *err } STATIC const mp_pin_p_t pinbase_pin_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin) .ioctl = pinbase_ioctl, }; diff --git a/extmod/machine_signal.c b/extmod/machine_signal.c index 62658cbb17..50501e34fe 100644 --- a/extmod/machine_signal.c +++ b/extmod/machine_signal.c @@ -47,12 +47,7 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, const bool invert = false; #if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW) - mp_pin_p_t *pin_p = NULL; - - if (MP_OBJ_IS_OBJ(pin)) { - mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - pin_p = (mp_pin_p_t*)pin_base->type->protocol; - } + mp_pin_p_t *pin_p = (mp_pin_t*)mp_proto_get(QSTR_pin_protocol, pin); if (pin_p == NULL) { // If first argument isn't a Pin-like object, we filter out "invert" @@ -170,6 +165,7 @@ STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table); STATIC const mp_pin_p_t signal_pin_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin) .ioctl = signal_ioctl, }; diff --git a/extmod/machine_spi.c b/extmod/machine_spi.c index c5707a3d0b..4ead321d90 100644 --- a/extmod/machine_spi.c +++ b/extmod/machine_spi.c @@ -67,7 +67,7 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, const STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); - mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; + mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s); spi_p->init(s, n_args - 1, args + 1, kw_args); return mp_const_none; } @@ -75,7 +75,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init); STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) { mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); - mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; + mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s); if (spi_p->deinit != NULL) { spi_p->deinit(s); } @@ -85,7 +85,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_spi_deinit_obj, machine_spi_deinit); STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) { mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); - mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; + mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s); spi_p->transfer(s, len, src, dest); } @@ -268,6 +268,7 @@ STATIC void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, con } const mp_machine_spi_p_t mp_machine_soft_spi_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_spi) .init = mp_machine_soft_spi_init, .deinit = NULL, .transfer = mp_machine_soft_spi_transfer, diff --git a/extmod/machine_spi.h b/extmod/machine_spi.h index db21e1cd31..365b44d6e8 100644 --- a/extmod/machine_spi.h +++ b/extmod/machine_spi.h @@ -27,11 +27,13 @@ #define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H #include "py/obj.h" +#include "py/proto.h" #include "py/mphal.h" #include "drivers/bus/spi.h" // SPI protocol typedef struct _mp_machine_spi_p_t { + MP_PROTOCOL_HEAD void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); void (*deinit)(mp_obj_base_t *obj); // can be NULL void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest); diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index 561b842bcc..a51d1c3804 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -28,6 +28,7 @@ #include #include "py/runtime.h" +#include "py/proto.h" #if MICROPY_PY_FRAMEBUF @@ -46,6 +47,7 @@ typedef uint32_t (*getpixel_t)(const mp_obj_framebuf_t*, int, int); typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t); typedef struct _mp_framebuf_p_t { + MP_PROTOCOL_HEAD setpixel_t setpixel; getpixel_t getpixel; fill_rect_t fill_rect; @@ -227,13 +229,13 @@ STATIC void gs8_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int } STATIC mp_framebuf_p_t formats[] = { - [FRAMEBUF_MVLSB] = {mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect}, - [FRAMEBUF_RGB565] = {rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect}, - [FRAMEBUF_GS2_HMSB] = {gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect}, - [FRAMEBUF_GS4_HMSB] = {gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect}, - [FRAMEBUF_GS8] = {gs8_setpixel, gs8_getpixel, gs8_fill_rect}, - [FRAMEBUF_MHLSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, - [FRAMEBUF_MHMSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, + [FRAMEBUF_MVLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect}, + [FRAMEBUF_RGB565] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect}, + [FRAMEBUF_GS2_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect}, + [FRAMEBUF_GS4_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect}, + [FRAMEBUF_GS8] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs8_setpixel, gs8_getpixel, gs8_fill_rect}, + [FRAMEBUF_MHLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, + [FRAMEBUF_MHMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, }; static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { diff --git a/extmod/modlwip.c b/extmod/modlwip.c index e5e92c42b5..776b81ee51 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -1261,6 +1261,7 @@ STATIC const mp_rom_map_elem_t lwip_socket_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_table); STATIC const mp_stream_p_t lwip_socket_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = lwip_socket_read, .write = lwip_socket_write, .ioctl = lwip_socket_ioctl, diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c index cfa6525853..032dea09fd 100644 --- a/extmod/modussl_axtls.c +++ b/extmod/modussl_axtls.c @@ -221,6 +221,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); STATIC const mp_stream_p_t ussl_socket_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = socket_read, .write = socket_write, .ioctl = socket_ioctl, diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index 08807d20ba..9abdeb966e 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -305,6 +305,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); STATIC const mp_stream_p_t ussl_socket_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = socket_read, .write = socket_write, .ioctl = socket_ioctl, diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index 7f15d02a8e..3a081bc452 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -134,6 +134,7 @@ STATIC const mp_rom_map_elem_t decompio_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table); STATIC const mp_stream_p_t decompio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = decompio_read, }; diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c index 06da210d15..fb4d97358d 100644 --- a/extmod/modwebrepl.c +++ b/extmod/modwebrepl.c @@ -331,6 +331,7 @@ STATIC const mp_rom_map_elem_t webrepl_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(webrepl_locals_dict, webrepl_locals_dict_table); STATIC const mp_stream_p_t webrepl_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = webrepl_read, .write = webrepl_write, .ioctl = webrepl_ioctl, diff --git a/extmod/modwebsocket.c b/extmod/modwebsocket.c index 997c7e2625..496e4b5bb3 100644 --- a/extmod/modwebsocket.c +++ b/extmod/modwebsocket.c @@ -286,6 +286,7 @@ STATIC const mp_rom_map_elem_t websocket_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(websocket_locals_dict, websocket_locals_dict_table); STATIC const mp_stream_p_t websocket_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = websocket_read, .write = websocket_write, .ioctl = websocket_ioctl, diff --git a/extmod/vfs.c b/extmod/vfs.c index 7d6e6999bd..2bb4057e7e 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -126,7 +126,7 @@ mp_import_stat_t mp_vfs_import_stat(const char *path) { } // If the mounted object has the VFS protocol, call its import_stat helper - const mp_vfs_proto_t *proto = mp_obj_get_type(vfs->obj)->protocol; + const mp_vfs_proto_t *proto = (mp_vfs_proto_t*)mp_proto_get(MP_QSTR_protocol_vfs, vfs->obj); if (proto != NULL) { return proto->import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out); } diff --git a/extmod/vfs.h b/extmod/vfs.h index 38c77943c7..6c0692365f 100644 --- a/extmod/vfs.h +++ b/extmod/vfs.h @@ -28,6 +28,7 @@ #include "py/lexer.h" #include "py/obj.h" +#include "py/proto.h" // return values of mp_vfs_lookup_path // ROOT is 0 so that the default current directory is the root directory @@ -47,6 +48,7 @@ // At the moment the VFS protocol just has import_stat, but could be extended to other methods typedef struct _mp_vfs_proto_t { + MP_PROTOCOL_HEAD mp_import_stat_t (*import_stat)(void *self, const char *path); } mp_vfs_proto_t; diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 20d3e3e5ce..60f4393f43 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -488,6 +488,7 @@ STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table); STATIC const mp_vfs_proto_t fat_vfs_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_vfs) .import_stat = fat_vfs_import_stat, }; diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 6aad1884cb..3ea9cee529 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -254,6 +254,7 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); #if MICROPY_PY_IO_FILEIO STATIC const mp_stream_p_t fileio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = file_obj_read, .write = file_obj_write, .ioctl = file_obj_ioctl, @@ -272,6 +273,7 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = { #endif STATIC const mp_stream_p_t textio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = file_obj_read, .write = file_obj_write, .ioctl = file_obj_ioctl, diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c index d28dfe4516..56a5de303d 100644 --- a/extmod/vfs_posix.c +++ b/extmod/vfs_posix.c @@ -350,6 +350,7 @@ STATIC const mp_rom_map_elem_t vfs_posix_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(vfs_posix_locals_dict, vfs_posix_locals_dict_table); STATIC const mp_vfs_proto_t vfs_posix_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_vfs) .import_stat = mp_vfs_posix_import_stat, }; diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index b760b38474..be455fa281 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -220,6 +220,7 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); #if MICROPY_PY_IO_FILEIO STATIC const mp_stream_p_t fileio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = vfs_posix_file_read, .write = vfs_posix_file_write, .ioctl = vfs_posix_file_ioctl, @@ -238,6 +239,7 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = { #endif STATIC const mp_stream_p_t textio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = vfs_posix_file_read, .write = vfs_posix_file_write, .ioctl = vfs_posix_file_ioctl, diff --git a/extmod/virtpin.c b/extmod/virtpin.c index dbfa21d669..559f992650 100644 --- a/extmod/virtpin.c +++ b/extmod/virtpin.c @@ -25,15 +25,16 @@ */ #include "extmod/virtpin.h" +#include "py/proto.h" int mp_virtual_pin_read(mp_obj_t pin) { mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); - mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; + const mp_pin_p_t *pin_p = mp_proto_get(MP_QSTR_protocol_pin, s); return pin_p->ioctl(pin, MP_PIN_READ, 0, NULL); } void mp_virtual_pin_write(mp_obj_t pin, int value) { mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); - mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; + const mp_pin_p_t *pin_p = mp_proto_get(MP_QSTR_protocol_pin, s); pin_p->ioctl(pin, MP_PIN_WRITE, value, NULL); } diff --git a/extmod/virtpin.h b/extmod/virtpin.h index 706affc192..591249e48d 100644 --- a/extmod/virtpin.h +++ b/extmod/virtpin.h @@ -27,6 +27,7 @@ #define MICROPY_INCLUDED_EXTMOD_VIRTPIN_H #include "py/obj.h" +#include "py/proto.h" #define MP_PIN_READ (1) #define MP_PIN_WRITE (2) @@ -35,6 +36,7 @@ // Pin protocol typedef struct _mp_pin_p_t { + MP_PROTOCOL_HEAD mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); } mp_pin_p_t; diff --git a/lib/utils/sys_stdio_mphal.c b/lib/utils/sys_stdio_mphal.c index 266783f376..c1607dfe8c 100644 --- a/lib/utils/sys_stdio_mphal.c +++ b/lib/utils/sys_stdio_mphal.c @@ -123,6 +123,7 @@ STATIC const mp_rom_map_elem_t stdio_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(stdio_locals_dict, stdio_locals_dict_table); STATIC const mp_stream_p_t stdio_obj_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = stdio_read, .write = stdio_write, .ioctl = stdio_ioctl, @@ -158,6 +159,7 @@ STATIC mp_uint_t stdio_buffer_write(mp_obj_t self_in, const void *buf, mp_uint_t } STATIC const mp_stream_p_t stdio_buffer_obj_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = stdio_buffer_read, .write = stdio_buffer_write, .is_text = false, diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 841924c58d..849820fffd 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -96,6 +96,7 @@ STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); STATIC const mp_stream_p_t fileio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = stest_read, .write = stest_write, .ioctl = stest_ioctl, @@ -123,6 +124,7 @@ STATIC const mp_rom_map_elem_t rawfile_locals_dict_table2[] = { STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict2, rawfile_locals_dict_table2); STATIC const mp_stream_p_t textio_stream_p2 = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = stest_read2, .write = NULL, .is_text = true, diff --git a/ports/unix/file.c b/ports/unix/file.c index c0cf6dcc43..e5c73d26c2 100644 --- a/ports/unix/file.c +++ b/ports/unix/file.c @@ -230,6 +230,7 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); #if MICROPY_PY_IO_FILEIO STATIC const mp_stream_p_t fileio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = fdfile_read, .write = fdfile_write, .ioctl = fdfile_ioctl, @@ -248,6 +249,7 @@ const mp_obj_type_t mp_type_fileio = { #endif STATIC const mp_stream_p_t textio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = fdfile_read, .write = fdfile_write, .ioctl = fdfile_ioctl, diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c index 84e9298fd3..95da276ed9 100644 --- a/ports/unix/modusocket.c +++ b/ports/unix/modusocket.c @@ -374,6 +374,7 @@ STATIC const mp_rom_map_elem_t usocket_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(usocket_locals_dict, usocket_locals_dict_table); STATIC const mp_stream_p_t usocket_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = socket_read, .write = socket_write, .ioctl = socket_ioctl, diff --git a/py/modio.c b/py/modio.c index d7c1a58a8c..17840a6d87 100644 --- a/py/modio.c +++ b/py/modio.c @@ -90,6 +90,7 @@ STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, in } STATIC const mp_stream_p_t iobase_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = iobase_read, .write = iobase_write, .ioctl = iobase_ioctl, @@ -185,6 +186,7 @@ STATIC const mp_rom_map_elem_t bufwriter_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table); STATIC const mp_stream_p_t bufwriter_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .write = bufwriter_write, }; diff --git a/py/objstringio.c b/py/objstringio.c index d2ca6decdb..178e6446cc 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -240,6 +240,7 @@ STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table); STATIC const mp_stream_p_t stringio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = stringio_read, .write = stringio_write, .ioctl = stringio_ioctl, @@ -247,6 +248,7 @@ STATIC const mp_stream_p_t stringio_stream_p = { }; STATIC const mp_stream_p_t bytesio_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = stringio_read, .write = stringio_write, .ioctl = stringio_ioctl, diff --git a/py/proto.c b/py/proto.c new file mode 100644 index 0000000000..030b62674e --- /dev/null +++ b/py/proto.c @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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 "py/obj.h" +#include "py/proto.h" +#include "py/runtime.h" + +#ifndef MICROPY_UNSAFE_PROTO +const void *mp_proto_get(uint16_t name, mp_const_obj_t obj) { + mp_obj_type_t *type = mp_obj_get_type(obj); + if (!type->protocol) return NULL; + uint16_t proto_name = *(const uint16_t*) type->protocol; + if (proto_name == name) { + return type->protocol; + } + return NULL; +} +#endif + +const void *mp_proto_get_or_throw(uint16_t name, mp_const_obj_t obj) { + const void *proto = mp_proto_get(name, obj); + if (proto) { + return proto; + } + mp_raise_TypeError_varg(translate("'%s' object does not support '%s'"), + mp_obj_get_type_str(obj), qstr_str(name)); +} diff --git a/py/proto.h b/py/proto.h new file mode 100644 index 0000000000..2d4f805659 --- /dev/null +++ b/py/proto.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_PY_PROTO_H +#define MICROPY_INCLUDED_PY_PROTO_H + +#ifdef MICROPY_UNSAFE_PROTO +#define MP_PROTOCOL_HEAD /* NOTHING */ +#define MP_PROTO_IMPLEMENT(name) /* NOTHING */ +static inline void *mp_proto_get(uint16_t name, mp_const_obj_type_t obj) { return mp_obj_get_type(obj)->protocol; } +#else +#define MP_PROTOCOL_HEAD \ + uint16_t name; // The name of this protocol, a qstr +#define MP_PROTO_IMPLEMENT(n) .name = n, +const void *mp_proto_get(uint16_t name, mp_const_obj_t obj); +const void *mp_proto_get_or_throw(uint16_t name, mp_const_obj_t obj); +#endif + +#endif + diff --git a/py/py.mk b/py/py.mk index 17cb792646..ae9b005b6c 100644 --- a/py/py.mk +++ b/py/py.mk @@ -214,6 +214,7 @@ PY_CORE_O_BASENAME = $(addprefix py/,\ objtype.o \ objzip.o \ opmethods.o \ + proto.o \ reload.o \ sequence.o \ stream.o \ diff --git a/py/stream.c b/py/stream.c index 1d25f64706..2ff2b76a61 100644 --- a/py/stream.c +++ b/py/stream.c @@ -86,8 +86,7 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode } const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - const mp_stream_p_t *stream_p = type->protocol; + const mp_stream_p_t *stream_p = mp_proto_get(MP_QSTR_protocol_stream, self_in); if (stream_p == NULL || ((flags & MP_STREAM_OP_READ) && stream_p->read == NULL) || ((flags & MP_STREAM_OP_WRITE) && stream_p->write == NULL) @@ -522,7 +521,7 @@ int mp_stream_errno; ssize_t mp_stream_posix_write(mp_obj_t stream, const void *buf, size_t len) { mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = mp_get_stream(o); mp_uint_t out_sz = stream_p->write(stream, buf, len, &mp_stream_errno); if (out_sz == MP_STREAM_ERROR) { return -1; @@ -533,7 +532,7 @@ ssize_t mp_stream_posix_write(mp_obj_t stream, const void *buf, size_t len) { ssize_t mp_stream_posix_read(mp_obj_t stream, void *buf, size_t len) { mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = mp_get_stream(o); mp_uint_t out_sz = stream_p->read(stream, buf, len, &mp_stream_errno); if (out_sz == MP_STREAM_ERROR) { return -1; @@ -544,7 +543,7 @@ ssize_t mp_stream_posix_read(mp_obj_t stream, void *buf, size_t len) { off_t mp_stream_posix_lseek(mp_obj_t stream, off_t offset, int whence) { const mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = mp_get_stream(o); struct mp_stream_seek_t seek_s; seek_s.offset = offset; seek_s.whence = whence; @@ -557,7 +556,7 @@ off_t mp_stream_posix_lseek(mp_obj_t stream, off_t offset, int whence) { int mp_stream_posix_fsync(mp_obj_t stream) { mp_obj_base_t* o = (mp_obj_base_t*)MP_OBJ_TO_PTR(stream); - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = mp_get_stream(o); mp_uint_t res = stream_p->ioctl(stream, MP_STREAM_FLUSH, 0, &mp_stream_errno); if (res == MP_STREAM_ERROR) { return -1; diff --git a/py/stream.h b/py/stream.h index 03e24c7469..543fe8c82a 100644 --- a/py/stream.h +++ b/py/stream.h @@ -27,6 +27,7 @@ #define MICROPY_INCLUDED_PY_STREAM_H #include "py/obj.h" +#include "py/proto.h" #include "py/mperrno.h" #define MP_STREAM_ERROR ((mp_uint_t)-1) @@ -64,6 +65,7 @@ struct mp_stream_seek_t { // Stream protocol typedef struct _mp_stream_p_t { + MP_PROTOCOL_HEAD // On error, functions should return MP_STREAM_ERROR and fill in *errcode (values // are implementation-dependent, but will be exposed to user, e.g. via exception). mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); @@ -93,7 +95,7 @@ MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_ioctl_obj); // Object is assumed to have a non-NULL stream protocol with valid r/w/ioctl methods static inline const mp_stream_p_t *mp_get_stream(mp_const_obj_t self) { - return (const mp_stream_p_t*)((const mp_obj_base_t*)MP_OBJ_TO_PTR(self))->type->protocol; + return mp_proto_get(MP_QSTR_protocol_stream, self); } const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags); diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index e7524da2d5..fc95d0d503 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -230,6 +230,7 @@ STATIC const mp_rom_map_elem_t bleio_characteristic_buffer_locals_dict_table[] = STATIC MP_DEFINE_CONST_DICT(bleio_characteristic_buffer_locals_dict, bleio_characteristic_buffer_locals_dict_table); STATIC const mp_stream_p_t characteristic_buffer_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = bleio_characteristic_buffer_read, .write = bleio_characteristic_buffer_write, .ioctl = bleio_characteristic_buffer_ioctl, diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 7a3b48e895..1fc81e78e2 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -398,6 +398,7 @@ STATIC const mp_rom_map_elem_t busio_uart_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(busio_uart_locals_dict, busio_uart_locals_dict_table); STATIC const mp_stream_p_t uart_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = busio_uart_read, .write = busio_uart_write, .ioctl = busio_uart_ioctl, diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c index 6d04a98936..2d6c16e90f 100644 --- a/shared-bindings/socket/__init__.c +++ b/shared-bindings/socket/__init__.c @@ -500,6 +500,7 @@ mp_uint_t socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int * } STATIC const mp_stream_p_t socket_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .ioctl = socket_ioctl, .is_text = false, }; diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index cdde672d3a..9c01fba20b 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -112,6 +112,7 @@ STATIC const mp_rom_map_elem_t terminalio_terminal_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(terminalio_terminal_locals_dict, terminalio_terminal_locals_dict_table); STATIC const mp_stream_p_t terminalio_terminal_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = NULL, .write = terminalio_terminal_write, .ioctl = terminalio_terminal_ioctl, diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index 356a81d52c..e2df56e954 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -107,6 +107,7 @@ STATIC const mp_rom_map_elem_t usb_midi_portin_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(usb_midi_portin_locals_dict, usb_midi_portin_locals_dict_table); STATIC const mp_stream_p_t usb_midi_portin_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = usb_midi_portin_read, .write = NULL, .ioctl = usb_midi_portin_ioctl, diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index 6f4ce67165..e3eddfaf57 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -89,6 +89,7 @@ STATIC const mp_rom_map_elem_t usb_midi_portout_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(usb_midi_portout_locals_dict, usb_midi_portout_locals_dict_table); STATIC const mp_stream_p_t usb_midi_portout_stream_p = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = NULL, .write = usb_midi_portout_write, .ioctl = usb_midi_portout_ioctl, From feb8eb935bd69ce855533bf9a4316e3025602c1a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 4 Dec 2019 09:31:52 -0600 Subject: [PATCH 126/531] audiosample: convert to use a protocol This eases addition of new sample sources, since the manual virtual function dispatch functions are just calls via a protocol --- shared-bindings/audiocore/RawSample.c | 11 ++++ shared-bindings/audiocore/RawSample.h | 2 + shared-bindings/audiocore/WaveFile.c | 12 ++++ shared-bindings/audiomixer/Mixer.c | 11 ++++ shared-bindings/audiomixer/Mixer.h | 2 + shared-module/audiocore/RawSample.c | 6 ++ shared-module/audiocore/__init__.c | 92 ++++----------------------- shared-module/audiocore/__init__.h | 35 ++++++++-- shared-module/audiomixer/Mixer.c | 8 +++ 9 files changed, 94 insertions(+), 85 deletions(-) diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 07f8c683f2..87d410ea1a 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -180,9 +180,20 @@ STATIC const mp_rom_map_elem_t audioio_rawsample_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(audioio_rawsample_locals_dict, audioio_rawsample_locals_dict_table); +STATIC const audiosample_p_t audioio_rawsample_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) + .sample_rate = (audiosample_sample_rate_fun)common_hal_audioio_rawsample_get_sample_rate, + .bits_per_sample = (audiosample_bits_per_sample_fun)common_hal_audioio_rawsample_get_bits_per_sample, + .channel_count = (audiosample_channel_count_fun)common_hal_audioio_rawsample_get_channel_count, + .reset_buffer = (audiosample_reset_buffer_fun)audioio_rawsample_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)audioio_rawsample_get_buffer, + .get_buffer_structure = (audiosample_get_buffer_structure_fun)audioio_rawsample_get_buffer_structure, +}; + const mp_obj_type_t audioio_rawsample_type = { { &mp_type_type }, .name = MP_QSTR_RawSample, .make_new = audioio_rawsample_make_new, .locals_dict = (mp_obj_dict_t*)&audioio_rawsample_locals_dict, + .protocol = &audioio_rawsample_proto, }; diff --git a/shared-bindings/audiocore/RawSample.h b/shared-bindings/audiocore/RawSample.h index b02778cad3..61f61a0662 100644 --- a/shared-bindings/audiocore/RawSample.h +++ b/shared-bindings/audiocore/RawSample.h @@ -39,6 +39,8 @@ void common_hal_audioio_rawsample_construct(audioio_rawsample_obj_t* self, void common_hal_audioio_rawsample_deinit(audioio_rawsample_obj_t* self); bool common_hal_audioio_rawsample_deinited(audioio_rawsample_obj_t* self); uint32_t common_hal_audioio_rawsample_get_sample_rate(audioio_rawsample_obj_t* self); +uint8_t common_hal_audioio_rawsample_get_bits_per_sample(audioio_rawsample_obj_t* self); +uint8_t common_hal_audioio_rawsample_get_channel_count(audioio_rawsample_obj_t* self); void common_hal_audioio_rawsample_set_sample_rate(audioio_rawsample_obj_t* self, uint32_t sample_rate); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 1b3a94ff37..178d2a1393 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -206,9 +206,21 @@ STATIC const mp_rom_map_elem_t audioio_wavefile_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(audioio_wavefile_locals_dict, audioio_wavefile_locals_dict_table); +STATIC const audiosample_p_t audioio_wavefile_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) + .sample_rate = (audiosample_sample_rate_fun)common_hal_audioio_wavefile_get_sample_rate, + .bits_per_sample = (audiosample_bits_per_sample_fun)common_hal_audioio_wavefile_get_bits_per_sample, + .channel_count = (audiosample_channel_count_fun)common_hal_audioio_wavefile_get_channel_count, + .reset_buffer = (audiosample_reset_buffer_fun)audioio_wavefile_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)audioio_wavefile_get_buffer, + .get_buffer_structure = (audiosample_get_buffer_structure_fun)audioio_wavefile_get_buffer_structure, +}; + + const mp_obj_type_t audioio_wavefile_type = { { &mp_type_type }, .name = MP_QSTR_WaveFile, .make_new = audioio_wavefile_make_new, .locals_dict = (mp_obj_dict_t*)&audioio_wavefile_locals_dict, + .protocol = &audioio_wavefile_proto, }; diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index ed7b95d9e0..03ffb9373b 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -291,9 +291,20 @@ STATIC const mp_rom_map_elem_t audiomixer_mixer_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(audiomixer_mixer_locals_dict, audiomixer_mixer_locals_dict_table); +STATIC const audiosample_p_t audiomixer_mixer_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) + .sample_rate = (audiosample_sample_rate_fun)common_hal_audiomixer_mixer_get_sample_rate, + .bits_per_sample = (audiosample_bits_per_sample_fun)common_hal_audiomixer_mixer_get_bits_per_sample, + .channel_count = (audiosample_channel_count_fun)common_hal_audiomixer_mixer_get_channel_count, + .reset_buffer = (audiosample_reset_buffer_fun)audiomixer_mixer_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)audiomixer_mixer_get_buffer, + .get_buffer_structure = (audiosample_get_buffer_structure_fun)audiomixer_mixer_get_buffer_structure, +}; + const mp_obj_type_t audiomixer_mixer_type = { { &mp_type_type }, .name = MP_QSTR_Mixer, .make_new = audiomixer_mixer_make_new, .locals_dict = (mp_obj_dict_t*)&audiomixer_mixer_locals_dict, + .protocol = &audiomixer_mixer_proto, }; diff --git a/shared-bindings/audiomixer/Mixer.h b/shared-bindings/audiomixer/Mixer.h index 9eabbf61df..a99e1bf62a 100644 --- a/shared-bindings/audiomixer/Mixer.h +++ b/shared-bindings/audiomixer/Mixer.h @@ -47,5 +47,7 @@ bool common_hal_audiomixer_mixer_deinited(audiomixer_mixer_obj_t* self); bool common_hal_audiomixer_mixer_get_playing(audiomixer_mixer_obj_t* self); uint32_t common_hal_audiomixer_mixer_get_sample_rate(audiomixer_mixer_obj_t* self); +uint8_t common_hal_audiomixer_mixer_get_channel_count(audiomixer_mixer_obj_t* self); +uint8_t common_hal_audiomixer_mixer_get_bits_per_sample(audiomixer_mixer_obj_t* self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H diff --git a/shared-module/audiocore/RawSample.c b/shared-module/audiocore/RawSample.c index d6bf3a567a..a69ddeb650 100644 --- a/shared-module/audiocore/RawSample.c +++ b/shared-module/audiocore/RawSample.c @@ -60,6 +60,12 @@ void common_hal_audioio_rawsample_set_sample_rate(audioio_rawsample_obj_t* self, uint32_t sample_rate) { self->sample_rate = sample_rate; } +uint8_t common_hal_audioio_rawsample_get_bits_per_sample(audioio_rawsample_obj_t* self) { + return self->bits_per_sample; +} +uint8_t common_hal_audioio_rawsample_get_channel_count(audioio_rawsample_obj_t* self) { + return self->channel_count; +} void audioio_rawsample_reset_buffer(audioio_rawsample_obj_t* self, bool single_channel, diff --git a/shared-module/audiocore/__init__.c b/shared-module/audiocore/__init__.c index f9762676fd..1553dbe961 100644 --- a/shared-module/audiocore/__init__.c +++ b/shared-module/audiocore/__init__.c @@ -36,103 +36,37 @@ #include "shared-module/audiomixer/Mixer.h" uint32_t audiosample_sample_rate(mp_obj_t sample_obj) { - if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) { - audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj); - return sample->sample_rate; - } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) { - audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - return file->sample_rate; - #if CIRCUITPY_AUDIOMIXER - } else if (MP_OBJ_IS_TYPE(sample_obj, &audiomixer_mixer_type)) { - audiomixer_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj); - return mixer->sample_rate; - #endif - } - return 16000; + const audiosample_p_t *proto = mp_proto_get_or_throw(MP_QSTR_protocol_audiosample, sample_obj); + return proto->sample_rate(MP_OBJ_TO_PTR(sample_obj)); } uint8_t audiosample_bits_per_sample(mp_obj_t sample_obj) { - if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) { - audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj); - return sample->bits_per_sample; - } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) { - audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - return file->bits_per_sample; - #if CIRCUITPY_AUDIOMIXER - } else if (MP_OBJ_IS_TYPE(sample_obj, &audiomixer_mixer_type)) { - audiomixer_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj); - return mixer->bits_per_sample; - #endif - } - return 8; + const audiosample_p_t *proto = mp_proto_get_or_throw(MP_QSTR_protocol_audiosample, sample_obj); + return proto->bits_per_sample(MP_OBJ_TO_PTR(sample_obj)); } uint8_t audiosample_channel_count(mp_obj_t sample_obj) { - if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) { - audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj); - return sample->channel_count; - } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) { - audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - return file->channel_count; - #if CIRCUITPY_AUDIOMIXER - } else if (MP_OBJ_IS_TYPE(sample_obj, &audiomixer_mixer_type)) { - audiomixer_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj); - return mixer->channel_count; - #endif - } - return 1; + const audiosample_p_t *proto = mp_proto_get_or_throw(MP_QSTR_protocol_audiosample, sample_obj); + return proto->channel_count(MP_OBJ_TO_PTR(sample_obj)); } void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel) { - if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) { - audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj); - audioio_rawsample_reset_buffer(sample, single_channel, audio_channel); - } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) { - audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - audioio_wavefile_reset_buffer(file, single_channel, audio_channel); - #if CIRCUITPY_AUDIOMIXER - } else if (MP_OBJ_IS_TYPE(sample_obj, &audiomixer_mixer_type)) { - audiomixer_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - audiomixer_mixer_reset_buffer(file, single_channel, audio_channel); - #endif - } + const audiosample_p_t *proto = mp_proto_get_or_throw(MP_QSTR_protocol_audiosample, sample_obj); + proto->reset_buffer(MP_OBJ_TO_PTR(sample_obj)); } audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t channel, uint8_t** buffer, uint32_t* buffer_length) { - if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) { - audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj); - return audioio_rawsample_get_buffer(sample, single_channel, channel, buffer, buffer_length); - } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) { - audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - return audioio_wavefile_get_buffer(file, single_channel, channel, buffer, buffer_length); - #if CIRCUITPY_AUDIOMIXER - } else if (MP_OBJ_IS_TYPE(sample_obj, &audiomixer_mixer_type)) { - audiomixer_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - return audiomixer_mixer_get_buffer(file, single_channel, channel, buffer, buffer_length); - #endif - } - return GET_BUFFER_DONE; + const audiosample_p_t *proto = mp_proto_get_or_throw(MP_QSTR_protocol_audiosample, sample_obj); + return proto->get_buffer(MP_OBJ_TO_PTR(sample_obj), single_channel, channel, buffer, buffer_length); } void audiosample_get_buffer_structure(mp_obj_t sample_obj, bool single_channel, bool* single_buffer, bool* samples_signed, uint32_t* max_buffer_length, uint8_t* spacing) { - if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) { - audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj); - audioio_rawsample_get_buffer_structure(sample, single_channel, single_buffer, - samples_signed, max_buffer_length, spacing); - } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) { - audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - audioio_wavefile_get_buffer_structure(file, single_channel, single_buffer, samples_signed, - max_buffer_length, spacing); - #if CIRCUITPY_AUDIOMIXER - } else if (MP_OBJ_IS_TYPE(sample_obj, &audiomixer_mixer_type)) { - audiomixer_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj); - audiomixer_mixer_get_buffer_structure(file, single_channel, single_buffer, samples_signed, - max_buffer_length, spacing); - #endif - } + const audiosample_p_t *proto = mp_proto_get_or_throw(MP_QSTR_protocol_audiosample, sample_obj); + proto->get_buffer_structure(MP_OBJ_TO_PTR(sample_obj), single_channel, single_buffer, + samples_signed, max_buffer_length, spacing); } diff --git a/shared-module/audiocore/__init__.h b/shared-module/audiocore/__init__.h index 7aa0c1824a..4b306f8ba0 100644 --- a/shared-module/audiocore/__init__.h +++ b/shared-module/audiocore/__init__.h @@ -31,6 +31,7 @@ #include #include "py/obj.h" +#include "py/proto.h" typedef enum { GET_BUFFER_DONE, // No more data to read @@ -38,15 +39,37 @@ typedef enum { GET_BUFFER_ERROR, // Error while reading data. } audioio_get_buffer_result_t; -uint32_t audiosample_sample_rate(mp_obj_t sample_obj); -uint8_t audiosample_bits_per_sample(mp_obj_t sample_obj); -uint8_t audiosample_channel_count(mp_obj_t sample_obj); -void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel); -audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj, +typedef uint32_t (*audiosample_sample_rate_fun)(void* sample_obj); +typedef uint8_t (*audiosample_bits_per_sample_fun)(void* sample_obj); +typedef uint8_t (*audiosample_channel_count_fun)(void* sample_obj); +typedef void (*audiosample_reset_buffer_fun)(void* sample_obj); +typedef audioio_get_buffer_result_t (*audiosample_get_buffer_fun)(void* sample_obj, + bool single_channel, uint8_t channel, uint8_t** buffer, + uint32_t* buffer_length); +typedef void (*audiosample_get_buffer_structure_fun)(void* sample_obj, + bool single_channel, bool* single_buffer, + bool* samples_signed, uint32_t *max_buffer_length, + uint8_t* spacing); + +typedef struct _audiosample_p_t { + MP_PROTOCOL_HEAD // MP_QSTR_protocol_audiosample + audiosample_sample_rate_fun sample_rate; + audiosample_bits_per_sample_fun bits_per_sample; + audiosample_channel_count_fun channel_count; + audiosample_reset_buffer_fun reset_buffer; + audiosample_get_buffer_fun get_buffer; + audiosample_get_buffer_structure_fun get_buffer_structure; +} audiosample_p_t; + +uint32_t audiosample_sample_rate(void* sample_obj); +uint8_t audiosample_bits_per_sample(void* sample_obj); +uint8_t audiosample_channel_count(void* sample_obj); +void audiosample_reset_buffer(void* sample_obj, bool single_channel, uint8_t audio_channel); +audioio_get_buffer_result_t audiosample_get_buffer(void* sample_obj, bool single_channel, uint8_t channel, uint8_t** buffer, uint32_t* buffer_length); -void audiosample_get_buffer_structure(mp_obj_t sample_obj, bool single_channel, +void audiosample_get_buffer_structure(void* sample_obj, bool single_channel, bool* single_buffer, bool* samples_signed, uint32_t* max_buffer_length, uint8_t* spacing); diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index a52489f856..afa3a06323 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -76,6 +76,14 @@ uint32_t common_hal_audiomixer_mixer_get_sample_rate(audiomixer_mixer_obj_t* sel return self->sample_rate; } +uint8_t common_hal_audiomixer_mixer_get_channel_count(audiomixer_mixer_obj_t* self) { + return self->channel_count; +} + +uint8_t common_hal_audiomixer_mixer_get_bits_per_sample(audiomixer_mixer_obj_t* self) { + return self->bits_per_sample; +} + bool common_hal_audiomixer_mixer_get_playing(audiomixer_mixer_obj_t* self) { for (uint8_t v = 0; v < self->voice_count; v++) { if (common_hal_audiomixer_mixervoice_get_playing(MP_OBJ_TO_PTR(self->voice[v]))) { From e2f319fc6b110dcc22e2f07ededfe58a2e94bd44 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 4 Dec 2019 09:59:00 -0600 Subject: [PATCH 127/531] Update translations --- locale/ID.po | 7 ++++++- locale/circuitpython.pot | 7 ++++++- locale/de_DE.po | 7 ++++++- locale/en_US.po | 7 ++++++- locale/en_x_pirate.po | 7 ++++++- locale/es.po | 7 ++++++- locale/fil.po | 7 ++++++- locale/fr.po | 7 ++++++- locale/it_IT.po | 7 ++++++- locale/ko.po | 7 ++++++- locale/pl.po | 7 ++++++- locale/pt_BR.po | 7 ++++++- locale/zh_Latn_pinyin.po | 7 ++++++- 13 files changed, 78 insertions(+), 13 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 6a0b73b6f7..d3d025379c 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -120,6 +120,11 @@ msgstr "" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' integer 0x%x tidak cukup didalam mask 0x%x" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index a24ab186a4..f9edf50af3 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:58-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -119,6 +119,11 @@ msgstr "" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/de_DE.po b/locale/de_DE.po index 37937b94f7..d6c3fc359c 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -121,6 +121,11 @@ msgstr "'%s' integer %d ist nicht im Bereich %d..%d" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' Integer 0x%x passt nicht in Maske 0x%x" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/en_US.po b/locale/en_US.po index e0e63e4fd4..a2e18f8ad2 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -119,6 +119,11 @@ msgstr "" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index b22687469c..32772646c9 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -121,6 +121,11 @@ msgstr "" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/es.po b/locale/es.po index 4e8df4195b..6ff7e8e174 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -121,6 +121,11 @@ msgstr "'%s' entero %d no esta dentro del rango %d..%d" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' entero 0x%x no cabe en la máscara 0x%x" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/fil.po b/locale/fil.po index f3f2b7e3b0..1e14df3ed1 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -122,6 +122,11 @@ msgstr "'%s' integer %d ay wala sa sakop ng %d..%d" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' integer 0x%x ay wala sa mask na sakop ng 0x%x" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/fr.po b/locale/fr.po index 098bd8d1fc..ff513edbf4 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -123,6 +123,11 @@ msgstr "'%s' l'entier %d n'est pas dans la gamme %d..%d" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' l'entier 0x%x ne correspond pas au masque 0x%x" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/it_IT.po b/locale/it_IT.po index 154dda932e..7037ad15e0 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -121,6 +121,11 @@ msgstr "intero '%s' non è nell'intervallo %d..%d" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "intero '%s' non è nell'intervallo %d..%d" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/ko.po b/locale/ko.po index 5fc91553b2..7d58863229 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -121,6 +121,11 @@ msgstr "" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/pl.po b/locale/pl.po index edfce95c62..37395aecd2 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -120,6 +120,11 @@ msgstr "'%s' liczba %d poza zakresem %d..%d" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' liczba 0x%x nie pasuje do maski 0x%x" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index a2b259fc46..f2fa266154 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -121,6 +121,11 @@ msgstr "" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index de78d35b5f..2e91bcafa4 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-04 09:44-0600\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -121,6 +121,11 @@ msgstr "'%s' zhěngshù %d bùzài fànwéi nèi %d.%d" msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' zhěngshù 0x%x bù shìyòng yú yǎn mǎ 0x%x" +#: py/proto.c +#, c-format +msgid "'%s' object does not support '%s'" +msgstr "" + #: py/obj.c #, c-format msgid "'%s' object does not support item assignment" From 17c8356b8c06ac160bf9fad6b6b4b8b1095d8dcd Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 22 Nov 2019 16:33:48 -0800 Subject: [PATCH 128/531] Add connection interval and debugging This also sets TinyUSB to master and to not include its submodules. It also fixes an old displayio example comment and retries gattc reads. --- .gitmodules | 3 +- ports/nrf/bluetooth/ble_drv.c | 14 +++- ports/nrf/common-hal/_bleio/Adapter.c | 9 +++ ports/nrf/common-hal/_bleio/Connection.c | 82 ++++++++++++++++++++---- ports/nrf/common-hal/_bleio/Connection.h | 2 + ports/nrf/common-hal/_bleio/Service.c | 7 ++ ports/nrf/common-hal/_bleio/__init__.c | 6 +- py/circuitpy_mpconfig.h | 2 + shared-bindings/_bleio/Connection.c | 46 ++++++++++++- shared-bindings/_bleio/Connection.h | 3 + shared-bindings/displayio/OnDiskBitmap.c | 2 +- supervisor/shared/bluetooth.c | 8 +-- 12 files changed, 160 insertions(+), 24 deletions(-) diff --git a/.gitmodules b/.gitmodules index bb62a5c39d..764456cd65 100644 --- a/.gitmodules +++ b/.gitmodules @@ -76,7 +76,8 @@ [submodule "lib/tinyusb"] path = lib/tinyusb url = https://github.com/hathach/tinyusb.git - branch = develop + branch = master + fetchRecurseSubmodules = false [submodule "tools/huffman"] path = tools/huffman url = https://github.com/tannewt/huffman.git diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index 16475e4b3b..896fa0fb09 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.c @@ -134,6 +134,9 @@ void SD_EVT_IRQHandler(void) { } ble_evt_t* event = (ble_evt_t *)m_ble_evt_buf; + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "BLE event: 0x%04x\n", event->header.evt_id); + #endif if (supervisor_bluetooth_hook(event)) { continue; @@ -145,8 +148,15 @@ void SD_EVT_IRQHandler(void) { done = it->func(event, it->param) || done; it = it->next; } - if (!done) { - //mp_printf(&mp_plat_print, "Unhandled ble event: 0x%04x\n", event->header.evt_id); + #if CIRCUITPY_VERBOSE_BLE + if (event->header.evt_id == BLE_GATTS_EVT_WRITE) { + ble_gatts_evt_write_t* write_evt = &event->evt.gatts_evt.params.write; + mp_printf(&mp_plat_print, "Write to: UUID(0x%04x) handle %x of length %d auth %x\n", write_evt->uuid.uuid, write_evt->handle, write_evt->len, write_evt->auth_required); } + if (!done) { + mp_printf(&mp_plat_print, "Unhandled ble event: 0x%04x\n", event->header.evt_id); + + } + #endif } } diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 85c159c6d5..00541c679a 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -180,9 +180,18 @@ STATIC bool adapter_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { connection->conn_handle = ble_evt->evt.gap_evt.conn_handle; connection->connection_obj = mp_const_none; connection->pair_status = PAIR_NOT_PAIRED; + ble_drv_add_event_handler_entry(&connection->handler_entry, connection_on_ble_evt, connection); self->connection_objs = NULL; + // Save the current connection parameters. + memcpy(&connection->conn_params, &connected->conn_params, sizeof(ble_gap_conn_params_t)); + + #if CIRCUITPY_VERBOSE_BLE + ble_gap_conn_params_t *cp = &connected->conn_params; + mp_printf(&mp_plat_print, "conn params: min_ci %d max_ci %d s_l %d sup_timeout %d\n", cp->min_conn_interval, cp->max_conn_interval, cp->slave_latency, cp->conn_sup_timeout); + #endif + // See if connection interval set by Central is out of range. // If so, negotiate our preferred range. ble_gap_conn_params_t conn_params; diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 0e1e187c2d..0720d5c472 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -70,8 +70,6 @@ static volatile bool m_discovery_successful; static bleio_service_obj_t *m_char_discovery_service; static bleio_characteristic_obj_t *m_desc_discovery_characteristic; -bool dump_events = false; - bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { bleio_connection_internal_t *self = (bleio_connection_internal_t*)self_in; @@ -84,16 +82,9 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { return false; } - // For debugging. - if (dump_events) { - mp_printf(&mp_plat_print, "Connection event: 0x%04x\n", ble_evt->header.evt_id); - } - switch (ble_evt->header.evt_id) { case BLE_GAP_EVT_DISCONNECTED: break; - case BLE_GAP_EVT_CONN_PARAM_UPDATE: // 0x12 - break; case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { ble_gap_phys_t const phys = { .rx_phys = BLE_GAP_PHY_AUTO, @@ -124,15 +115,61 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); break; + #if CIRCUITPY_VERBOSE_BLE + // Use read authorization to snoop on all reads when doing verbose debugging. + case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: { + + ble_gatts_evt_rw_authorize_request_t *request = + &ble_evt->evt.gatts_evt.params.authorize_request; + + mp_printf(&mp_plat_print, "Read %x offset %d ", request->request.read.handle, request->request.read.offset); + uint8_t value_bytes[22]; + ble_gatts_value_t value; + value.offset = request->request.read.offset; + value.len = 22; + value.p_value = value_bytes; + + sd_ble_gatts_value_get(self->conn_handle, request->request.read.handle, &value); + size_t len = value.len; + if (len > 22) { + len = 22; + } + for (uint8_t i = 0; i < len; i++) { + mp_printf(&mp_plat_print, " %02x", value_bytes[i]); + } + mp_printf(&mp_plat_print, "\n"); + ble_gatts_rw_authorize_reply_params_t reply; + reply.type = request->type; + reply.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS; + reply.params.read.update = false; + reply.params.read.offset = request->request.read.offset; + sd_ble_gatts_rw_authorize_reply(self->conn_handle, &reply); + break; + } + #endif + case BLE_GATTS_EVT_HVN_TX_COMPLETE: // Capture this for now. 0x55 break; - case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: { + self->conn_params_updating = true; ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request; sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params); break; } + case BLE_GAP_EVT_CONN_PARAM_UPDATE: { // 0x12 + ble_gap_evt_conn_param_update_t *result = + &ble_evt->evt.gap_evt.params.conn_param_update; + + #if CIRCUITPY_VERBOSE_BLE + ble_gap_conn_params_t *cp = &ble_evt->evt.gap_evt.params.conn_param_update.conn_params; + mp_printf(&mp_plat_print, "conn params updated: min_ci %d max_ci %d s_l %d sup_timeout %d\n", cp->min_conn_interval, cp->max_conn_interval, cp->slave_latency, cp->conn_sup_timeout); + #endif + + memcpy(&self->conn_params, &result->conn_params, sizeof(ble_gap_conn_params_t)); + self->conn_params_updating = false; + break; + } case BLE_GAP_EVT_SEC_PARAMS_REQUEST: { ble_gap_sec_keyset_t keyset = { .keys_own = { @@ -212,9 +249,9 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { default: // For debugging. - if (dump_events) { + #if CIRCUITPY_VERBOSE_BLE mp_printf(&mp_plat_print, "Unhandled connection event: 0x%04x\n", ble_evt->header.evt_id); - } + #endif return false; } @@ -262,6 +299,25 @@ void common_hal_bleio_connection_pair(bleio_connection_internal_t *self, bool bo check_sec_status(self->sec_status); } +mp_float_t common_hal_bleio_connection_get_connection_interval(bleio_connection_internal_t *self) { + while (self->conn_params_updating && !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } + return 1.25f * self->conn_params.min_conn_interval; +} + +void common_hal_bleio_connection_set_connection_interval(bleio_connection_internal_t *self, mp_float_t new_interval) { + self->conn_params_updating = true; + uint16_t interval = new_interval / 1.25f; + self->conn_params.min_conn_interval = interval; + self->conn_params.max_conn_interval = interval; + uint32_t status = NRF_ERROR_BUSY; + while (status == NRF_ERROR_BUSY) { + status = sd_ble_gap_conn_param_update(self->conn_handle, &self->conn_params); + RUN_BACKGROUND_TASKS; + } + check_nrf_error(status); +} // service_uuid may be NULL, to discover all services. STATIC bool discover_next_services(bleio_connection_internal_t* connection, uint16_t start_handle, ble_uuid_t *service_uuid) { @@ -600,6 +656,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t ble_drv_remove_event_handler(discovery_on_ble_evt, self); } + mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist) { discover_remote_services(self->connection, service_uuids_whitelist); // Convert to a tuple and then clear the list so the callee will take ownership. @@ -609,7 +666,6 @@ mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_conne return services_tuple; } - uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self) { if (self == NULL || self->connection == NULL) { return BLE_CONN_HANDLE_INVALID; diff --git a/ports/nrf/common-hal/_bleio/Connection.h b/ports/nrf/common-hal/_bleio/Connection.h index d5548de453..1474a0a6c0 100644 --- a/ports/nrf/common-hal/_bleio/Connection.h +++ b/ports/nrf/common-hal/_bleio/Connection.h @@ -63,6 +63,8 @@ typedef struct { uint8_t sec_status; // Internal security status. mp_obj_t connection_obj; ble_drv_evt_handler_entry_t handler_entry; + ble_gap_conn_params_t conn_params; + volatile bool conn_params_updating; } bleio_connection_internal_t; typedef struct { diff --git a/ports/nrf/common-hal/_bleio/Service.c b/ports/nrf/common-hal/_bleio/Service.c index 5918327c14..19288f7479 100644 --- a/ports/nrf/common-hal/_bleio/Service.c +++ b/ports/nrf/common-hal/_bleio/Service.c @@ -119,6 +119,10 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, bleio_attribute_gatts_set_security_mode(&char_attr_md.read_perm, characteristic->read_perm); bleio_attribute_gatts_set_security_mode(&char_attr_md.write_perm, characteristic->write_perm); + #if CIRCUITPY_VERBOSE_BLE + // Turn on read authorization so that we receive an event to print on every read. + char_attr_md.rd_auth = true; + #endif ble_gatts_attr_t char_attr = { .p_uuid = &char_uuid, @@ -137,6 +141,9 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, characteristic->cccd_handle = char_handles.cccd_handle; characteristic->sccd_handle = char_handles.sccd_handle; characteristic->handle = char_handles.value_handle; + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Char handle %x user %x cccd %x sccd %x\n", characteristic->handle, characteristic->user_desc_handle, characteristic->cccd_handle, characteristic->sccd_handle); + #endif mp_obj_list_append(self->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); } diff --git a/ports/nrf/common-hal/_bleio/__init__.c b/ports/nrf/common-hal/_bleio/__init__.c index 7ba3dc8c1f..4b2780dedc 100644 --- a/ports/nrf/common-hal/_bleio/__init__.c +++ b/ports/nrf/common-hal/_bleio/__init__.c @@ -187,7 +187,11 @@ size_t common_hal_bleio_gattc_read(uint16_t handle, uint16_t conn_handle, uint8_ read_info.done = false; ble_drv_add_event_handler(_on_gattc_read_rsp_evt, &read_info); - check_nrf_error(sd_ble_gattc_read(conn_handle, handle, 0)); + uint32_t nrf_error = NRF_ERROR_BUSY; + while (nrf_error == NRF_ERROR_BUSY) { + nrf_error = sd_ble_gattc_read(conn_handle, handle, 0); + } + check_nrf_error(nrf_error); while (!read_info.done) { RUN_BACKGROUND_TASKS; diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3e83d0c510..000674c4f4 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -666,4 +666,6 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000 #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" +#define CIRCUITPY_VERBOSE_BLE 0 + #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index da2fbff287..568a4ea214 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -195,6 +195,46 @@ const mp_obj_property_t bleio_connection_paired_obj = { (mp_obj_t)&mp_const_none_obj }, }; + +//| .. attribute:: connection_interval +//| +//| Time between transmissions in milliseconds. Will be multiple of 1.25ms. Lower numbers +//| increase speed and decrease latency but increase power consumption. +//| +//| When setting connection_interval, the peer may reject the new interval and +//| `connection_interval` will then remain the same. +//| +//| Apple has additional guidelines that dictate should be a multiple of 15ms except if HID is +//| available. When HID is available Apple devices may accept 11.25ms intervals. +//| +//| +STATIC mp_obj_t bleio_connection_get_connection_interval(mp_obj_t self_in) { + bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); + + ensure_connected(self); + return mp_obj_new_float(common_hal_bleio_connection_get_connection_interval(self->connection)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_connection_interval_obj, bleio_connection_get_connection_interval); + +STATIC mp_obj_t bleio_connection_set_connection_interval(mp_obj_t self_in, mp_obj_t interval_in) { + bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); + + mp_float_t interval = mp_obj_get_float(interval_in); + + ensure_connected(self); + common_hal_bleio_connection_set_connection_interval(self->connection, interval); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_connection_set_connection_interval_obj, bleio_connection_set_connection_interval); + +const mp_obj_property_t bleio_connection_connection_interval_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_connection_get_connection_interval_obj, + (mp_obj_t)&bleio_connection_set_connection_interval_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + STATIC const mp_rom_map_elem_t bleio_connection_locals_dict_table[] = { // Methods { MP_ROM_QSTR(MP_QSTR_pair), MP_ROM_PTR(&bleio_connection_pair_obj) }, @@ -202,8 +242,10 @@ STATIC const mp_rom_map_elem_t bleio_connection_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_discover_remote_services), MP_ROM_PTR(&bleio_connection_discover_remote_services_obj) }, // Properties - { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_connection_connected_obj) }, - { MP_ROM_QSTR(MP_QSTR_paired), MP_ROM_PTR(&bleio_connection_paired_obj) }, + { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_connection_connected_obj) }, + { MP_ROM_QSTR(MP_QSTR_paired), MP_ROM_PTR(&bleio_connection_paired_obj) }, + { MP_ROM_QSTR(MP_QSTR_connection_interval), MP_ROM_PTR(&bleio_connection_connection_interval_obj) }, + }; STATIC MP_DEFINE_CONST_DICT(bleio_connection_locals_dict, bleio_connection_locals_dict_table); diff --git a/shared-bindings/_bleio/Connection.h b/shared-bindings/_bleio/Connection.h index f7eee180f7..b0e26da5c8 100644 --- a/shared-bindings/_bleio/Connection.h +++ b/shared-bindings/_bleio/Connection.h @@ -40,4 +40,7 @@ extern bool common_hal_bleio_connection_get_connected(bleio_connection_obj_t *se extern bool common_hal_bleio_connection_get_paired(bleio_connection_obj_t *self); extern mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist); +mp_float_t common_hal_bleio_connection_get_connection_interval(bleio_connection_internal_t *self); +void common_hal_bleio_connection_set_connection_interval(bleio_connection_internal_t *self, mp_float_t new_interval); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CONNECTION_H diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index bf00ef855e..f7e2bf693f 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -59,7 +59,7 @@ //| //| with open("/sample.bmp", "rb") as f: //| odb = displayio.OnDiskBitmap(f) -//| face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter(), position=(0,0)) +//| face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter()) //| splash.append(face) //| # Wait for the image to load. //| board.DISPLAY.wait_for_frame() diff --git a/supervisor/shared/bluetooth.c b/supervisor/shared/bluetooth.c index 02258de742..cf41b3fd3c 100644 --- a/supervisor/shared/bluetooth.c +++ b/supervisor/shared/bluetooth.c @@ -52,7 +52,7 @@ bleio_uuid_obj_t supervisor_ble_length_uuid; bleio_characteristic_obj_t supervisor_ble_contents_characteristic; bleio_uuid_obj_t supervisor_ble_contents_uuid; const uint8_t circuitpython_base_uuid[16] = {0x6e, 0x68, 0x74, 0x79, 0x50, 0x74, 0x69, 0x75, 0x63, 0x72, 0x69, 0x43, 0x00, 0x00, 0xaf, 0xad }; -uint8_t circuitpython_advertising_data[] = { 0x02, 0x01, 0x06, 0x02, 0x0a, 0x00, 0x11, 0x07, 0x6e, 0x68, 0x74, 0x79, 0x50, 0x74, 0x69, 0x75, 0x63, 0x72, 0x69, 0x43, 0x00, 0x01, 0xaf, 0xad, 0x06, 0x08, 0x43, 0x49, 0x52, 0x43, 0x55 }; +uint8_t circuitpython_advertising_data[] = { 0x02, 0x01, 0x06, 0x02, 0x0a, 0x00, 0x11, 0x07, 0x6e, 0x68, 0x74, 0x79, 0x50, 0x74, 0x69, 0x75, 0x63, 0x72, 0x69, 0x43, 0x00, 0x01, 0xaf, 0xad, 0x06, 0x08, 0x43, 0x49, 0x52, 0x43, 0x55 }; uint8_t circuitpython_scan_response_data[15] = {0x0e, 0x09, 0x43, 0x49, 0x52, 0x43, 0x55, 0x49, 0x54, 0x50, 0x59, 0x00, 0x00, 0x00, 0x00}; mp_obj_list_t service_list; mp_obj_t service_list_items[1]; @@ -86,7 +86,7 @@ void supervisor_start_bluetooth(void) { characteristic_list.len = 0; characteristic_list.items = characteristic_list_items; mp_seq_clear(characteristic_list.items, 0, characteristic_list.alloc, sizeof(*characteristic_list.items)); - + _common_hal_bleio_service_construct(&supervisor_ble_service, &supervisor_ble_service_uuid, false /* is secondary */, &characteristic_list); // File length @@ -225,7 +225,7 @@ void supervisor_bluetooth_background(void) { uint16_t current_length = ((uint16_t*) current_command)[0]; if (current_length > 0 && current_length == current_offset) { uint16_t command = ((uint16_t *) current_command)[1]; - + if (command == 1) { uint16_t max_len = 20; //supervisor_ble_contents_characteristic.max_length; uint8_t buf[max_len]; @@ -274,7 +274,7 @@ void supervisor_bluetooth_background(void) { f_write(&active_file, &data, 1, &actual); } } - + f_lseek(&active_file, offset); uint8_t* data = (uint8_t *) (current_command + 4); UINT written; From e30dde0afc71bbd0e01bfa9454589ef2b553d75a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 5 Dec 2019 08:35:02 -0500 Subject: [PATCH 129/531] Make _bleio.Connection.disconnect() idempotent --- shared-bindings/_bleio/Connection.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index da2fbff287..e1e458c226 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -80,14 +80,12 @@ STATIC void ensure_connected(bleio_connection_obj_t *self) { //| //| .. method:: disconnect() //| -//| Disconnects from the remote peripheral. +//| Disconnects from the remote peripheral. Does nothing if already disconnected. //| STATIC mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); - ensure_connected(self); - + // common_hal_bleio_connection_disconnect() does nothing if already disconnected. common_hal_bleio_connection_disconnect(self->connection); - return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_disconnect_obj, bleio_connection_disconnect); From f3f2c7f5dea80b827242988f031baf249b9df302 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 5 Dec 2019 11:38:20 -0500 Subject: [PATCH 130/531] change default phase for SPI --- ports/stm32f4/common-hal/busio/SPI.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index 1142657b7f..32089887f9 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -165,7 +165,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, self->baudrate = (get_busclock(SPIx)/16); self->prescaler = 16; self->polarity = 0; - self->phase = 1; + self->phase = 0; self->bits = 8; claim_pin(sck); From ab74f45bfbed78fd752e3ed3a12c01fa910ad672 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 5 Dec 2019 11:44:21 -0500 Subject: [PATCH 131/531] Define polarity and phase in Fourwire --- shared-module/displayio/FourWire.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-module/displayio/FourWire.c b/shared-module/displayio/FourWire.c index 92d4507dde..256c29642d 100644 --- a/shared-module/displayio/FourWire.c +++ b/shared-module/displayio/FourWire.c @@ -49,8 +49,8 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self, gc_never_free(self->bus); self->frequency = baudrate; - self->polarity = common_hal_busio_spi_get_polarity(spi); - self->phase = common_hal_busio_spi_get_phase(spi); + self->polarity = 0; + self->phase = 0; common_hal_digitalio_digitalinout_construct(&self->command, command); common_hal_digitalio_digitalinout_switch_to_output(&self->command, true, DRIVE_MODE_PUSH_PULL); From c53496a55eccb1c7382c41817504ce8f949a9b77 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 5 Dec 2019 12:45:09 -0500 Subject: [PATCH 132/531] remove redundant NOPs --- ports/stm32f4/common-hal/neopixel_write/__init__.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ports/stm32f4/common-hal/neopixel_write/__init__.c b/ports/stm32f4/common-hal/neopixel_write/__init__.c index 23fe7870f5..6740a0d348 100644 --- a/ports/stm32f4/common-hal/neopixel_write/__init__.c +++ b/ports/stm32f4/common-hal/neopixel_write/__init__.c @@ -76,13 +76,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout cyc = (pix & mask) ? t1 : t0; start = DWT->CYCCNT; LL_GPIO_SetOutputPin(p_port, p_mask); - while((DWT->CYCCNT - start) < cyc) { - __asm__ __volatile__("nop"); - } + while((DWT->CYCCNT - start) < cyc); LL_GPIO_ResetOutputPin(p_port, p_mask); - while((DWT->CYCCNT - start) < interval) { - __asm__ __volatile__("nop"); - } + while((DWT->CYCCNT - start) < interval); if(!(mask >>= 1)) { if(p >= end) break; pix = *p++; From 49a547eed881408d77f750c5f0328e2d93770369 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 5 Dec 2019 13:06:06 -0600 Subject: [PATCH 133/531] proto: Use %q format-string shortcut --- py/proto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/proto.c b/py/proto.c index 030b62674e..e5053130b8 100644 --- a/py/proto.c +++ b/py/proto.c @@ -45,6 +45,6 @@ const void *mp_proto_get_or_throw(uint16_t name, mp_const_obj_t obj) { if (proto) { return proto; } - mp_raise_TypeError_varg(translate("'%s' object does not support '%s'"), - mp_obj_get_type_str(obj), qstr_str(name)); + mp_raise_TypeError_varg(translate("'%s' object does not support '%q'"), + mp_obj_get_type_str(obj), name); } From 60f489d36a364dfc4feb55af4d139987302c0242 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 5 Dec 2019 13:08:32 -0600 Subject: [PATCH 134/531] audiocore: restore the prototypes of audiosample_xxx functions --- shared-module/audiocore/__init__.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shared-module/audiocore/__init__.h b/shared-module/audiocore/__init__.h index 4b306f8ba0..9012c0d8b9 100644 --- a/shared-module/audiocore/__init__.h +++ b/shared-module/audiocore/__init__.h @@ -61,15 +61,15 @@ typedef struct _audiosample_p_t { audiosample_get_buffer_structure_fun get_buffer_structure; } audiosample_p_t; -uint32_t audiosample_sample_rate(void* sample_obj); -uint8_t audiosample_bits_per_sample(void* sample_obj); -uint8_t audiosample_channel_count(void* sample_obj); -void audiosample_reset_buffer(void* sample_obj, bool single_channel, uint8_t audio_channel); -audioio_get_buffer_result_t audiosample_get_buffer(void* sample_obj, +uint32_t audiosample_sample_rate(mp_obj_t sample_obj); +uint8_t audiosample_bits_per_sample(mp_obj_t sample_obj); +uint8_t audiosample_channel_count(mp_obj_t sample_obj); +void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel); +audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t channel, uint8_t** buffer, uint32_t* buffer_length); -void audiosample_get_buffer_structure(void* sample_obj, bool single_channel, +void audiosample_get_buffer_structure(mp_obj_t sample_obj, bool single_channel, bool* single_buffer, bool* samples_signed, uint32_t* max_buffer_length, uint8_t* spacing); From 2dcfc9d411fe06f190c6af59c44be3a2b29a63eb Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 6 Dec 2019 11:41:38 -0500 Subject: [PATCH 135/531] USB fixes and cleanup --- .../boards/stm32f411ce_blackpill/mpconfigboard.h | 7 +++++++ .../boards/stm32f411ce_blackpill/mpconfigboard.mk | 9 +++++++-- ports/stm32f4/boards/stm32f411ce_blackpill/pins.c | 12 +++++++----- ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c | 1 - ports/stm32f4/supervisor/usb.c | 7 ++++++- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index 8a482ce7dc..4b46b1056b 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,6 +33,13 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 +#define BOARD_USB_VBUS_BOOST + +// On-board flash +// #define SPI_FLASH_MOSI_PIN (&pin_PA07) +// #define SPI_FLASH_MISO_PIN (&pin_PA06) +// #define SPI_FLASH_SCK_PIN (&pin_PA05) +// #define SPI_FLASH_CS_PIN (&pin_PA04) #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk index 41c283a780..a9f12cbc95 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk @@ -1,8 +1,13 @@ USB_VID = 0x239A USB_PID = 0x806A -USB_PRODUCT = "stm32f411ce-blackpill" +USB_PRODUCT = "stm32f411ce blackpill" USB_MANUFACTURER = "Unknown" -USB_DEVICES = "CDC" +USB_DEVICES = "CDC,MSC" + +# SPI_FLASH_FILESYSTEM = 1 +# EXTERNAL_FLASH_DEVICE_COUNT = 1 +# EXTERNAL_FLASH_DEVICES = xxxxxx #See supervisor/shared/external_flash/devices.h for options +# LONGINT_IMPL = MPZ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c index 0846cee673..5797a9762b 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c @@ -6,10 +6,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_B14), MP_ROM_PTR(&pin_PB14) }, { MP_ROM_QSTR(MP_QSTR_B15), MP_ROM_PTR(&pin_PB15) }, { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) }, //USB (shouldn't be used) + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, //USB (shouldn't be used) + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PA11) }, //USB (shouldn't be used) + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_PA12) }, //USB (shouldn't be used) { MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_B3), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_B4), MP_ROM_PTR(&pin_PB04) }, @@ -26,7 +26,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, @@ -34,5 +34,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_C15), MP_ROM_PTR(&pin_PC15) }, { MP_ROM_QSTR(MP_QSTR_C14), MP_ROM_PTR(&pin_PC14) }, { MP_ROM_QSTR(MP_QSTR_C13), MP_ROM_PTR(&pin_PC13) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PC13) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c index 2b0e2b2888..651aea2691 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c @@ -38,7 +38,6 @@ void stm32f4_peripherals_gpio_init(void) { __HAL_RCC_GPIOD_CLK_ENABLE(); //Never reset pins - never_reset_pin_number(2,13); //PC13 anti tamp never_reset_pin_number(2,14); //PC14 OSC32_IN never_reset_pin_number(2,15); //PC15 OSC32_OUT never_reset_pin_number(0,13); //PA13 SWDIO diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index f327050f58..39538daabf 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -31,6 +31,7 @@ #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" #include "common-hal/microcontroller/Pin.h" @@ -58,7 +59,11 @@ void init_usb_hardware(void) { /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; +#ifdef BOARD_USB_VBUS_BOOST + GPIO_InitStruct.Pull = GPIO_PULLUP; //GPIO_NOPULL; +#else + GPIO_InitStruct.Pull = GPIO_NOPULL; //GPIO_NOPULL; +#endif HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 9); From f6d0e912c94e11f43f5c9f37c8dddbda824a20f8 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 6 Dec 2019 11:52:40 -0500 Subject: [PATCH 136/531] remove old 401 files --- .../peripherals/stm32f4/stm32f401xe/clocks.c | 61 ------- .../peripherals/stm32f4/stm32f401xe/gpio.c | 54 ------ .../peripherals/stm32f4/stm32f401xe/periph.c | 172 ------------------ .../peripherals/stm32f4/stm32f401xe/periph.h | 57 ------ .../peripherals/stm32f4/stm32f401xe/pins.c | 123 ------------- .../peripherals/stm32f4/stm32f401xe/pins.h | 121 ------------ 6 files changed, 588 deletions(-) delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c delete mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c deleted file mode 100644 index 883c252d51..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c +++ /dev/null @@ -1,61 +0,0 @@ - -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" - -void stm32f4_peripherals_clocks_init(void) { - //System clock init - RCC_ClkInitTypeDef RCC_ClkInitStruct; - RCC_OscInitTypeDef RCC_OscInitStruct; - - /* Enable Power Control clock */ - __HAL_RCC_PWR_CLK_ENABLE(); - - /* The voltage scaling allows optimizing the power consumption when the device is - clocked below the maximum system frequency, to update the voltage scaling value - regarding system frequency refer to product datasheet. */ - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); - - /* Enable HSE Oscillator and activate PLL with HSE as source */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 8; - RCC_OscInitStruct.PLL.PLLN = 336; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 7; - HAL_RCC_OscConfig(&RCC_OscInitStruct); - - /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 - clocks dividers */ - RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); -} diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c deleted file mode 100644 index 45dc8fc6fa..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" -#include "stm32f4/gpio.h" -#include "common-hal/microcontroller/Pin.h" - -void stm32f4_peripherals_gpio_init(void) { - //Enable all GPIO for now - GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - - //Never reset pins - never_reset_pin_number(2,13); //PC13 anti tamp - never_reset_pin_number(2,14); //PC14 OSC32_IN - never_reset_pin_number(2,15); //PC15 OSC32_OUT - never_reset_pin_number(0,13); //PA13 SWDIO - never_reset_pin_number(0,14); //PA14 SWCLK -} - -//LEDs are inverted on F411 DISCO -void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { -} - - diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c deleted file mode 100644 index 859e9a1adb..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c +++ /dev/null @@ -1,172 +0,0 @@ - /* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" -#include "py/mphal.h" -#include "stm32f4/pins.h" -#include "stm32f4/periph.h" - -// I2C - -I2C_TypeDef * mcu_i2c_banks[3] = {I2C1, I2C2, I2C3}; - -const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5] = { - I2C_SDA(1, 4, &pin_PB07), - I2C_SDA(1, 4, &pin_PB09), - I2C_SDA(2, 9, &pin_PB03), - I2C_SDA(3, 4, &pin_PC09), - I2C_SDA(3, 9, &pin_PB04), -}; - -const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { - I2C_SCL(1, 4, &pin_PB06), - I2C_SCL(1, 4, &pin_PB08), - I2C_SCL(2, 4, &pin_PB10), - I2C_SCL(3, 4, &pin_PA08) -}; - -// SPI - -SPI_TypeDef * mcu_spi_banks[4] = {SPI1, SPI2, SPI3, SPI4}; - -const mcu_spi_sck_obj_t mcu_spi_sck_list[9] = { - SPI(1, 5, &pin_PA05), - SPI(1, 5, &pin_PB03), - SPI(2, 5, &pin_PB10), - SPI(2, 5, &pin_PB13), - SPI(2, 5, &pin_PD03), - SPI(3, 6, &pin_PB03), - SPI(3, 6, &pin_PC10), - SPI(4, 5, &pin_PE02), - SPI(4, 5, &pin_PE12), -}; - -const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9] = { - SPI(1, 5, &pin_PA07), - SPI(1, 5, &pin_PB05), - SPI(2, 5, &pin_PB15), - SPI(2, 5, &pin_PC03), - SPI(3, 6, &pin_PB05), - SPI(3, 6, &pin_PC12), - SPI(3, 5, &pin_PD06), - SPI(4, 5, &pin_PE06), - SPI(4, 5, &pin_PE14), -}; - -const mcu_spi_miso_obj_t mcu_spi_miso_list[8] = { - SPI(1, 5, &pin_PA06), - SPI(1, 5, &pin_PB04), - SPI(2, 5, &pin_PB14), - SPI(2, 5, &pin_PC02), - SPI(3, 6, &pin_PB04), - SPI(3, 6, &pin_PC11), - SPI(4, 5, &pin_PE05), - SPI(4, 5, &pin_PE13), -}; - -const mcu_spi_nss_obj_t mcu_spi_nss_list[9] = { - SPI(1, 5, &pin_PA04), - SPI(1, 5, &pin_PA15), - SPI(2, 5, &pin_PB09), - SPI(2, 5, &pin_PB12), - SPI(3, 6, &pin_PA04), - SPI(3, 6, &pin_PA15), - SPI(4, 6, &pin_PB12), - SPI(4, 5, &pin_PE04), - SPI(4, 5, &pin_PE11), -}; - -USART_TypeDef * mcu_uart_banks[MAX_UART] = {USART1, USART2, NULL, NULL, NULL, USART6}; -bool mcu_uart_has_usart[MAX_UART] = {true, true, false, false, false, true}; - -const mcu_uart_tx_obj_t mcu_uart_tx_list[6] = { - UART(2, 7, &pin_PA02), - UART(1, 7, &pin_PA09), - UART(6, 8, &pin_PA11), - UART(1, 7, &pin_PB06), - UART(6, 8, &pin_PC06), - UART(2, 7, &pin_PD05), -}; - -const mcu_uart_rx_obj_t mcu_uart_rx_list[6] = { - UART(2, 7, &pin_PA03), - UART(1, 7, &pin_PA10), - UART(6, 8, &pin_PA12), - UART(1, 7, &pin_PB07), - UART(6, 8, &pin_PC07), - UART(2, 7, &pin_PD06), -}; - -//Timers -//TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins -TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10, - TIM11, NULL, NULL, NULL}; - -const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { - TIM(2,1,1,&pin_PA00), - TIM(5,2,1,&pin_PA00), - TIM(2,1,2,&pin_PA01), - TIM(5,2,2,&pin_PA01), - TIM(2,1,3,&pin_PA02), - TIM(5,2,3,&pin_PA02), - TIM(2,1,4,&pin_PA03), - TIM(5,2,4,&pin_PA03), - TIM(9,3,1,&pin_PA02), - TIM(9,3,2,&pin_PA03), - TIM(3,2,1,&pin_PA06), - TIM(3,2,2,&pin_PA07), - TIM(1,1,1,&pin_PA08), - TIM(1,1,2,&pin_PA09), - TIM(1,1,3,&pin_PA10), - TIM(1,1,4,&pin_PA11), - TIM(2,1,1,&pin_PA15), - TIM(3,2,3,&pin_PB00), - TIM(3,2,4,&pin_PB01), - TIM(2,1,2,&pin_PB03), - TIM(3,2,1,&pin_PB04), - TIM(3,2,2,&pin_PB05), - TIM(4,2,1,&pin_PB06), - TIM(4,2,2,&pin_PB07), - TIM(4,2,3,&pin_PB08), - TIM(10,2,1,&pin_PB08), - TIM(4,2,4,&pin_PB09), - TIM(11,2,1,&pin_PB09), - TIM(2,1,3,&pin_PB10), - TIM(3,2,1,&pin_PC06), - TIM(3,2,2,&pin_PC07), - TIM(3,2,3,&pin_PC08), - TIM(3,2,4,&pin_PC09), - TIM(4,2,1,&pin_PD12), - TIM(4,2,2,&pin_PD13), - TIM(4,2,3,&pin_PD14), - TIM(4,2,4,&pin_PD15), - TIM(9,3,1,&pin_PE05), - TIM(9,3,2,&pin_PE06), - TIM(1,1,1,&pin_PE09), - TIM(1,1,2,&pin_PE11), - TIM(1,1,3,&pin_PE13), - TIM(1,1,4,&pin_PE14), -}; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h deleted file mode 100644 index 7d3f4dca22..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H -#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H - -//I2C -extern I2C_TypeDef * mcu_i2c_banks[3]; - -extern const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5]; -extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; - -//SPI -extern SPI_TypeDef * mcu_spi_banks[4]; - -extern const mcu_spi_sck_obj_t mcu_spi_sck_list[9]; -extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9]; -extern const mcu_spi_miso_obj_t mcu_spi_miso_list[8]; -extern const mcu_spi_nss_obj_t mcu_spi_nss_list[9]; - -//UART -extern USART_TypeDef * mcu_uart_banks[MAX_UART]; -extern bool mcu_uart_has_usart[MAX_UART]; - -extern const mcu_uart_tx_obj_t mcu_uart_tx_list[6]; -extern const mcu_uart_rx_obj_t mcu_uart_rx_list[6]; - -//Timers -#define TIM_BANK_ARRAY_LEN 14 -#define TIM_PIN_ARRAY_LEN 44 -TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN]; -const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; - -#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c deleted file mode 100644 index 7e88c3dcba..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c +++ /dev/null @@ -1,123 +0,0 @@ - /* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" -#include "py/mphal.h" -#include "stm32f4/pins.h" - -const mcu_pin_obj_t pin_PE02 = PIN(4, 2, NO_ADC); -const mcu_pin_obj_t pin_PE03 = PIN(4, 3, NO_ADC); -const mcu_pin_obj_t pin_PE04 = PIN(4, 4, NO_ADC); -const mcu_pin_obj_t pin_PE05 = PIN(4, 5, NO_ADC); -const mcu_pin_obj_t pin_PE06 = PIN(4, 6, NO_ADC); - -const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); //anti-tamp -const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); //OSC32_IN -const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); //OSC32_OUT - -const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_1,10)); -const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_1,11)); -const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_1,12)); -const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_1,13)); - -const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1,0)); -const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1,1)); -const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1,2)); -const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1,3)); -const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1,4)); -const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1,5)); -const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1,6)); -const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1,7)); - -const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_1,14)); -const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_1,15)); - -const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1,8)); -const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1,9)); -const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); - -const mcu_pin_obj_t pin_PE07 = PIN(4, 7, NO_ADC); -const mcu_pin_obj_t pin_PE08 = PIN(4, 8, NO_ADC); -const mcu_pin_obj_t pin_PE09 = PIN(4, 9, NO_ADC); -const mcu_pin_obj_t pin_PE10 = PIN(4, 10, NO_ADC); -const mcu_pin_obj_t pin_PE11 = PIN(4, 11, NO_ADC); -const mcu_pin_obj_t pin_PE12 = PIN(4, 12, NO_ADC); -const mcu_pin_obj_t pin_PE13 = PIN(4, 13, NO_ADC); -const mcu_pin_obj_t pin_PE14 = PIN(4, 14, NO_ADC); -const mcu_pin_obj_t pin_PE15 = PIN(4, 15, NO_ADC); - -const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); -const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); -const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); -const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); -const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); - -const mcu_pin_obj_t pin_PD08 = PIN(3, 8, NO_ADC); -const mcu_pin_obj_t pin_PD09 = PIN(3, 9, NO_ADC); -const mcu_pin_obj_t pin_PD10 = PIN(3, 10, NO_ADC); -const mcu_pin_obj_t pin_PD11 = PIN(3, 11, NO_ADC); -const mcu_pin_obj_t pin_PD12 = PIN(3, 12, NO_ADC); -const mcu_pin_obj_t pin_PD13 = PIN(3, 13, NO_ADC); -const mcu_pin_obj_t pin_PD14 = PIN(3, 14, NO_ADC); -const mcu_pin_obj_t pin_PD15 = PIN(3, 15, NO_ADC); - -const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); -const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); -const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); -const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); - -const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); -const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); -const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); -const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); -const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); -const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); //SWDIO -const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); //SWCLK -const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); //JTDI - -const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); -const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); -const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); - -const mcu_pin_obj_t pin_PD00 = PIN(3, 0, NO_ADC); -const mcu_pin_obj_t pin_PD01 = PIN(3, 1, NO_ADC); -const mcu_pin_obj_t pin_PD02 = PIN(3, 2, NO_ADC); -const mcu_pin_obj_t pin_PD03 = PIN(3, 3, NO_ADC); -const mcu_pin_obj_t pin_PD04 = PIN(3, 4, NO_ADC); -const mcu_pin_obj_t pin_PD05 = PIN(3, 5, NO_ADC); -const mcu_pin_obj_t pin_PD06 = PIN(3, 6, NO_ADC); -const mcu_pin_obj_t pin_PD07 = PIN(3, 7, NO_ADC); - -const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); -const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); -const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); -const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); -const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); -const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); -const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); - -const mcu_pin_obj_t pin_PE00 = PIN(4, 0, NO_ADC); -const mcu_pin_obj_t pin_PE01 = PIN(4, 1, NO_ADC); \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h deleted file mode 100644 index 37d3a5cf11..0000000000 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H -#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H - -//Pins in datasheet order: DocID026289 Rev 7 page 38. LQFP100 only -//pg 38 -extern const mcu_pin_obj_t pin_PE02; -extern const mcu_pin_obj_t pin_PE03; -extern const mcu_pin_obj_t pin_PE04; -extern const mcu_pin_obj_t pin_PE05; -//pg 39 -extern const mcu_pin_obj_t pin_PE06; -extern const mcu_pin_obj_t pin_PC13; -extern const mcu_pin_obj_t pin_PC14; -extern const mcu_pin_obj_t pin_PC15; -extern const mcu_pin_obj_t pin_PC00; -extern const mcu_pin_obj_t pin_PC01; -extern const mcu_pin_obj_t pin_PC02; -extern const mcu_pin_obj_t pin_PC03; -//pg 40 -extern const mcu_pin_obj_t pin_PA00; -extern const mcu_pin_obj_t pin_PA01; -extern const mcu_pin_obj_t pin_PA02; -extern const mcu_pin_obj_t pin_PA03; -extern const mcu_pin_obj_t pin_PA04; -extern const mcu_pin_obj_t pin_PA05; -extern const mcu_pin_obj_t pin_PA06; -extern const mcu_pin_obj_t pin_PA07; -//pg 41 -extern const mcu_pin_obj_t pin_PC04; -extern const mcu_pin_obj_t pin_PC05; -extern const mcu_pin_obj_t pin_PB00; -extern const mcu_pin_obj_t pin_PB01; -extern const mcu_pin_obj_t pin_PB02; -extern const mcu_pin_obj_t pin_PE07; -extern const mcu_pin_obj_t pin_PE08; -extern const mcu_pin_obj_t pin_PE09; -extern const mcu_pin_obj_t pin_PE10; -extern const mcu_pin_obj_t pin_PE11; -extern const mcu_pin_obj_t pin_PE12; -extern const mcu_pin_obj_t pin_PE13; -extern const mcu_pin_obj_t pin_PE14; -extern const mcu_pin_obj_t pin_PE15; -//pg 42 -extern const mcu_pin_obj_t pin_PB10; -extern const mcu_pin_obj_t pin_PB12; -extern const mcu_pin_obj_t pin_PB13; -extern const mcu_pin_obj_t pin_PB14; -extern const mcu_pin_obj_t pin_PB15; -extern const mcu_pin_obj_t pin_PD08; -extern const mcu_pin_obj_t pin_PD09; -extern const mcu_pin_obj_t pin_PD10; -extern const mcu_pin_obj_t pin_PD11; -extern const mcu_pin_obj_t pin_PD12; -//pg 43 -extern const mcu_pin_obj_t pin_PD13; -extern const mcu_pin_obj_t pin_PD14; -extern const mcu_pin_obj_t pin_PD15; -extern const mcu_pin_obj_t pin_PC06; -extern const mcu_pin_obj_t pin_PC07; -extern const mcu_pin_obj_t pin_PC08; -extern const mcu_pin_obj_t pin_PC09; -extern const mcu_pin_obj_t pin_PA08; -extern const mcu_pin_obj_t pin_PA09; -//pg 44 -extern const mcu_pin_obj_t pin_PA10; -extern const mcu_pin_obj_t pin_PA11; -extern const mcu_pin_obj_t pin_PA12; -extern const mcu_pin_obj_t pin_PA13; -extern const mcu_pin_obj_t pin_PA14; -extern const mcu_pin_obj_t pin_PA15; -extern const mcu_pin_obj_t pin_PC10; -extern const mcu_pin_obj_t pin_PC11; -extern const mcu_pin_obj_t pin_PC12; -//pg 45 -extern const mcu_pin_obj_t pin_PD00; -extern const mcu_pin_obj_t pin_PD01; -extern const mcu_pin_obj_t pin_PD02; -extern const mcu_pin_obj_t pin_PD03; -extern const mcu_pin_obj_t pin_PD04; -extern const mcu_pin_obj_t pin_PD05; -extern const mcu_pin_obj_t pin_PD06; -extern const mcu_pin_obj_t pin_PD07; -extern const mcu_pin_obj_t pin_PB03; -extern const mcu_pin_obj_t pin_PB04; -extern const mcu_pin_obj_t pin_PB05; -extern const mcu_pin_obj_t pin_PB06; -//pg 46 -extern const mcu_pin_obj_t pin_PB07; -extern const mcu_pin_obj_t pin_PB08; -extern const mcu_pin_obj_t pin_PB09; -extern const mcu_pin_obj_t pin_PE00; -extern const mcu_pin_obj_t pin_PE01; - - -#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H From 0ae08e275d4ba0388a3fb8145e4858c637d58a31 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 6 Dec 2019 11:54:01 -0500 Subject: [PATCH 137/531] remove pyb nano folder --- .github/workflows/build.yml | 1 - ports/stm32f4/boards/pyb_nano_v2/board.c | 39 -- .../boards/pyb_nano_v2/mpconfigboard.h | 47 -- .../boards/pyb_nano_v2/mpconfigboard.mk | 19 - ports/stm32f4/boards/pyb_nano_v2/pins.c | 59 --- .../boards/pyb_nano_v2/stm32f4xx_hal_conf.h | 440 ------------------ 6 files changed, 605 deletions(-) delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/board.c delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/pins.c delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d7db57d0e..a395d07e0f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,7 +129,6 @@ jobs: - "pewpew10" - "pewpew_m4" - "pirkey_m0" - - "pyb_nano_v2" - "pybadge" - "pybadge_airlift" - "pyboard_v11" diff --git a/ports/stm32f4/boards/pyb_nano_v2/board.c b/ports/stm32f4/boards/pyb_nano_v2/board.c deleted file mode 100644 index 82b0c506ed..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/board.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "boards/board.h" -#include "mpconfigboard.h" - -void board_init(void) { -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { - -} diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h deleted file mode 100644 index 7980ca93d6..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "PYB LR Nano V2" -#define MICROPY_HW_MCU_NAME "STM32F411CE" - -#define FLASH_SIZE (0x80000) -#define FLASH_PAGE_SIZE (0x4000) - -#define BOARD_OSC_DIV 8 - -// On-board flash -#define SPI_FLASH_MOSI_PIN (&pin_PB15) -#define SPI_FLASH_MISO_PIN (&pin_PB14) -#define SPI_FLASH_SCK_PIN (&pin_PB13) -#define SPI_FLASH_CS_PIN (&pin_PB12) - -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk deleted file mode 100644 index d46ee0b08a..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk +++ /dev/null @@ -1,19 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x8068 -USB_PRODUCT = "PYB LR Nano V2" -USB_MANUFACTURER = "MicroPython Chinese Community" -USB_DEVICES = "CDC,MSC" - -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = W25Q64JV_IQ -LONGINT_IMPL = MPZ - -MCU_SERIES = m4 -MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f411xe -MCU_PACKAGE = 48 -CMSIS_MCU = STM32F411xE -LD_FILE = boards/STM32F411VETx_FLASH.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/pyb_nano_v2/pins.c b/ports/stm32f4/boards/pyb_nano_v2/pins.c deleted file mode 100644 index e10124f6af..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/pins.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_Y10), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_Y9), MP_ROM_PTR(&pin_PA13) }, - { MP_ROM_QSTR(MP_QSTR_Y8), MP_ROM_PTR(&pin_PA14) }, - { MP_ROM_QSTR(MP_QSTR_Y7), MP_ROM_PTR(&pin_PA15) }, - { MP_ROM_QSTR(MP_QSTR_Y6), MP_ROM_PTR(&pin_PB03) }, - { MP_ROM_QSTR(MP_QSTR_Y5), MP_ROM_PTR(&pin_PB04) }, - { MP_ROM_QSTR(MP_QSTR_Y4), MP_ROM_PTR(&pin_PB05) }, - { MP_ROM_QSTR(MP_QSTR_Y3), MP_ROM_PTR(&pin_PB06) }, - { MP_ROM_QSTR(MP_QSTR_Y2), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_Y1), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_Y0), MP_ROM_PTR(&pin_PB09) }, - - { MP_ROM_QSTR(MP_QSTR_X15), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_X14), MP_ROM_PTR(&pin_PB15) }, - { MP_ROM_QSTR(MP_QSTR_X13), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_X12), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_X11), MP_ROM_PTR(&pin_PB12) }, - { MP_ROM_QSTR(MP_QSTR_X10), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_X9), MP_ROM_PTR(&pin_PB01) }, - { MP_ROM_QSTR(MP_QSTR_X8), MP_ROM_PTR(&pin_PB00) }, - { MP_ROM_QSTR(MP_QSTR_X7), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_X6), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_X5), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_X4), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_X3), MP_ROM_PTR(&pin_PA03) }, - { MP_ROM_QSTR(MP_QSTR_X2), MP_ROM_PTR(&pin_PA02) }, - { MP_ROM_QSTR(MP_QSTR_X1), MP_ROM_PTR(&pin_PA01) }, - { MP_ROM_QSTR(MP_QSTR_X0), MP_ROM_PTR(&pin_PA00) }, - - { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PB03) }, - { MP_ROM_QSTR(MP_QSTR_SCL2), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_SDA3), MP_ROM_PTR(&pin_PB04) }, - { MP_ROM_QSTR(MP_QSTR_SCL3), MP_ROM_PTR(&pin_PA08) }, - - { MP_ROM_QSTR(MP_QSTR_SCK1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_MISO1), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_MOSI1), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_SCK2), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_MISO2), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI2), MP_ROM_PTR(&pin_PB15) }, - - { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PB06) }, - { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA02) }, - { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA03) }, - - { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PA00) }, - { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PA01) }, - { MP_ROM_QSTR(MP_QSTR_LED_YELLOW), MP_ROM_PTR(&pin_PA02) }, - { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_PA03) }, - - { MP_ROM_QSTR(MP_QSTR_SW), MP_ROM_PTR(&pin_PC13) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h deleted file mode 100644 index ab04df3182..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h +++ /dev/null @@ -1,440 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf_template.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32f4xx_hal_conf.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_H -#define __STM32F4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED - -#define HAL_ADC_MODULE_ENABLED -/* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CRC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ -#define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ -#define HAL_I2C_MODULE_ENABLED -#define HAL_I2S_MODULE_ENABLED -/* #define HAL_IWDG_MODULE_ENABLED */ -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_RNG_MODULE_ENABLED */ -/* #define HAL_RTC_MODULE_ENABLED */ -/* #define HAL_SAI_MODULE_ENABLED */ -/* #define HAL_SD_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ -#define HAL_PCD_MODULE_ENABLED -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_EXTI_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)40000) -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature. */ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) - -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver -* Activated: CRC code is present inside driver -* Deactivated: CRC code cleaned from driver -*/ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED - #include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED - #include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED - #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED - #include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED - #include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED - #include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED - #include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED - #include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED - #include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 2a01f0806ec6e67d6b35f162031464f69108f2ed Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 6 Dec 2019 11:58:26 -0500 Subject: [PATCH 138/531] text fixes --- ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk | 2 +- ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h | 1 - ports/stm32f4/peripherals/stm32f4/periph.h | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk index a9f12cbc95..d4f0f9577f 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk @@ -19,4 +19,4 @@ MCU_PACKAGE = 48 CMSIS_MCU = STM32F411xE LD_FILE = boards/STM32F411VETx_FLASH.ld TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 \ No newline at end of file +TEXT1_ADDR = 0x08020000 diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h index 0c6f537f87..130e6a1db0 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h @@ -33,7 +33,6 @@ #define FLASH_PAGE_SIZE (0x4000) //16K #define BOARD_OSC_DIV 8 - #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) diff --git a/ports/stm32f4/peripherals/stm32f4/periph.h b/ports/stm32f4/peripherals/stm32f4/periph.h index ac98b89320..0d1374e850 100644 --- a/ports/stm32f4/peripherals/stm32f4/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/periph.h @@ -140,12 +140,6 @@ typedef struct { //Starter Lines -#ifdef STM32F401xE -#define HAS_DAC 0 -#define HAS_TRNG 0 -#include "stm32f401xe/periph.h" -#endif - #ifdef STM32F411xE #define HAS_DAC 0 #define HAS_TRNG 0 From 6c8503b3c6665e2504d336e1c89fdf9a0d6fe92c Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 6 Dec 2019 12:17:38 -0500 Subject: [PATCH 139/531] VBUS fix actually doesn't work --- ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h | 1 - ports/stm32f4/supervisor/usb.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index 4b46b1056b..a438b5baa6 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,7 +33,6 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 -#define BOARD_USB_VBUS_BOOST // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 39538daabf..95db0aafc2 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -31,7 +31,6 @@ #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" #include "stm32f4xx_hal.h" -#include "py/mpconfig.h" #include "common-hal/microcontroller/Pin.h" @@ -59,11 +58,7 @@ void init_usb_hardware(void) { /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; -#ifdef BOARD_USB_VBUS_BOOST - GPIO_InitStruct.Pull = GPIO_PULLUP; //GPIO_NOPULL; -#else - GPIO_InitStruct.Pull = GPIO_NOPULL; //GPIO_NOPULL; -#endif + GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 9); From e8a54eacaabb0bf16be79c3f993b660a6c069122 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 6 Dec 2019 11:13:22 -0800 Subject: [PATCH 140/531] Comment supervisor ble data arrays. --- supervisor/shared/bluetooth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/supervisor/shared/bluetooth.c b/supervisor/shared/bluetooth.c index cf41b3fd3c..18caa2eb4a 100644 --- a/supervisor/shared/bluetooth.c +++ b/supervisor/shared/bluetooth.c @@ -51,8 +51,12 @@ bleio_characteristic_obj_t supervisor_ble_length_characteristic; bleio_uuid_obj_t supervisor_ble_length_uuid; bleio_characteristic_obj_t supervisor_ble_contents_characteristic; bleio_uuid_obj_t supervisor_ble_contents_uuid; + +// This is the base UUID for CircuitPython services and characteristics. const uint8_t circuitpython_base_uuid[16] = {0x6e, 0x68, 0x74, 0x79, 0x50, 0x74, 0x69, 0x75, 0x63, 0x72, 0x69, 0x43, 0x00, 0x00, 0xaf, 0xad }; +// This standard advertisement advertises the CircuitPython editing service and a CIRCUITPY short name. uint8_t circuitpython_advertising_data[] = { 0x02, 0x01, 0x06, 0x02, 0x0a, 0x00, 0x11, 0x07, 0x6e, 0x68, 0x74, 0x79, 0x50, 0x74, 0x69, 0x75, 0x63, 0x72, 0x69, 0x43, 0x00, 0x01, 0xaf, 0xad, 0x06, 0x08, 0x43, 0x49, 0x52, 0x43, 0x55 }; +// This scan response advertises the full CIRCUITPYXXXX device name. uint8_t circuitpython_scan_response_data[15] = {0x0e, 0x09, 0x43, 0x49, 0x52, 0x43, 0x55, 0x49, 0x54, 0x50, 0x59, 0x00, 0x00, 0x00, 0x00}; mp_obj_list_t service_list; mp_obj_t service_list_items[1]; From c38a2ac3346f68ef83dc6ec9b4fe1cef34fdcb5d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 6 Dec 2019 13:25:28 -0600 Subject: [PATCH 141/531] make translate --- locale/ID.po | 5 ++--- locale/circuitpython.pot | 5 ++--- locale/de_DE.po | 5 ++--- locale/en_US.po | 5 ++--- locale/en_x_pirate.po | 5 ++--- locale/es.po | 5 ++--- locale/fil.po | 5 ++--- locale/fr.po | 5 ++--- locale/it_IT.po | 5 ++--- locale/ko.po | 5 ++--- locale/pl.po | 5 ++--- locale/pt_BR.po | 5 ++--- locale/zh_Latn_pinyin.po | 5 ++--- 13 files changed, 26 insertions(+), 39 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index d3d025379c..472c042c60 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -121,8 +121,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' integer 0x%x tidak cukup didalam mask 0x%x" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index f9edf50af3..1541b1f74d 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:58-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -120,8 +120,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/de_DE.po b/locale/de_DE.po index d6c3fc359c..b34626ea1a 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -122,8 +122,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' Integer 0x%x passt nicht in Maske 0x%x" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/en_US.po b/locale/en_US.po index a2e18f8ad2..95884c7b25 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -120,8 +120,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 32772646c9..ed7d2cec72 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -122,8 +122,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/es.po b/locale/es.po index 6ff7e8e174..fac38c0817 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -122,8 +122,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' entero 0x%x no cabe en la máscara 0x%x" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/fil.po b/locale/fil.po index 1e14df3ed1..776002768d 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -123,8 +123,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' integer 0x%x ay wala sa mask na sakop ng 0x%x" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/fr.po b/locale/fr.po index ff513edbf4..78d079bf12 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -124,8 +124,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' l'entier 0x%x ne correspond pas au masque 0x%x" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/it_IT.po b/locale/it_IT.po index 7037ad15e0..67585fe2fb 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -122,8 +122,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "intero '%s' non è nell'intervallo %d..%d" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/ko.po b/locale/ko.po index 7d58863229..0cf6747370 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -122,8 +122,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/pl.po b/locale/pl.po index 37395aecd2..0e33f3022c 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -121,8 +121,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' liczba 0x%x nie pasuje do maski 0x%x" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/pt_BR.po b/locale/pt_BR.po index f2fa266154..f1f707f63d 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -122,8 +122,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 2e91bcafa4..6e49774b56 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-04 09:44-0600\n" +"POT-Creation-Date: 2019-12-06 13:25-0600\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -122,8 +122,7 @@ msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgstr "'%s' zhěngshù 0x%x bù shìyòng yú yǎn mǎ 0x%x" #: py/proto.c -#, c-format -msgid "'%s' object does not support '%s'" +msgid "'%s' object does not support '%q'" msgstr "" #: py/obj.c From d5eca87ca23e9288b31c51f3d841fd2bb37c631b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 6 Dec 2019 13:25:40 -0600 Subject: [PATCH 142/531] audiocore: use mp_obj_t in prototypes --- shared-module/audiocore/__init__.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shared-module/audiocore/__init__.h b/shared-module/audiocore/__init__.h index 9012c0d8b9..38c1f5aeb1 100644 --- a/shared-module/audiocore/__init__.h +++ b/shared-module/audiocore/__init__.h @@ -39,14 +39,14 @@ typedef enum { GET_BUFFER_ERROR, // Error while reading data. } audioio_get_buffer_result_t; -typedef uint32_t (*audiosample_sample_rate_fun)(void* sample_obj); -typedef uint8_t (*audiosample_bits_per_sample_fun)(void* sample_obj); -typedef uint8_t (*audiosample_channel_count_fun)(void* sample_obj); -typedef void (*audiosample_reset_buffer_fun)(void* sample_obj); -typedef audioio_get_buffer_result_t (*audiosample_get_buffer_fun)(void* sample_obj, +typedef uint32_t (*audiosample_sample_rate_fun)(mp_obj_t); +typedef uint8_t (*audiosample_bits_per_sample_fun)(mp_obj_t); +typedef uint8_t (*audiosample_channel_count_fun)(mp_obj_t); +typedef void (*audiosample_reset_buffer_fun)(mp_obj_t); +typedef audioio_get_buffer_result_t (*audiosample_get_buffer_fun)(mp_obj_t, bool single_channel, uint8_t channel, uint8_t** buffer, uint32_t* buffer_length); -typedef void (*audiosample_get_buffer_structure_fun)(void* sample_obj, +typedef void (*audiosample_get_buffer_structure_fun)(mp_obj_t, bool single_channel, bool* single_buffer, bool* samples_signed, uint32_t *max_buffer_length, uint8_t* spacing); From d628d2a261bb28b84c6b257a990bd9a30cbe369c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 6 Dec 2019 15:18:20 -0500 Subject: [PATCH 143/531] atmel-samd working --- ports/atmel-samd/bindings/samd/Clock.c | 260 ++++++++++++++++++ .../common-hal/frequencyio/FrequencyIn.c | 2 +- ports/atmel-samd/mpconfigport.h | 48 ++-- ports/atmel-samd/peripherals | 2 +- ports/atmel-samd/supervisor/port.c | 54 +++- py/circuitpy_mpconfig.h | 3 +- tools/build_memory_info.py | 3 +- 7 files changed, 349 insertions(+), 23 deletions(-) diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c index be597c4440..b88bb82e22 100644 --- a/ports/atmel-samd/bindings/samd/Clock.c +++ b/ports/atmel-samd/bindings/samd/Clock.c @@ -163,3 +163,263 @@ const mp_obj_type_t samd_clock_type = { .print = samd_clock_print, .locals_dict = (mp_obj_t)&samd_clock_locals_dict, }; + +#ifdef SAMD21 + +#ifdef SAMD21_EXPOSE_ALL_CLOCKS +CLOCK_SOURCE(XOSC); +CLOCK_SOURCE(GCLKIN); +CLOCK_SOURCE(GCLKGEN1); +CLOCK_SOURCE(OSCULP32K); +#endif +CLOCK_SOURCE(OSC32K); +CLOCK_SOURCE(XOSC32K); +#ifdef SAMD21_EXPOSE_ALL_CLOCKS +CLOCK_SOURCE(OSC8M); +CLOCK_SOURCE(DFLL48M); +CLOCK_SOURCE(DPLL96M); + +CLOCK_GCLK_(SYSCTRL, DFLL48); +CLOCK_GCLK_(SYSCTRL, FDPLL); +CLOCK_GCLK_(SYSCTRL, FDPLL32K); +CLOCK_GCLK(WDT); +#endif +CLOCK_GCLK(RTC); +#ifdef SAMD21_EXPOSE_ALL_CLOCKS +CLOCK_GCLK(EIC); +CLOCK_GCLK(USB); +CLOCK_GCLK_(EVSYS, 0); +CLOCK_GCLK_(EVSYS, 1); +CLOCK_GCLK_(EVSYS, 2); +CLOCK_GCLK_(EVSYS, 3); +CLOCK_GCLK_(EVSYS, 4); +CLOCK_GCLK_(EVSYS, 5); +CLOCK_GCLK_(EVSYS, 6); +CLOCK_GCLK_(EVSYS, 7); +CLOCK_GCLK_(EVSYS, 8); +CLOCK_GCLK_(EVSYS, 9); +CLOCK_GCLK_(EVSYS, 10); +CLOCK_GCLK_(EVSYS, 11); +CLOCK(SERCOMx_SLOW, 1, 19); +CLOCK_GCLK_(SERCOM0, CORE); +CLOCK_GCLK_(SERCOM1, CORE); +CLOCK_GCLK_(SERCOM2, CORE); +CLOCK_GCLK_(SERCOM3, CORE); +CLOCK_GCLK_(SERCOM4, CORE); +CLOCK_GCLK_(SERCOM5, CORE); +CLOCK(TCC0_TCC1, 1, 26); +CLOCK(TCC2_TCC3, 1, 27); +CLOCK(TC4_TC5, 1, 28); +CLOCK(TC6_TC7, 1, 29); +CLOCK_GCLK(ADC); +CLOCK_GCLK_(AC, DIG); +CLOCK_GCLK_(AC, ANA); +CLOCK_GCLK(DAC); +CLOCK_GCLK(PTC); +CLOCK_GCLK_(I2S, 0); +CLOCK_GCLK_(I2S, 1); + +CLOCK(SYSTICK, 2, 0); +#endif + +STATIC const mp_rom_map_elem_t samd_clock_global_dict_table[] = { +#ifdef SAMD21_EXPOSE_ALL_CLOCKS + CLOCK_ENTRY(XOSC), + CLOCK_ENTRY(GCLKIN), + CLOCK_ENTRY(GCLKGEN1), + CLOCK_ENTRY(OSCULP32K), +#endif + CLOCK_ENTRY(OSC32K), + CLOCK_ENTRY(XOSC32K), +#ifdef SAMD21_EXPOSE_ALL_CLOCKS + CLOCK_ENTRY(OSC8M), + CLOCK_ENTRY(DFLL48M), + CLOCK_ENTRY(DPLL96M), + CLOCK_ENTRY_(SYSCTRL, DFLL48), + CLOCK_ENTRY_(SYSCTRL, FDPLL), + CLOCK_ENTRY_(SYSCTRL, FDPLL32K), + CLOCK_ENTRY(WDT), +#endif + CLOCK_ENTRY(RTC), +#ifdef SAMD21_EXPOSE_ALL_CLOCKS + CLOCK_ENTRY(EIC), + CLOCK_ENTRY(USB), + CLOCK_ENTRY_(EVSYS, 0), + CLOCK_ENTRY_(EVSYS, 1), + CLOCK_ENTRY_(EVSYS, 2), + CLOCK_ENTRY_(EVSYS, 3), + CLOCK_ENTRY_(EVSYS, 4), + CLOCK_ENTRY_(EVSYS, 5), + CLOCK_ENTRY_(EVSYS, 6), + CLOCK_ENTRY_(EVSYS, 7), + CLOCK_ENTRY_(EVSYS, 8), + CLOCK_ENTRY_(EVSYS, 9), + CLOCK_ENTRY_(EVSYS, 10), + CLOCK_ENTRY_(EVSYS, 11), + CLOCK_ENTRY(SERCOMx_SLOW), + CLOCK_ENTRY_(SERCOM0, CORE), + CLOCK_ENTRY_(SERCOM1, CORE), + CLOCK_ENTRY_(SERCOM2, CORE), + CLOCK_ENTRY_(SERCOM3, CORE), + CLOCK_ENTRY_(SERCOM4, CORE), + CLOCK_ENTRY_(SERCOM5, CORE), + CLOCK_ENTRY(TCC0_TCC1), + CLOCK_ENTRY(TCC2_TCC3), + CLOCK_ENTRY(TC4_TC5), + CLOCK_ENTRY(TC6_TC7), + CLOCK_ENTRY(ADC), + CLOCK_ENTRY_(AC, DIG), + CLOCK_ENTRY_(AC, ANA), + CLOCK_ENTRY(DAC), + CLOCK_ENTRY(PTC), + CLOCK_ENTRY_(I2S, 0), + CLOCK_ENTRY_(I2S, 1), + + CLOCK_ENTRY(SYSTICK), +#endif +}; +MP_DEFINE_CONST_DICT(samd_clock_globals, samd_clock_global_dict_table); + +#endif // SAMD21 + +#ifdef SAMD51 + + + +#include +#include +#include +#include +#include +#include +#include + +CLOCK_SOURCE(XOSC0); +CLOCK_SOURCE(XOSC1); +CLOCK_SOURCE(GCLKIN); +CLOCK_SOURCE(GCLKGEN1); +CLOCK_SOURCE(OSCULP32K); +CLOCK_SOURCE(XOSC32K); +CLOCK_SOURCE(DFLL); +CLOCK_SOURCE(DPLL0); +CLOCK_SOURCE(DPLL1); + +CLOCK_GCLK_(OSCCTRL, DFLL48); +CLOCK_GCLK_(OSCCTRL, FDPLL0); +CLOCK_GCLK_(OSCCTRL, FDPLL1); +CLOCK_GCLK_(OSCCTRL, FDPLL032K); // GCLK_OSCCTRL_FDPLL1_32K, GCLK_SDHC0_SLOW, GCLK_SDHC1_SLOW, GCLK_SERCOM[0..7]_SLOW +CLOCK_GCLK(EIC); +CLOCK_GCLK_(FREQM, MSR); +// 6: GCLK_FREQM_REF +CLOCK_GCLK_(SERCOM0, CORE); +CLOCK_GCLK_(SERCOM1, CORE); +CLOCK(TC0_TC1, 1, 9); +CLOCK_GCLK(USB); +CLOCK_GCLK_(EVSYS, 0); +CLOCK_GCLK_(EVSYS, 1); +CLOCK_GCLK_(EVSYS, 2); +CLOCK_GCLK_(EVSYS, 3); +CLOCK_GCLK_(EVSYS, 4); +CLOCK_GCLK_(EVSYS, 5); +CLOCK_GCLK_(EVSYS, 6); +CLOCK_GCLK_(EVSYS, 7); +CLOCK_GCLK_(EVSYS, 8); +CLOCK_GCLK_(EVSYS, 9); +CLOCK_GCLK_(EVSYS, 10); +CLOCK_GCLK_(EVSYS, 11); +CLOCK_GCLK_(SERCOM2, CORE); +CLOCK_GCLK_(SERCOM3, CORE); +CLOCK(TCC0_TCC1, 1, 25); +CLOCK(TC2_TC3, 1, 26); +CLOCK_GCLK(CAN0); +CLOCK_GCLK(CAN1); +CLOCK(TCC2_TCC3, 1, 29); +CLOCK(TC4_TC5, 1, 30); +// CLOCK_GCLK(PDEC); +// CLOCK_GCLK(AC); +// CLOCK_GCLK(CCL); +CLOCK_GCLK_(SERCOM4, CORE); +CLOCK_GCLK_(SERCOM5, CORE); +CLOCK_GCLK_(SERCOM6, CORE); +CLOCK_GCLK_(SERCOM7, CORE); +CLOCK_GCLK(TCC4); +CLOCK(TC6_TC7, 1, 39); +CLOCK_GCLK(ADC0); +CLOCK_GCLK(ADC1); +CLOCK_GCLK(DAC); +CLOCK_GCLK_(I2S, 0); +CLOCK_GCLK_(I2S, 1); +// CLOCK_GCLK(SDHC0); +// CLOCK_GCLK(SDHC1); +// 47: GCLK_CM4_TRACE + +CLOCK(SYSTICK, 2, 0); +CLOCK(CPU, 2, 1); +CLOCK(RTC, 2, 2); + + +STATIC const mp_rom_map_elem_t samd_clock_global_dict_table[] = { + CLOCK_ENTRY(XOSC0), + CLOCK_ENTRY(XOSC1), + CLOCK_ENTRY(GCLKIN), + CLOCK_ENTRY(GCLKGEN1), + CLOCK_ENTRY(OSCULP32K), + CLOCK_ENTRY(XOSC32K), + CLOCK_ENTRY(DFLL), + CLOCK_ENTRY(DPLL0), + CLOCK_ENTRY(DPLL1), + + CLOCK_ENTRY_(OSCCTRL, DFLL48), + CLOCK_ENTRY_(OSCCTRL, FDPLL0), + CLOCK_ENTRY_(OSCCTRL, FDPLL1), + CLOCK_ENTRY_(OSCCTRL, FDPLL032K), + CLOCK_ENTRY(EIC), + CLOCK_ENTRY_(FREQM, MSR), + CLOCK_ENTRY_(SERCOM0, CORE), + CLOCK_ENTRY_(SERCOM1, CORE), + CLOCK_ENTRY(TC0_TC1), + CLOCK_ENTRY(USB), + CLOCK_ENTRY_(EVSYS, 0), + CLOCK_ENTRY_(EVSYS, 1), + CLOCK_ENTRY_(EVSYS, 2), + CLOCK_ENTRY_(EVSYS, 3), + CLOCK_ENTRY_(EVSYS, 4), + CLOCK_ENTRY_(EVSYS, 5), + CLOCK_ENTRY_(EVSYS, 6), + CLOCK_ENTRY_(EVSYS, 7), + CLOCK_ENTRY_(EVSYS, 8), + CLOCK_ENTRY_(EVSYS, 9), + CLOCK_ENTRY_(EVSYS, 10), + CLOCK_ENTRY_(EVSYS, 11), + CLOCK_ENTRY_(SERCOM2, CORE), + CLOCK_ENTRY_(SERCOM3, CORE), + CLOCK_ENTRY(TCC0_TCC1), + CLOCK_ENTRY(TC2_TC3), + CLOCK_ENTRY(CAN0), + CLOCK_ENTRY(CAN1), + CLOCK_ENTRY(TCC2_TCC3), + CLOCK_ENTRY(TC4_TC5), + // CLOCK_ENTRY(PDEC), + // CLOCK_ENTRY(AC), + // CLOCK_ENTRY(CCL), + CLOCK_ENTRY_(SERCOM4, CORE), + CLOCK_ENTRY_(SERCOM5, CORE), + CLOCK_ENTRY_(SERCOM6, CORE), + CLOCK_ENTRY_(SERCOM7, CORE), + CLOCK_ENTRY(TCC4), + CLOCK_ENTRY(TC6_TC7), + CLOCK_ENTRY(ADC0), + CLOCK_ENTRY(ADC1), + CLOCK_ENTRY(DAC), + CLOCK_ENTRY_(I2S, 0), + CLOCK_ENTRY_(I2S, 1), + // CLOCK_ENTRY(SDHC0), + // CLOCK_ENTRY(SDHC1), + + CLOCK_ENTRY(SYSTICK), + CLOCK_ENTRY(CPU), + CLOCK_ENTRY(RTC), +}; +MP_DEFINE_CONST_DICT(samd_clock_globals, samd_clock_global_dict_table); + +#endif // SAMD51 diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index d34049946b..6258818c83 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -213,7 +213,7 @@ void frequencyin_samd51_start_dpll() { // Will also enable the Lock Bypass due to low-frequency sources causing DPLL unlocks // as outlined in the Errata (1.12.1) OSCCTRL->Dpll[1].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0) | OSCCTRL_DPLLRATIO_LDR(2999); - if (board_has_crystal()) { // we can use XOSC32K directly as the source + if (BOARD_HAS_CRYSTAL) { // we can use XOSC32K directly as the source OSC32KCTRL->XOSC32K.bit.EN32K = 1; OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK(1) | OSCCTRL_DPLLCTRLB_LBYPASS; diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 9733d270ad..ecb9621945 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -30,28 +30,16 @@ // Definitions for which SAMD chip we're using. #include "include/sam.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////// +#ifdef SAMD21 + #if INTERNAL_FLASH_FILESYSTEM #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) #else #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) #endif -#ifndef CALIBRATE_CRYSTALLESS -#define CALIBRATE_CRYSTALLESS (0) -#endif - -// if CALIBRATE_CRYSTALLESS is requested, make room for storing -// calibration data generated from external USB. -#ifndef CIRCUITPY_INTERNAL_CONFIG_SIZE - #if CALIBRATE_CRYSTALLESS - #define CIRCUITPY_INTERNAL_CONFIG_SIZE (256) - #else - #define CIRCUITPY_INTERNAL_CONFIG_SIZE (0) - #endif -#endif - -#ifdef SAMD21 - // HMCRAMC0_SIZE is defined in the ASF4 include files for each SAMD21 chip. #define RAM_SIZE HMCRAMC0_SIZE #define BOOTLOADER_SIZE (8*1024) @@ -84,6 +72,8 @@ #endif // SAMD21 +//////////////////////////////////////////////////////////////////////////////////////////////////// + #ifdef SAMD51 #ifndef CIRCUITPY_INTERNAL_NVM_SIZE @@ -110,6 +100,7 @@ #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) #define MICROPY_PY_FUNCTION_ATTRS (1) +// MICROPY_PY_UJSON depends on MICROPY_PY_IO #define MICROPY_PY_IO (1) #define MICROPY_PY_UJSON (1) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) @@ -117,6 +108,29 @@ #endif // SAMD51 +//////////////////////////////////////////////////////////////////////////////////////////////////// + +// This also includes mpconfigboard.h. +#include "py/circuitpy_mpconfig.h" + +#ifndef CALIBRATE_CRYSTALLESS +#define CALIBRATE_CRYSTALLESS (0) +#endif + +#ifndef BOARD_HAS_CRYSTAL +#define BOARD_HAS_CRYSTAL (0) +#endif + +// if CALIBRATE_CRYSTALLESS is requested, make room for storing +// calibration data generated from external USB. +#ifndef CIRCUITPY_INTERNAL_CONFIG_SIZE + #if CALIBRATE_CRYSTALLESS + #define CIRCUITPY_INTERNAL_CONFIG_SIZE (NVMCTRL_ROW_SIZE) // 256 + #else + #define CIRCUITPY_INTERNAL_CONFIG_SIZE (0) + #endif +#endif + // Flash layout, starting at 0x00000000 // // bootloader (8 or 16kB) @@ -155,8 +169,6 @@ #include "peripherals/samd/dma.h" -#include "py/circuitpy_mpconfig.h" - #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS \ mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; diff --git a/ports/atmel-samd/peripherals b/ports/atmel-samd/peripherals index 2ba5b20ba7..bb26a4145c 160000 --- a/ports/atmel-samd/peripherals +++ b/ports/atmel-samd/peripherals @@ -1 +1 @@ -Subproject commit 2ba5b20ba725e1c91c77875fba3a5e22059cdb92 +Subproject commit bb26a4145c86a51debc6571bb1f791e0d4fd296b diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index e962281c1e..5662b159bc 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -24,12 +24,16 @@ * THE SOFTWARE. */ +#include +#include + #include "boards/board.h" #include "supervisor/port.h" // ASF 4 #include "atmel_start_pins.h" #include "hal/include/hal_delay.h" +#include "hal/include/hal_flash.h" #include "hal/include/hal_gpio.h" #include "hal/include/hal_init.h" #include "hpl/gclk/hpl_gclk_base.h" @@ -94,6 +98,40 @@ extern volatile bool mp_msc_enabled; __attribute__((__aligned__(TRACE_BUFFER_SIZE_BYTES))) uint32_t mtb[TRACE_BUFFER_SIZE] = {0}; #endif +#if CALIBRATE_CRYSTALLESS +static void save_usb_clock_calibration(void) { + // If we are on USB lets double check our fine calibration for the clock and + // save the new value if its different enough. + SYSCTRL->DFLLSYNC.bit.READREQ = 1; + uint16_t saved_calibration = 0x1ff; + if (strcmp((char*) CIRCUITPY_INTERNAL_CONFIG_START_ADDR, "CIRCUITPYTHON1") == 0) { + saved_calibration = ((uint16_t *) CIRCUITPY_INTERNAL_CONFIG_START_ADDR)[8]; + } + while (SYSCTRL->PCLKSR.bit.DFLLRDY == 0) { + // TODO(tannewt): Run the mass storage stuff if this takes a while. + } + int16_t current_calibration = SYSCTRL->DFLLVAL.bit.FINE; + if (abs(current_calibration - saved_calibration) > 10) { + // Copy the full internal config page to memory. + uint8_t page_buffer[NVMCTRL_ROW_SIZE]; + memcpy(page_buffer, (uint8_t*) CIRCUITPY_INTERNAL_CONFIG_START_ADDR, NVMCTRL_ROW_SIZE); + + // Modify it. + memcpy(page_buffer, "CIRCUITPYTHON1", 15); + // First 16 bytes (0-15) are ID. Little endian! + page_buffer[16] = current_calibration & 0xff; + page_buffer[17] = current_calibration >> 8; + + // Write it back. + // We don't use features that use any advanced NVMCTRL features so we can fake the descriptor + // whenever we need it instead of storing it long term. + struct flash_descriptor desc; + desc.dev.hw = NVMCTRL; + flash_write(&desc, (uint32_t) CIRCUITPY_INTERNAL_CONFIG_START_ADDR, page_buffer, NVMCTRL_ROW_SIZE); + } +} +#endif + safe_mode_t port_init(void) { #if defined(SAMD21) @@ -168,7 +206,19 @@ safe_mode_t port_init(void) { hri_nvmctrl_set_CTRLB_RWS_bf(NVMCTRL, 2); _pm_init(); #endif - clock_init(); + +#if CALIBRATE_CRYSTALLESS + uint32_t fine = DEFAULT_DFLL48M_FINE_CALIBRATION; + // The fine calibration data is stored in an NVM page after the text and data storage but before + // the optional file system. The first 16 bytes are the identifier for the section. + if (strcmp((char*) CIRCUITPY_INTERNAL_CONFIG_START_ADDR, "CIRCUITPYTHON1") == 0) { + fine = ((uint16_t *) CIRCUITPY_INTERNAL_CONFIG_START_ADDR)[8]; + } + clock_init(BOARD_HAS_CRYSTAL, fine); +#else + // Use a default fine value + clock_init(BOARD_HAS_CRYSTAL, DEFAULT_DFLL48M_FINE_CALIBRATION); +#endif // Configure millisecond timer initialization. tick_init(); @@ -257,9 +307,11 @@ void reset_port(void) { // gpio_set_pin_function(PIN_PB15, GPIO_PIN_FUNCTION_M); // GCLK1, D6 // #endif +#if CALIBRATE_CRYSTALLESS if (tud_cdc_connected()) { save_usb_clock_calibration(); } +#endif } void reset_to_bootloader(void) { diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index cf21d26dd0..c4606074fa 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -174,7 +174,8 @@ typedef long mp_off_t; { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, -// board specific definitions +////////////////////////////////////////////////////////////////////////////////////////////////// +// board-specific definitions, which control and may override definitions below. #include "mpconfigboard.h" // CIRCUITPY_FULL_BUILD is defined in a *.mk file. diff --git a/tools/build_memory_info.py b/tools/build_memory_info.py index 0dcd5f6e48..f128561ab2 100644 --- a/tools/build_memory_info.py +++ b/tools/build_memory_info.py @@ -41,6 +41,7 @@ data = 0 bss = 0 # stdin is the linker output. for line in sys.stdin: + print(line) line = line.strip() if not line.startswith("text"): text, data, bss = map(int, line.split()[:3]) @@ -64,7 +65,7 @@ for region in regions: free_flash = regions["FLASH_FIRMWARE"] - text - data free_ram = regions["RAM"] - data - bss print("{} bytes free in flash firmware space out of {} bytes ({}kB).".format(free_flash, regions["FLASH_FIRMWARE"], regions["FLASH_FIRMWARE"] / 1024)) -print("{} bytes free in ram for stack out of {} bytes ({}kB).".format(free_ram, regions["RAM"], regions["RAM"] / 1024)) +print("{} bytes free in ram for heap out of {} bytes ({}kB).".format(free_ram, regions["RAM"], regions["RAM"] / 1024)) print() # Check that we have free flash space. GCC doesn't fail when the text + data From 252da17bc911b79ea82402d1dd7c5691bb5cbbba Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 6 Dec 2019 15:55:00 -0500 Subject: [PATCH 144/531] Create VBUS disable interface in shared supervisor --- .../stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h | 1 + ports/stm32f4/supervisor/usb.c | 9 ++++++++- supervisor/shared/usb/usb.c | 7 +++++++ supervisor/usb.h | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index a438b5baa6..b8e374f05b 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,6 +33,7 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 +#define BOARD_NO_VBUS // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 95db0aafc2..a97b1f2574 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -43,6 +43,7 @@ void init_usb_hardware(void) { PA11 ------> USB_OTG_FS_DM PA12 ------> USB_OTG_FS_DP */ + __HAL_RCC_GPIOA_CLK_ENABLE(); /* Configure DM DP Pins */ @@ -58,7 +59,7 @@ void init_usb_hardware(void) { /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 9); @@ -83,3 +84,9 @@ void init_usb_hardware(void) { /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); } + +void disable_usb_vbus(void) { + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; +} diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index c1d70c5b0f..fca08b4eed 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -33,6 +33,8 @@ #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" +#include "py/mpconfig.h" + #include "tusb.h" // Serial number as hex characters. This writes directly to the USB @@ -72,6 +74,11 @@ void usb_init(void) { #if CIRCUITPY_USB_MIDI usb_midi_init(); #endif + +#ifdef BOARD_NO_VBUS + disable_usb_vbus(); +#endif + } void usb_background(void) { diff --git a/supervisor/usb.h b/supervisor/usb.h index c87540d408..6b4082b6f8 100644 --- a/supervisor/usb.h +++ b/supervisor/usb.h @@ -37,6 +37,8 @@ void usb_background(void); // TinyUSB. void init_usb_hardware(void); +void disable_usb_vbus(void); + // Shared implementation. bool usb_enabled(void); void usb_init(void); From dd4d3a662d59360253e632415e65480c2bc1c9e0 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 6 Dec 2019 16:44:17 -0500 Subject: [PATCH 145/531] conditional for F412 register difference --- ports/stm32f4/supervisor/usb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index a97b1f2574..e3baf1412b 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -86,7 +86,12 @@ void init_usb_hardware(void) { } void disable_usb_vbus(void) { + +#ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; +#else USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; +#endif } From da0ea979ff651e6358e99b6369a22b9184e2f7e6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 5 Dec 2019 15:02:52 -0800 Subject: [PATCH 146/531] Check connection validity after service discovery. Fixes #2347 --- ports/nrf/bluetooth/ble_drv.c | 4 ---- ports/nrf/common-hal/_bleio/Connection.c | 6 +----- shared-bindings/_bleio/Connection.c | 10 +++++----- shared-bindings/_bleio/Connection.h | 2 ++ shared-bindings/_bleio/Service.c | 2 +- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index 896fa0fb09..63d67a7f4a 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.c @@ -153,10 +153,6 @@ void SD_EVT_IRQHandler(void) { ble_gatts_evt_write_t* write_evt = &event->evt.gatts_evt.params.write; mp_printf(&mp_plat_print, "Write to: UUID(0x%04x) handle %x of length %d auth %x\n", write_evt->uuid.uuid, write_evt->handle, write_evt->len, write_evt->auth_required); } - if (!done) { - mp_printf(&mp_plat_print, "Unhandled ble event: 0x%04x\n", event->header.evt_id); - - } #endif } } diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 0720d5c472..e0b50901ad 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -248,11 +248,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { default: - // For debugging. - #if CIRCUITPY_VERBOSE_BLE - mp_printf(&mp_plat_print, "Unhandled connection event: 0x%04x\n", ble_evt->header.evt_id); - #endif - return false; } return true; @@ -659,6 +654,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist) { discover_remote_services(self->connection, service_uuids_whitelist); + bleio_connection_ensure_connected(self); // Convert to a tuple and then clear the list so the callee will take ownership. mp_obj_tuple_t *services_tuple = service_linked_list_to_tuple(self->connection->remote_service_list); self->connection->remote_service_list = NULL; diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index 709f6c2540..c157af3652 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -66,7 +66,7 @@ //| connection = _bleio.adapter.connect(my_entry.address, timeout=10) //| -STATIC void ensure_connected(bleio_connection_obj_t *self) { +void bleio_connection_ensure_connected(bleio_connection_obj_t *self) { if (!common_hal_bleio_connection_get_connected(self)) { mp_raise_bleio_ConnectionError(translate("Connection has been disconnected and can no longer be used. Create a new connection.")); } @@ -106,7 +106,7 @@ STATIC mp_obj_t bleio_connection_pair(mp_uint_t n_args, const mp_obj_t *pos_args 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); - ensure_connected(self); + bleio_connection_ensure_connected(self); common_hal_bleio_connection_pair(self->connection, args[ARG_bond].u_bool); return mp_const_none; @@ -148,7 +148,7 @@ STATIC mp_obj_t bleio_connection_discover_remote_services(mp_uint_t n_args, cons 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); - ensure_connected(self); + bleio_connection_ensure_connected(self); return MP_OBJ_FROM_PTR(common_hal_bleio_connection_discover_remote_services( self, @@ -209,7 +209,7 @@ const mp_obj_property_t bleio_connection_paired_obj = { STATIC mp_obj_t bleio_connection_get_connection_interval(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); - ensure_connected(self); + bleio_connection_ensure_connected(self); return mp_obj_new_float(common_hal_bleio_connection_get_connection_interval(self->connection)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_connection_interval_obj, bleio_connection_get_connection_interval); @@ -219,7 +219,7 @@ STATIC mp_obj_t bleio_connection_set_connection_interval(mp_obj_t self_in, mp_ob mp_float_t interval = mp_obj_get_float(interval_in); - ensure_connected(self); + bleio_connection_ensure_connected(self); common_hal_bleio_connection_set_connection_interval(self->connection, interval); return mp_const_none; diff --git a/shared-bindings/_bleio/Connection.h b/shared-bindings/_bleio/Connection.h index b0e26da5c8..c6f2601608 100644 --- a/shared-bindings/_bleio/Connection.h +++ b/shared-bindings/_bleio/Connection.h @@ -43,4 +43,6 @@ extern mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(blei mp_float_t common_hal_bleio_connection_get_connection_interval(bleio_connection_internal_t *self); void common_hal_bleio_connection_set_connection_interval(bleio_connection_internal_t *self, mp_float_t new_interval); +void bleio_connection_ensure_connected(bleio_connection_obj_t *self); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CONNECTION_H diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index 43679393a2..bc242bc364 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -136,7 +136,7 @@ const mp_obj_property_t bleio_service_secondary_obj = { //| .. attribute:: uuid //| //| The UUID of this service. (read-only) -//| +//| //| Will be ``None`` if the 128-bit UUID for this service is not known. //| STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) { From 1905d0746dbd8677161dfc4523558a8fa8b029ed Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 7 Dec 2019 19:06:17 -0600 Subject: [PATCH 147/531] samd: neopixel: Fix neopixels after #2297 This adapts the "inline assembler" code from the UF2 bootloader, which in turn is said to be adapted from the arduino neopixel library. This requires the cache remain ON when using M0, and be turned OFF on M4 (determined by trial and error) Testing performed on a Metro M4: * measured timings using o'scope and found all values within datasheet tolerance. * Drove a string of 96 neopixels without visible glitches * on-board neopixel worked Testing performed on a Circuit Playground Express (M0): * Color wheel code works on built-in neopixels * Color wheel code works on 96 neopixel strip As a bonus, this may have freed up a bit of flash on M0 targets. (2988 -> 3068 bytes free on Trinket M0) Closes: #2297 --- .../common-hal/neopixel_write/__init__.c | 157 +++++++----------- 1 file changed, 63 insertions(+), 94 deletions(-) diff --git a/ports/atmel-samd/common-hal/neopixel_write/__init__.c b/ports/atmel-samd/common-hal/neopixel_write/__init__.c index 57e963c918..ba69174af4 100644 --- a/ports/atmel-samd/common-hal/neopixel_write/__init__.c +++ b/ports/atmel-samd/common-hal/neopixel_write/__init__.c @@ -34,24 +34,62 @@ #ifdef SAMD51 #include "hri/hri_cmcc_d51.h" #include "hri/hri_nvmctrl_d51.h" - -// This magical macro makes sure the delay isn't optimized out and is the -// minimal three instructions. -#define delay_cycles(cycles) \ -{ \ - uint32_t t; \ - asm volatile ( \ - "movs %[t], %[c]\n\t" \ - "loop%=:\n\t" \ - "subs %[t], #1\n\t" \ - "bne.n loop%=" : [t] "=r"(t) : [c] "I" (cycles)); \ - } #endif -// Ensure this code is compiled with -Os. Any other optimization level may change the timing of it -// and break neopixels. -#pragma GCC push_options -#pragma GCC optimize ("Os") +__attribute__((naked,noinline,aligned(16))) +static void neopixel_send_buffer_core(volatile uint32_t *clraddr, uint32_t pinMask, + const uint8_t *ptr, int numBytes); + +static void neopixel_send_buffer_core(volatile uint32_t *clraddr, uint32_t pinMask, + const uint8_t *ptr, int numBytes) { + asm volatile(" push {r4, r5, r6, lr};" + " add r3, r2, r3;" + "loopLoad:" + " ldrb r5, [r2, #0];" // r5 := *ptr + " add r2, #1;" // ptr++ + " movs r4, #128;" // r4-mask, 0x80 + "loopBit:" + " str r1, [r0, #4];" // set + #ifdef SAMD21 + " movs r6, #3; d2: sub r6, #1; bne d2;" // delay 3 + #endif + #ifdef SAMD51 + " movs r6, #3; d2: subs r6, #1; bne d2;" // delay 3 + #endif + " tst r4, r5;" // mask&r5 + " bne skipclr;" + " str r1, [r0, #0];" // clr + "skipclr:" + #ifdef SAMD21 + " movs r6, #6; d0: sub r6, #1; bne d0;" // delay 6 + #endif + #ifdef SAMD51 + " movs r6, #6; d0: subs r6, #1; bne d0;" // delay 6 + #endif + " str r1, [r0, #0];" // clr (possibly again, doesn't matter) + #ifdef SAMD21 + " asr r4, r4, #1;" // mask >>= 1 + #endif + #ifdef SAMD51 + " asrs r4, r4, #1;" // mask >>= 1 + #endif + " beq nextbyte;" + " uxtb r4, r4;" + #ifdef SAMD21 + " movs r6, #2; d1: sub r6, #1; bne d1;" // delay 2 + #endif + #ifdef SAMD51 + " movs r6, #2; d1: subs r6, #1; bne d1;" // delay 2 + #endif + " b loopBit;" + "nextbyte:" + " cmp r2, r3;" + " bcs neopixel_stop;" + " b loopLoad;" + "neopixel_stop:" + " pop {r4, r5, r6, pc};" + ""); +} uint64_t next_start_tick_ms = 0; uint32_t next_start_tick_us = 1000; @@ -59,7 +97,7 @@ uint32_t next_start_tick_us = 1000; void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) { // This is adapted directly from the Adafruit NeoPixel library SAMD21G18A code: // https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp - uint8_t *ptr, *end, p, bitMask; + // and the asm version from https://github.com/microsoft/uf2-samdx1/blob/master/inc/neopixel.h uint32_t pinMask; PortGroup* port; @@ -71,21 +109,18 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, mp_hal_disable_all_interrupts(); - #ifdef SAMD21 - // Make sure the NVM cache is consistently timed. - NVMCTRL->CTRLB.bit.READMODE = NVMCTRL_CTRLB_READMODE_DETERMINISTIC_Val; - #endif - #ifdef SAMD51 // When this routine is positioned at certain addresses, the timing logic // below can be too fast by about 2.5x. This is some kind of (un)fortunate code - // positiong with respect to a cache line. + // positioning with respect to a cache line. // Theoretically we should turn on off the CMCC caches and the // NVM caches to ensure consistent timing. Testing shows the the NVMCTRL // cache disabling seems to make the difference. But turn both off to make sure. // It's difficult to test because additions to the code before the timing loop - // below change instruction placement. Testing was done by adding cache changes - // below the loop (so only the first time through is wrong). + // below change instruction placement. (though this should be less true now that + // the main code is in the cache-aligned function neopixel_send_buffer_core) + // Testing was done by adding cache changes below the loop (so only the + // first time through is wrong). // // Turn off instruction, data, and NVM caches to force consistent timing. // Invalidate existing cache entries. @@ -93,78 +128,13 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, hri_cmcc_write_MAINT0_reg(CMCC, CMCC_MAINT0_INVALL); hri_nvmctrl_set_CTRLA_CACHEDIS0_bit(NVMCTRL); hri_nvmctrl_set_CTRLA_CACHEDIS1_bit(NVMCTRL); - #endif + #endif uint32_t pin = digitalinout->pin->number; port = &PORT->Group[GPIO_PORT(pin)]; // Convert GPIO # to port register pinMask = (1UL << (pin % 32)); // From port_pin_set_output_level ASF code. - ptr = pixels; - end = ptr + numBytes; - p = *ptr++; - bitMask = 0x80; - - volatile uint32_t *set = &(port->OUTSET.reg), - *clr = &(port->OUTCLR.reg); - - for(;;) { - *set = pinMask; - // This is the time where the line is always high regardless of the bit. - // For the SK6812 its 0.3us +- 0.15us - #ifdef SAMD21 - asm("nop; nop;"); - #endif - #ifdef SAMD51 - delay_cycles(2); - #endif - if((p & bitMask) != 0) { - // This is the high delay unique to a one bit. - // For the SK6812 its 0.3us - #ifdef SAMD21 - asm("nop; nop; nop; nop; nop; nop; nop;"); - #endif - #ifdef SAMD51 - delay_cycles(3); - #endif - *clr = pinMask; - } else { - *clr = pinMask; - // This is the low delay unique to a zero bit. - // For the SK6812 its 0.3us - #ifdef SAMD21 - asm("nop; nop;"); - #endif - #ifdef SAMD51 - delay_cycles(2); - #endif - } - if((bitMask >>= 1) != 0) { - // This is the delay between bits in a byte and is the 1 code low - // level time from the datasheet. - // For the SK6812 its 0.6us +- 0.15us - #ifdef SAMD21 - asm("nop; nop; nop; nop; nop;"); - #endif - #ifdef SAMD51 - delay_cycles(4); - #endif - } else { - if(ptr >= end) break; - p = *ptr++; - bitMask = 0x80; - // This is the delay between bytes. It's similar to the other branch - // in the if statement except its tuned to account for the time the - // above operations take. - // For the SK6812 its 0.6us +- 0.15us - #ifdef SAMD51 - delay_cycles(3); - #endif - } - } - - #ifdef SAMD21 - // Speed up! (But inconsistent timing.) - NVMCTRL->CTRLB.bit.READMODE = NVMCTRL_CTRLB_READMODE_NO_MISS_PENALTY_Val; - #endif + volatile uint32_t *clr = &(port->OUTCLR.reg); + neopixel_send_buffer_core(clr, pinMask, pixels, numBytes); #ifdef SAMD51 // Turn instruction, data, and NVM caches back on. @@ -189,4 +159,3 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, } -#pragma GCC pop_options From dd7ac68fb0a1d1327dbeddf1786480a977d41e96 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 8 Dec 2019 16:53:08 -0500 Subject: [PATCH 148/531] fix slice anf fill bugs --- shared-bindings/_pixelbuf/PixelBuf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index d0be2b61df..dabc23d359 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -349,8 +349,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - for (size_t offset = 0; offset < self->pixels; offset++) { - pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, + for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { + pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) call_show(self_in); @@ -382,7 +382,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; - mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice); + mp_seq_get_fast_slice_indexes(self->pixels, index_in, &slice); if ((slice.stop * self->pixel_step) > self->bytes) mp_raise_IndexError(translate("Range out of bounds")); @@ -399,8 +399,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) mp_raise_ValueError(translate("tuple/list required on RHS")); - size_t dst_len = (slice.stop - slice.start); - dst_len = (slice.stop - slice.start) / slice.step; + size_t dst_len = (slice.stop - slice.start) / slice.step; if (slice.step > 1) { if ((slice.stop - slice.start) % slice.step) dst_len ++; From 13620cc4db2c3e0d2655c6ee7ad9faab934488e2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 9 Dec 2019 10:57:55 -0600 Subject: [PATCH 149/531] nRF: PWMAudioOut: fix half-speed playback of stereo samples The "spacing" of "buffer structure" is confusing, use the "channel count" instead. Testing performed on nrf52840 feather: Play stereo and mono, 8- and 16-bit, 8kHz RawSamples representing 333.33Hz square waves. Use both mono and stereo PWMAudioOut instances. Scope the RC-filtered signal and use the scope's frequency measurement function, verify the frequency is 333 or 334Hz in all tested cases. In the "stereo output" cases, verify both the L and R channels. Verify the output amplitude is the same in both channels. In the "stereo output" cases, run a second test where the L channel's amplitude is attenuated 50%. Verify the output amplitude is correct in each channel. --- ports/nrf/common-hal/audiopwmio/PWMAudioOut.c | 16 ++++++++++------ ports/nrf/common-hal/audiopwmio/PWMAudioOut.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index 9496277b10..b4c626355f 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -97,27 +97,28 @@ STATIC void fill_buffers(audiopwmio_pwmaudioout_obj_t *self, int buf) { common_hal_audiopwmio_pwmaudioout_stop(self); return; } - uint32_t num_samples = buffer_length / self->bytes_per_sample / self->spacing; + uint32_t num_samples = buffer_length / self->bytes_per_sample / self->sample_channel_count; + uint16_t *end_dev_buffer = dev_buffer + 2 * num_samples; if (self->bytes_per_sample == 1) { uint8_t offset = self->signed_to_unsigned ? 0x80 : 0; uint16_t scale = self->scale; - for (uint32_t i=0; ispacing; i++) { + while (dev_buffer < end_dev_buffer) { uint8_t rawval = (*buffer++ + offset); uint16_t val = (uint16_t)(((uint32_t)rawval * (uint32_t)scale) >> 8); *dev_buffer++ = val; - if (self->spacing == 1) + if (self->sample_channel_count == 1) *dev_buffer++ = val; } } else { uint16_t offset = self->signed_to_unsigned ? 0x8000 : 0; uint16_t scale = self->scale; uint16_t *buffer16 = (uint16_t*)buffer; - for (uint32_t i=0; ispacing; i++) { + while (dev_buffer < end_dev_buffer) { uint16_t rawval = (*buffer16++ + offset); uint16_t val = (uint16_t)((rawval * (uint32_t)scale) >> 16); *dev_buffer++ = val; - if (self->spacing == 1) + if (self->sample_channel_count == 1) *dev_buffer++ = val; } } @@ -231,9 +232,12 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8; uint32_t max_buffer_length; + uint8_t spacing; audiosample_get_buffer_structure(sample, /* single channel */ false, &self->single_buffer, &self->signed_to_unsigned, &max_buffer_length, - &self->spacing); + &spacing); + self->sample_channel_count = audiosample_channel_count(sample); + if (max_buffer_length > UINT16_MAX) { mp_raise_ValueError_varg(translate("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX); } diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h index 8deff5d340..ed00324c41 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h @@ -41,7 +41,7 @@ typedef struct { uint8_t left_channel_number; uint8_t right_channel_number; - uint8_t spacing; + uint8_t sample_channel_count; uint8_t bytes_per_sample; bool playing; From 00e953e86cb1871a29b3e4329c1de816f7a1d897 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 9 Dec 2019 12:28:25 -0500 Subject: [PATCH 150/531] delete old boards --- ports/stm32f4/boards/pyb_nano_v2/board.c | 39 -- .../boards/pyb_nano_v2/mpconfigboard.h | 52 --- .../boards/pyb_nano_v2/mpconfigboard.mk | 19 - ports/stm32f4/boards/pyb_nano_v2/pins.c | 33 -- .../boards/pyb_nano_v2/stm32f4xx_hal_conf.h | 440 ------------------ .../boards/stm32f411ce_blackpill/board.c | 39 -- .../stm32f411ce_blackpill/mpconfigboard.h | 52 --- .../stm32f411ce_blackpill/mpconfigboard.mk | 19 - .../boards/stm32f411ce_blackpill/pins.c | 33 -- .../stm32f4xx_hal_conf.h | 440 ------------------ 10 files changed, 1166 deletions(-) delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/board.c delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/pins.c delete mode 100644 ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/board.c delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/pins.c delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h diff --git a/ports/stm32f4/boards/pyb_nano_v2/board.c b/ports/stm32f4/boards/pyb_nano_v2/board.c deleted file mode 100644 index 82b0c506ed..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/board.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "boards/board.h" -#include "mpconfigboard.h" - -void board_init(void) { -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { - -} diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h deleted file mode 100644 index 67ddc885ae..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" -#define MICROPY_HW_MCU_NAME "STM32F405RG" - -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (0x4000) - -#define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) - -// On-board flash -#define SPI_FLASH_MOSI_PIN &pin_PB05 -#define SPI_FLASH_MISO_PIN &pin_PB04 -#define SPI_FLASH_SCK_PIN &pin_PB03 -#define SPI_FLASH_CS_PIN &pin_PA15 - -#define DEFAULT_I2C_BUS_SCL (&pin_PB06) -#define DEFAULT_I2C_BUS_SDA (&pin_PB07) - -#define DEFAULT_SPI_BUS_SCK (&pin_PB13) -#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) -#define DEFAULT_SPI_BUS_MISO (&pin_PB14) - -#define DEFAULT_UART_BUS_RX (&pin_PB11) -#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk deleted file mode 100644 index 5bad4e81f3..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk +++ /dev/null @@ -1,19 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x805A -USB_PRODUCT = "Feather STM32F405 Express" -USB_MANUFACTURER = "Adafruit Industries LLC" -USB_DEVICES = "CDC,MSC" - -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = GD25Q16C -LONGINT_IMPL = MPZ - -MCU_SERIES = m4 -MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f405xx -MCU_PACKAGE = 64 -CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/pyb_nano_v2/pins.c b/ports/stm32f4/boards/pyb_nano_v2/pins.c deleted file mode 100644 index 4aa1f362ad..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/pins.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, - - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, - - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, - - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, - - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, - - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h deleted file mode 100644 index 68a49b4ba8..0000000000 --- a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h +++ /dev/null @@ -1,440 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf_template.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32f4xx_hal_conf.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_H -#define __STM32F4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED - -#define HAL_ADC_MODULE_ENABLED -/* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CRC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ -#define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ -#define HAL_I2C_MODULE_ENABLED -#define HAL_I2S_MODULE_ENABLED -/* #define HAL_IWDG_MODULE_ENABLED */ -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_RNG_MODULE_ENABLED */ -/* #define HAL_RTC_MODULE_ENABLED */ -/* #define HAL_SAI_MODULE_ENABLED */ -/* #define HAL_SD_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ -#define HAL_PCD_MODULE_ENABLED -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_EXTI_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)40000) -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature. */ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) - -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver -* Activated: CRC code is present inside driver -* Deactivated: CRC code cleaned from driver -*/ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED - #include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED - #include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED - #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED - #include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED - #include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED - #include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED - #include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED - #include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED - #include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/board.c b/ports/stm32f4/boards/stm32f411ce_blackpill/board.c deleted file mode 100644 index 82b0c506ed..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/board.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "boards/board.h" -#include "mpconfigboard.h" - -void board_init(void) { -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { - -} diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h deleted file mode 100644 index 67ddc885ae..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" -#define MICROPY_HW_MCU_NAME "STM32F405RG" - -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (0x4000) - -#define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) - -// On-board flash -#define SPI_FLASH_MOSI_PIN &pin_PB05 -#define SPI_FLASH_MISO_PIN &pin_PB04 -#define SPI_FLASH_SCK_PIN &pin_PB03 -#define SPI_FLASH_CS_PIN &pin_PA15 - -#define DEFAULT_I2C_BUS_SCL (&pin_PB06) -#define DEFAULT_I2C_BUS_SDA (&pin_PB07) - -#define DEFAULT_SPI_BUS_SCK (&pin_PB13) -#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) -#define DEFAULT_SPI_BUS_MISO (&pin_PB14) - -#define DEFAULT_UART_BUS_RX (&pin_PB11) -#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk deleted file mode 100644 index 5bad4e81f3..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk +++ /dev/null @@ -1,19 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x805A -USB_PRODUCT = "Feather STM32F405 Express" -USB_MANUFACTURER = "Adafruit Industries LLC" -USB_DEVICES = "CDC,MSC" - -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = GD25Q16C -LONGINT_IMPL = MPZ - -MCU_SERIES = m4 -MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f405xx -MCU_PACKAGE = 64 -CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c deleted file mode 100644 index 4aa1f362ad..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, - - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, - - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, - - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, - - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, - - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h deleted file mode 100644 index 68a49b4ba8..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h +++ /dev/null @@ -1,440 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf_template.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32f4xx_hal_conf.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_H -#define __STM32F4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED - -#define HAL_ADC_MODULE_ENABLED -/* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CRC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ -#define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ -#define HAL_I2C_MODULE_ENABLED -#define HAL_I2S_MODULE_ENABLED -/* #define HAL_IWDG_MODULE_ENABLED */ -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_RNG_MODULE_ENABLED */ -/* #define HAL_RTC_MODULE_ENABLED */ -/* #define HAL_SAI_MODULE_ENABLED */ -/* #define HAL_SD_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ -#define HAL_PCD_MODULE_ENABLED -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_EXTI_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)40000) -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature. */ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) - -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver -* Activated: CRC code is present inside driver -* Deactivated: CRC code cleaned from driver -*/ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED - #include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED - #include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED - #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED - #include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED - #include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED - #include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED - #include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED - #include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED - #include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 60f399395a4439cbff865b9dc62f41e9ad93b9f9 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 9 Dec 2019 18:30:24 -0500 Subject: [PATCH 151/531] Add POWER_SWITCH pin to CPB --- .../nrf/boards/circuitplayground_bluefruit/board.c | 14 +++++++++++++- .../circuitplayground_bluefruit/mpconfigboard.h | 3 +++ .../nrf/boards/circuitplayground_bluefruit/pins.c | 6 +++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ports/nrf/boards/circuitplayground_bluefruit/board.c b/ports/nrf/boards/circuitplayground_bluefruit/board.c index 4421970eef..7c8ec8e9a2 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/board.c +++ b/ports/nrf/boards/circuitplayground_bluefruit/board.c @@ -25,6 +25,11 @@ */ #include "boards/board.h" +#include "mpconfigboard.h" +#include "py/obj.h" +#include "peripherals/nrf/pins.h" + +#include "nrf_gpio.h" void board_init(void) { } @@ -34,5 +39,12 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - + // Turn off board.POWER_SWITCH (power-saving switch) on each soft reload, to prevent confusion. + nrf_gpio_cfg(POWER_SWITCH_PIN->number, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); + nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false); } diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index 4e37eae0aa..21ba3a976b 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -54,6 +54,9 @@ #define SPI_FLASH_CS_PIN &pin_P0_15 #endif +// Disables onboard peripherals and neopixels to save power. +#define POWER_SWITCH_PIN (&pin_P0_06) + #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) diff --git a/ports/nrf/boards/circuitplayground_bluefruit/pins.c b/ports/nrf/boards/circuitplayground_bluefruit/pins.c index e8e5f4110d..d0d9659db7 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/pins.c +++ b/ports/nrf/boards/circuitplayground_bluefruit/pins.c @@ -48,8 +48,12 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_P1_06) }, { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_06) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) }, + // If high, turns off NeoPixels, LIS3DH, sound sensor, light sensor, temp sensor. + { MP_ROM_QSTR(MP_QSTR_POWER_SWITCH), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_13) }, { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_13) }, From 0712c9522517dad0c6684c612f0c9e8e651284d1 Mon Sep 17 00:00:00 2001 From: iot49 Date: Mon, 9 Dec 2019 23:14:26 -0800 Subject: [PATCH 152/531] fix mtime on file creation --- ports/nrf/fatfs_port.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ports/nrf/fatfs_port.c b/ports/nrf/fatfs_port.c index 13ac21fb1b..83698fd19c 100644 --- a/ports/nrf/fatfs_port.c +++ b/ports/nrf/fatfs_port.c @@ -26,8 +26,18 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" +#include "lib/timeutils/timeutils.h" + +extern void common_hal_rtc_get_time(timeutils_struct_time_t *tm); +extern void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm); DWORD get_fattime(void) { - // TODO: Implement this function. For now, fake it. - return ((2016 - 1980) << 25) | ((12) << 21) | ((4) << 16) | ((00) << 11) | ((18) << 5) | (23 / 2); +#if CIRCUITPY_RTC + timeutils_struct_time_t tm; + common_hal_rtc_get_time(&tm); + return ((tm.tm_year - 1980) << 25) | (tm.tm_mon << 21) | (tm.tm_mday << 16) | + (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec >> 1); +#else + return ((2016 - 1980) << 25) | ((9) << 21) | ((1) << 16) | ((16) << 11) | ((43) << 5) | (35 / 2); +#endif } From e328e9c1063a42f1605d29a043063e16b74a7a32 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 10 Dec 2019 15:02:38 -0500 Subject: [PATCH 153/531] minor text changes --- ports/stm32f4/boards/meowbit_v121/pins.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 4aa1f362ad..169fbf2744 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -2,29 +2,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, - - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, - - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, - - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, { 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 a484a93b290806d01850e58905d65bc798b4cd91 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 29 Nov 2019 08:15:29 -0600 Subject: [PATCH 154/531] nRF: disk_read must be 4-byte aligned .. a requirement that oofatfs needs to be taught to respect. This problem can be demonstrated with the following snippet, except that the related file ("test.bin") must also be contiguous on the filesystem. You can ensure this by reformatting your device's filesystem before testing, then copying any single file bigger than 4kB to test.bin. f = open("test.bin", "rb") f.seek(2048) b = bytearray(2048) v = memoryview(b) f.readinto(v[909:]) Closes: #2332 --- lib/oofatfs/ff.c | 6 +++++- lib/oofatfs/ffconf.h | 6 ++++++ ports/nrf/Makefile | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/oofatfs/ff.c b/lib/oofatfs/ff.c index b0984756bf..71bd19702a 100644 --- a/lib/oofatfs/ff.c +++ b/lib/oofatfs/ff.c @@ -3382,7 +3382,11 @@ FRESULT f_read ( if (!sect) ABORT(fs, FR_INT_ERR); sect += csect; cc = btr / SS(fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ + if (cc +#if _FS_DISK_READ_ALIGNED + && (((int)rbuff & 3) == 0) +#endif + ) {/* Read maximum contiguous sectors directly */ if (csect + cc > fs->csize) { /* Clip at cluster boundary */ cc = fs->csize - csect; } diff --git a/lib/oofatfs/ffconf.h b/lib/oofatfs/ffconf.h index 214311b4c2..a3795fa3fe 100644 --- a/lib/oofatfs/ffconf.h +++ b/lib/oofatfs/ffconf.h @@ -343,6 +343,12 @@ / SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be / included somewhere in the scope of ff.h. */ +// Set to nonzero if buffers passed to disk_read have a word alignment +// restriction +#ifndef _FS_DISK_READ_ALIGNED +#define _FS_DISK_READ_ALIGNED 0 +#endif + /* #include // O/S definitions */ diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index be8a71b3f3..096dfaa4bf 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -106,6 +106,7 @@ CFLAGS += -Wno-undef CFLAGS += -Wno-cast-align NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET +NRF_DEFINES += -D_FS_DISK_READ_ALIGNED=1 CFLAGS += $(NRF_DEFINES) CFLAGS += \ From a08d9e6d8e0059c8aa59feadd7b94d95d691e273 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Nov 2019 09:29:55 -0600 Subject: [PATCH 155/531] audiocore: Add MP3File using Adafruit_MP3 library --- .gitmodules | 3 + lib/mp3 | 1 + locale/ID.po | 22 +- locale/circuitpython.pot | 22 +- locale/de_DE.po | 18 +- locale/en_US.po | 22 +- locale/en_x_pirate.po | 22 +- locale/es.po | 18 +- locale/fil.po | 18 +- locale/fr.po | 18 +- locale/it_IT.po | 18 +- locale/ko.po | 22 +- locale/pl.po | 18 +- locale/pt_BR.po | 18 +- locale/zh_Latn_pinyin.po | 18 +- .../boards/kicksat-sprite/mpconfigboard.mk | 1 + ports/atmel-samd/mpconfigport.mk | 4 + py/circuitpy_defns.mk | 25 ++ py/circuitpy_mpconfig.h | 8 + py/circuitpy_mpconfig.mk | 9 + shared-bindings/audiomp3/MP3File.c | 226 +++++++++++++++ shared-bindings/audiomp3/MP3File.h | 48 ++++ shared-bindings/audiomp3/__init__.c | 60 ++++ shared-bindings/audiomp3/__init__.h | 34 +++ shared-module/audiomp3/MP3File.c | 270 ++++++++++++++++++ shared-module/audiomp3/MP3File.h | 70 +++++ shared-module/audiomp3/__init__.c | 0 shared-module/audiomp3/__init__.h | 30 ++ 28 files changed, 1007 insertions(+), 36 deletions(-) create mode 160000 lib/mp3 create mode 100644 shared-bindings/audiomp3/MP3File.c create mode 100644 shared-bindings/audiomp3/MP3File.h create mode 100644 shared-bindings/audiomp3/__init__.c create mode 100644 shared-bindings/audiomp3/__init__.h create mode 100644 shared-module/audiomp3/MP3File.c create mode 100644 shared-module/audiomp3/MP3File.h create mode 100644 shared-module/audiomp3/__init__.c create mode 100644 shared-module/audiomp3/__init__.h diff --git a/.gitmodules b/.gitmodules index 764456cd65..98252c2afa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -102,3 +102,6 @@ [submodule "ports/cxd56/spresense-exported-sdk"] path = ports/cxd56/spresense-exported-sdk url = https://github.com/sonydevworld/spresense-exported-sdk.git +[submodule "lib/mp3"] + path = lib/mp3 + url = https://github.com/adafruit/Adafruit_MP3 diff --git a/lib/mp3 b/lib/mp3 new file mode 160000 index 0000000000..2a3cc7873b --- /dev/null +++ b/lib/mp3 @@ -0,0 +1 @@ +Subproject commit 2a3cc7873b5c642d4bb60043dc14d2555e3377a5 diff --git a/locale/ID.po b/locale/ID.po index 472c042c60..4be18ec0de 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -496,11 +496,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "Tidak dapat menginisialisasi UART" -#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -msgid "Couldn't allocate first buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate first buffer" +msgstr "" + +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "" @@ -613,6 +623,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1779,7 +1793,7 @@ msgstr "argumen keyword ekstra telah diberikan" msgid "extra positional arguments given" msgstr "argumen posisi ekstra telah diberikan" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 1541b1f74d..f007202071 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -486,11 +486,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -msgid "Couldn't allocate first buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate first buffer" +msgstr "" + +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "" @@ -602,6 +612,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1749,7 +1763,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index b34626ea1a..1756a7717e 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -490,11 +490,21 @@ msgstr "Beschädigter raw code" msgid "Could not initialize UART" msgstr "Konnte UART nicht initialisieren" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "Konnte first buffer nicht zuteilen" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "Konnte second buffer nicht zuteilen" @@ -606,6 +616,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "Verbindung nicht erfolgreich: timeout" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1798,7 +1812,7 @@ msgstr "Es wurden zusätzliche Keyword-Argumente angegeben" msgid "extra positional arguments given" msgstr "Es wurden zusätzliche Argumente ohne Keyword angegeben" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" diff --git a/locale/en_US.po b/locale/en_US.po index 95884c7b25..79940e95ed 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -486,11 +486,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -msgid "Couldn't allocate first buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate first buffer" +msgstr "" + +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "" @@ -602,6 +612,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1749,7 +1763,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index ed7d2cec72..9fe49ec9f1 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -490,11 +490,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -msgid "Couldn't allocate first buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate first buffer" +msgstr "" + +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "" @@ -606,6 +616,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1753,7 +1767,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/locale/es.po b/locale/es.po index fac38c0817..b5c375481c 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -494,11 +494,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "No se puede inicializar la UART" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "No se pudo asignar el primer buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "No se pudo asignar el segundo buffer" @@ -610,6 +620,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1802,7 +1816,7 @@ msgstr "argumento(s) por palabra clave adicionales fueron dados" msgid "extra positional arguments given" msgstr "argumento posicional adicional dado" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "el archivo deberia ser una archivo abierto en modo byte" diff --git a/locale/fil.po b/locale/fil.po index 776002768d..ba20e69b81 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -495,11 +495,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "Hindi ma-initialize ang UART" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "Hindi ma-iallocate ang first buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "Hindi ma-iallocate ang second buffer" @@ -616,6 +626,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1810,7 +1824,7 @@ msgstr "dagdag na keyword argument na ibinigay" msgid "extra positional arguments given" msgstr "dagdag na positional argument na ibinigay" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "file ay dapat buksan sa byte mode" diff --git a/locale/fr.po b/locale/fr.po index 78d079bf12..e103cd06d2 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -501,11 +501,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "L'UART n'a pu être initialisé" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "Impossible d'allouer le 1er tampon" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "Impossible d'allouer le 2e tampon" @@ -620,6 +630,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1842,7 +1856,7 @@ msgstr "argument(s) nommé(s) supplémentaire(s) donné(s)" msgid "extra positional arguments given" msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "le fichier doit être un fichier ouvert en mode 'byte'" diff --git a/locale/it_IT.po b/locale/it_IT.po index 67585fe2fb..c1a445fa24 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -496,11 +496,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "Impossibile inizializzare l'UART" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "Impossibile allocare il primo buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "Impossibile allocare il secondo buffer" @@ -616,6 +626,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1803,7 +1817,7 @@ msgstr "argomento nominato aggiuntivo fornito" msgid "extra positional arguments given" msgstr "argomenti posizonali extra dati" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 0cf6747370..93a476b876 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -490,11 +490,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -msgid "Couldn't allocate first buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate first buffer" +msgstr "" + +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "" @@ -606,6 +616,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1754,7 +1768,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 0e33f3022c..8efab18675 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -489,11 +489,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "Ustawienie UART nie powiodło się" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "Nie udała się alokacja pierwszego bufora" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "Nie udała się alokacja drugiego bufora" @@ -605,6 +615,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1774,7 +1788,7 @@ msgstr "nadmiarowe argumenty nazwane" msgid "extra positional arguments given" msgstr "nadmiarowe argumenty pozycyjne" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "file musi być otwarte w trybie bajtowym" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index f1f707f63d..1ca6b7d9a5 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -492,11 +492,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "Não foi possível inicializar o UART" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "Não pôde alocar primeiro buffer" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "Não pôde alocar segundo buffer" @@ -611,6 +621,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1771,7 +1785,7 @@ msgstr "argumentos extras de palavras-chave passados" msgid "extra positional arguments given" msgstr "argumentos extra posicionais passados" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 6e49774b56..40966090d4 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-06 13:25-0600\n" +"POT-Creation-Date: 2019-12-10 13:55-0600\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -490,11 +490,21 @@ msgstr "Sǔnhuài de yuánshǐ dàimǎ" msgid "Could not initialize UART" msgstr "Wúfǎ chūshǐhuà UART" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate decoder" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate first buffer" msgstr "Wúfǎ fēnpèi dì yī gè huǎnchōng qū" +#: shared-module/audiomp3/MP3File.c +msgid "Couldn't allocate input buffer" +msgstr "" + #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3File.c msgid "Couldn't allocate second buffer" msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū" @@ -606,6 +616,10 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "Liánjiē shībài: Chāoshí" +#: shared-module/audiomp3/MP3File.c +msgid "Failed to parse MP3 file" +msgstr "" + #: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" @@ -1785,7 +1799,7 @@ msgstr "éwài de guānjiàn cí cānshù" msgid "extra positional arguments given" msgstr "gěi chūle éwài de wèizhì cānshù" -#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c #: shared-bindings/displayio/OnDiskBitmap.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" diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index 453be3b5ee..b9b88a368b 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -16,3 +16,4 @@ CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_NETWORK = 0 CIRCUITPY_PS2IO = 0 +CIRCUITPY_AUDIOMP3 = 0 diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index df108664ad..58bf07247c 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -21,6 +21,10 @@ ifndef CIRCUITPY_AUDIOMIXER CIRCUITPY_AUDIOMIXER = 0 endif +ifndef CIRCUITPY_AUDIOMP3 +CIRCUITPY_AUDIOMP3 = 0 +endif + ifndef CIRCUITPY_FREQUENCYIO CIRCUITPY_FREQUENCYIO = 0 endif diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 211e853689..446620d27b 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -117,6 +117,9 @@ endif ifeq ($(CIRCUITPY_AUDIOMIXER),1) SRC_PATTERNS += audiomixer/% endif +ifeq ($(CIRCUITPY_AUDIOMP3),1) +SRC_PATTERNS += audiomp3/% +endif ifeq ($(CIRCUITPY_BITBANGIO),1) SRC_PATTERNS += bitbangio/% endif @@ -319,6 +322,8 @@ SRC_SHARED_MODULE_ALL = \ audiomixer/__init__.c \ audiomixer/Mixer.c \ audiomixer/MixerVoice.c \ + audiomp3/__init__.c \ + audiomp3/MP3File.c \ bitbangio/I2C.c \ bitbangio/OneWire.c \ bitbangio/SPI.c \ @@ -371,6 +376,26 @@ SRC_SHARED_MODULE_ALL += \ touchio/TouchIn.c \ touchio/__init__.c endif +ifeq ($(CIRCUITPY_AUDIOMP3),1) +SRC_MOD += $(addprefix lib/mp3/src/, \ + bitstream.c \ + buffers.c \ + dct32.c \ + dequant.c \ + dqchan.c \ + huffman.c \ + hufftabs.c \ + imdct.c \ + mp3dec.c \ + mp3tabs.c \ + polyphase.c \ + scalfact.c \ + stproc.c \ + subband.c \ + trigtabs.c \ +) +$(BUILD)/lib/mp3/src/buffers.o: CFLAGS += -include "py/misc.h" -D'MPDEC_ALLOCATOR(x)=m_malloc(x,0)' -D'MPDEC_FREE(x)=m_free(x)' +endif # All possible sources are listed here, and are filtered by SRC_PATTERNS. SRC_SHARED_MODULE_INTERNAL = \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 000674c4f4..5ee5d52c07 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -252,6 +252,13 @@ extern const struct _mp_obj_module_t audiomixer_module; #define AUDIOMIXER_MODULE #endif +#if CIRCUITPY_AUDIOMP3 +#define AUDIOMP3_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiomp3), (mp_obj_t)&audiomp3_module }, +extern const struct _mp_obj_module_t audiomp3_module; +#else +#define AUDIOMP3_MODULE +#endif + #if CIRCUITPY_AUDIOPWMIO #define AUDIOPWMIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiopwmio), (mp_obj_t)&audiopwmio_module }, extern const struct _mp_obj_module_t audiopwmio_module; @@ -582,6 +589,7 @@ extern const struct _mp_obj_module_t ustack_module; AUDIOCORE_MODULE \ AUDIOIO_MODULE \ AUDIOMIXER_MODULE \ + AUDIOMP3_MODULE \ AUDIOPWMIO_MODULE \ BITBANGIO_MODULE \ BLEIO_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 241fa10175..c614ea06a0 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -104,6 +104,15 @@ CIRCUITPY_AUDIOMIXER = $(CIRCUITPY_AUDIOIO) endif CFLAGS += -DCIRCUITPY_AUDIOMIXER=$(CIRCUITPY_AUDIOMIXER) +ifndef CIRCUITPY_AUDIOMP3 +ifeq ($(CIRCUITPY_FULL_BUILD),1) +CIRCUITPY_AUDIOMP3 = $(CIRCUITPY_AUDIOCORE) +else +CIRCUITPY_AUDIOMP3 = 0 +endif +endif +CFLAGS += -DCIRCUITPY_AUDIOMP3=$(CIRCUITPY_AUDIOMP3) + ifndef CIRCUITPY_BITBANGIO CIRCUITPY_BITBANGIO = $(CIRCUITPY_FULL_BUILD) endif diff --git a/shared-bindings/audiomp3/MP3File.c b/shared-bindings/audiomp3/MP3File.c new file mode 100644 index 0000000000..f518bae4bb --- /dev/null +++ b/shared-bindings/audiomp3/MP3File.c @@ -0,0 +1,226 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2019 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 "lib/utils/context_manager_helpers.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/audiomp3/MP3File.h" +#include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" + +//| .. currentmodule:: audiomp3 +//| +//| :class:`MP3` -- Load a mp3 file for audio playback +//| ======================================================== +//| +//| A .mp3 file prepped for audio playback. Only mono and stereo files are supported. Samples must +//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating +//| an internal buffer. +//| +//| .. class:: MP3(file[, buffer]) +//| +//| Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//| +//| :param typing.BinaryIO file: Already opened mp3 file +//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. +//| +//| +//| Playing a mp3 file from flash:: +//| +//| import board +//| import audiomp3 +//| import audioio +//| import digitalio +//| +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) +//| +//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb") +//| mp3 = audiomp3.MP3File(data) +//| a = audioio.AudioOut(board.A0) +//| +//| print("playing") +//| a.play(mp3) +//| while a.playing: +//| pass +//| print("stopped") +//| +STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 1, 2, false); + + audiomp3_mp3file_obj_t *self = m_new_obj(audiomp3_mp3file_obj_t); + self->base.type = &audiomp3_mp3file_type; + if (!MP_OBJ_IS_TYPE(args[0], &mp_type_fileio)) { + mp_raise_TypeError(translate("file must be a file opened in byte mode")); + } + uint8_t *buffer = NULL; + size_t buffer_size = 0; + if (n_args >= 2) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); + buffer = bufinfo.buf; + buffer_size = bufinfo.len; + } + common_hal_audiomp3_mp3file_construct(self, MP_OBJ_TO_PTR(args[0]), + buffer, buffer_size); + + return MP_OBJ_FROM_PTR(self); +} + +//| .. method:: deinit() +//| +//| Deinitialises the MP3 and releases all memory resources for reuse. +//| +STATIC mp_obj_t audiomp3_mp3file_deinit(mp_obj_t self_in) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_audiomp3_mp3file_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_deinit_obj, audiomp3_mp3file_deinit); + +STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) { + if (common_hal_audiomp3_mp3file_deinited(self)) { + raise_deinited_error(); + } +} + +//| .. method:: __enter__() +//| +//| No-op used by Context Managers. +//| +// Provided by context manager helper. + +//| .. method:: __exit__() +//| +//| Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info. +//| +STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_audiomp3_mp3file_deinit(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__); + +//| .. attribute:: sample_rate +//| +//| 32 bit value that dictates how quickly samples are loaded into the DAC +//| in Hertz (cycles per second). When the sample is looped, this can change +//| the pitch output without changing the underlying sample. +//| +STATIC mp_obj_t audiomp3_mp3file_obj_get_sample_rate(mp_obj_t self_in) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_audiomp3_mp3file_get_sample_rate(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_sample_rate_obj, audiomp3_mp3file_obj_get_sample_rate); + +STATIC mp_obj_t audiomp3_mp3file_obj_set_sample_rate(mp_obj_t self_in, mp_obj_t sample_rate) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + common_hal_audiomp3_mp3file_set_sample_rate(self, mp_obj_get_int(sample_rate)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_sample_rate_obj, audiomp3_mp3file_obj_set_sample_rate); + +const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiomp3_mp3file_get_sample_rate_obj, + (mp_obj_t)&audiomp3_mp3file_set_sample_rate_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +//| .. attribute:: bits_per_sample +//| +//| Bits per sample. (read only) +//| +STATIC mp_obj_t audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_audiomp3_mp3file_get_bits_per_sample(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_bits_per_sample_obj, audiomp3_mp3file_obj_get_bits_per_sample); + +const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiomp3_mp3file_get_bits_per_sample_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +//| .. attribute:: channel_count +//| +//| Number of audio channels. (read only) +//| +STATIC mp_obj_t audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_audiomp3_mp3file_get_channel_count(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_channel_count_obj, audiomp3_mp3file_obj_get_channel_count); + +const mp_obj_property_t audiomp3_mp3file_channel_count_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiomp3_mp3file_get_channel_count_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + +STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { + // Methods + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiomp3_mp3file_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiomp3_mp3file___exit___obj) }, + + // Properties + { MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&audiomp3_mp3file_sample_rate_obj) }, + { MP_ROM_QSTR(MP_QSTR_bits_per_sample), MP_ROM_PTR(&audiomp3_mp3file_bits_per_sample_obj) }, + { MP_ROM_QSTR(MP_QSTR_channel_count), MP_ROM_PTR(&audiomp3_mp3file_channel_count_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(audiomp3_mp3file_locals_dict, audiomp3_mp3file_locals_dict_table); + +STATIC const audiosample_p_t audiomp3_mp3file_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) + .sample_rate = (audiosample_sample_rate_fun)common_hal_audiomp3_mp3file_get_sample_rate, + .bits_per_sample = (audiosample_bits_per_sample_fun)common_hal_audiomp3_mp3file_get_bits_per_sample, + .channel_count = (audiosample_channel_count_fun)common_hal_audiomp3_mp3file_get_channel_count, + .reset_buffer = (audiosample_reset_buffer_fun)audiomp3_mp3file_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)audiomp3_mp3file_get_buffer, + .get_buffer_structure = (audiosample_get_buffer_structure_fun)audiomp3_mp3file_get_buffer_structure, +}; + +const mp_obj_type_t audiomp3_mp3file_type = { + { &mp_type_type }, + .name = MP_QSTR_MP3File, + .make_new = audiomp3_mp3file_make_new, + .locals_dict = (mp_obj_dict_t*)&audiomp3_mp3file_locals_dict, + .protocol = &audiomp3_mp3file_proto, +}; diff --git a/shared-bindings/audiomp3/MP3File.h b/shared-bindings/audiomp3/MP3File.h new file mode 100644 index 0000000000..adc13ea2c0 --- /dev/null +++ b/shared-bindings/audiomp3/MP3File.h @@ -0,0 +1,48 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H + +#include "py/obj.h" +#include "extmod/vfs_fat.h" + +#include "shared-module/audiomp3/MP3File.h" + +extern const mp_obj_type_t audiomp3_mp3file_type; + +void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, + pyb_file_obj_t* file, uint8_t *buffer, size_t buffer_size); + +void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self); +bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t* self); +uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* self); +void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t* self, uint32_t sample_rate); +uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t* self); +uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t* self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c new file mode 100644 index 0000000000..06f852ff1c --- /dev/null +++ b/shared-bindings/audiomp3/__init__.c @@ -0,0 +1,60 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/audiomp3/MP3File.h" + +//| :mod:`audiomp3` --- Support for MP3-compressed audio files +//| ========================================================== +//| +//| .. module:: audiomp3 +//| :synopsis: Support for mp3 files +//| +//| The `audiomp3` module contains an mp3 decoder +//| +//| Libraries +//| +//| .. toctree:: +//| :maxdepth: 3 +//| +//| MP3File +//| + +STATIC const mp_rom_map_elem_t audiomp3_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiomp3) }, + { MP_ROM_QSTR(MP_QSTR_MP3File), MP_ROM_PTR(&audiomp3_mp3file_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(audiomp3_module_globals, audiomp3_module_globals_table); + +const mp_obj_module_t audiomp3_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&audiomp3_module_globals, +}; diff --git a/shared-bindings/audiomp3/__init__.h b/shared-bindings/audiomp3/__init__.h new file mode 100644 index 0000000000..9026af6368 --- /dev/null +++ b/shared-bindings/audiomp3/__init__.h @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMP3___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMP3___INIT___H + +#include "py/obj.h" + +// Nothing now. + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMP3___INIT___H diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c new file mode 100644 index 0000000000..cabb461056 --- /dev/null +++ b/shared-module/audiomp3/MP3File.c @@ -0,0 +1,270 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/audiomp3/MP3File.h" + +#include +#include + +#include "py/mperrno.h" +#include "py/runtime.h" + +#include "shared-module/audiomp3/MP3File.h" +#include "supervisor/shared/translate.h" +#include "lib/mp3/src/mp3common.h" + +/** Fill the input buffer if it is less than half full. + * + * Returns true if the input buffer contains any useful data, + * false otherwise. (The input buffer will be padded to the end with + * 0 bytes, which do not interfere with MP3 decoding) + * + * Raises OSError if f_read fails. + * + * Sets self->eof if any read of the file returns 0 bytes + */ +STATIC bool mp3file_update_inbuf(audiomp3_mp3file_obj_t* self) { + // If buffer is over half full, do nothing + if (self->inbuf_offset < self->inbuf_length/2) return true; + + // If we didn't previously reach the end of file, we can try reading now + if (!self->eof) { + + // Move the unconsumed portion of the buffer to the start + uint8_t *end_of_buffer = self->inbuf + self->inbuf_length; + uint8_t *new_end_of_data = self->inbuf + self->inbuf_length - self->inbuf_offset; + memmove(self->inbuf, self->inbuf + self->inbuf_offset, + self->inbuf_length - self->inbuf_offset); + self->inbuf_offset = 0; + + UINT to_read = end_of_buffer - new_end_of_data; + UINT bytes_read = 0; + memset(new_end_of_data, 0, to_read); + if (f_read(&self->file->fp, new_end_of_data, to_read, &bytes_read) != FR_OK) { + self->eof = true; + mp_raise_OSError(MP_EIO); + } + + if (bytes_read == 0) { + self->eof = true; + } + + if (to_read != bytes_read) { + new_end_of_data += bytes_read; + memset(new_end_of_data, 0, end_of_buffer - new_end_of_data); + } + + } + + // Return true iff there are at least some useful bytes in the buffer + return self->inbuf_offset < self->inbuf_length; +} + +#define READ_PTR(self) (self->inbuf + self->inbuf_offset) +#define BYTES_LEFT(self) (self->inbuf_length - self->inbuf_offset) +#define CONSUME(self, n) (self->inbuf_offset += n) + +/* If a sync word can be found, advance to it and return true. Otherwise, + * return false. + */ +STATIC bool mp3file_find_sync_word(audiomp3_mp3file_obj_t* self) { + do { + mp3file_update_inbuf(self); + int offset = MP3FindSyncWord(READ_PTR(self), BYTES_LEFT(self)); + if (offset >= 0) { + CONSUME(self, offset); + mp3file_update_inbuf(self); + return true; + } + CONSUME(self, MAX(0, BYTES_LEFT(self) - 16)); + } while (!self->eof); + return false; +} + +STATIC bool mp3file_get_next_frame_info(audiomp3_mp3file_obj_t* self, MP3FrameInfo* fi) { + int err = MP3GetNextFrameInfo(self->decoder, fi, READ_PTR(self)); + return err == ERR_MP3_NONE; +} + +void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, + pyb_file_obj_t* file, + uint8_t *buffer, + size_t buffer_size) { + // XXX Adafruit_MP3 uses a 2kB input buffer and two 4kB output buffers. + // for a whopping total of 10kB buffers (+mp3 decoder state and frame buffer) + // At 44kHz, that's 23ms of output audio data. + // + // We will choose a slightly different allocation strategy for the output: + // Make sure the buffers are sized exactly to match (a multiple of) the + // frame size; this is typically 2304 * 2 bytes, so a little bit bigger + // than the two 4kB output buffers, except that the alignment allows to + // never allocate that extra frame buffer. + + self->file = file; + self->inbuf_length = 2048; + self->inbuf_offset = self->inbuf_length; + self->inbuf = m_malloc(self->inbuf_length, false); + if (self->inbuf == NULL) { + common_hal_audiomp3_mp3file_deinit(self); + mp_raise_msg(&mp_type_MemoryError, + translate("Couldn't allocate input buffer")); + } + self->decoder = MP3InitDecoder(); + if (self->decoder == NULL) { + common_hal_audiomp3_mp3file_deinit(self); + mp_raise_msg(&mp_type_MemoryError, + translate("Couldn't allocate decoder")); + } + + mp3file_find_sync_word(self); + MP3FrameInfo fi; + if(!mp3file_get_next_frame_info(self, &fi)) { + mp_raise_msg(&mp_type_RuntimeError, + translate("Failed to parse MP3 file")); + } + + self->sample_rate = fi.samprate; + self->channel_count = fi.nChans; + self->frame_buffer_size = fi.outputSamps*sizeof(int16_t); + + if (buffer_size >= 2 * self->frame_buffer_size) { + self->len = buffer_size / 2 / self->frame_buffer_size * self->frame_buffer_size; + self->buffers[0] = buffer; + self->buffers[1] = buffer + self->len; + } else { + self->len = 2 * self->frame_buffer_size; + self->buffers[0] = m_malloc(self->len, false); + if (self->buffers[0] == NULL) { + common_hal_audiomp3_mp3file_deinit(self); + mp_raise_msg(&mp_type_MemoryError, + translate("Couldn't allocate first buffer")); + } + + self->buffers[1] = m_malloc(self->len, false); + if (self->buffers[1] == NULL) { + common_hal_audiomp3_mp3file_deinit(self); + mp_raise_msg(&mp_type_MemoryError, + translate("Couldn't allocate second buffer")); + } + } +} + +void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self) { + MP3FreeDecoder(self->decoder); + self->decoder = NULL; + self->inbuf = NULL; + self->buffers[0] = NULL; + self->buffers[1] = NULL; + self->file = NULL; +} + +bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t* self) { + return self->buffers[0] == NULL; +} + +uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* self) { + return self->sample_rate; +} + +void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t* self, + uint32_t sample_rate) { + self->sample_rate = sample_rate; +} + +uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t* self) { + return 16; +} + +uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t* self) { + return self->channel_count; +} + +bool audiomp3_mp3file_samples_signed(audiomp3_mp3file_obj_t* self) { + return true; +} + +void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t* self, + bool single_channel, + uint8_t channel) { + if (single_channel && channel == 1) { + return; + } + // We don't reset the buffer index in case we're looping and we have an odd number of buffer + // loads + f_lseek(&self->file->fp, 0); + self->inbuf_offset = self->inbuf_length; + self->eof = 0; + mp3file_update_inbuf(self); + mp3file_find_sync_word(self); +} + +audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* self, + bool single_channel, + uint8_t channel, + uint8_t** bufptr, + uint32_t* buffer_length) { + if (!single_channel) { + channel = 0; + } + + uint16_t channel_read_count = self->channel_read_count[channel]++; + bool need_more_data = self->read_count++ == channel_read_count; + + *bufptr = self->buffers[self->buffer_index] + channel; + *buffer_length = self->frame_buffer_size; + + if (need_more_data) { + self->buffer_index = !self->buffer_index; + int16_t *buffer = (int16_t *)(void *)self->buffers[self->buffer_index]; + + if (!mp3file_find_sync_word(self)) { + return self->eof ? GET_BUFFER_DONE : GET_BUFFER_ERROR; + } + int bytes_left = BYTES_LEFT(self); + uint8_t *inbuf = READ_PTR(self); + int err = MP3Decode(self->decoder, &inbuf, &bytes_left, buffer, 0); + CONSUME(self, BYTES_LEFT(self) - bytes_left); + if (err) { + return GET_BUFFER_DONE; + } + } + + return GET_BUFFER_MORE_DATA; +} + +void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t* self, bool single_channel, + bool* single_buffer, bool* samples_signed, + uint32_t* max_buffer_length, uint8_t* spacing) { + *single_buffer = false; + *samples_signed = true; + *max_buffer_length = self->frame_buffer_size; + if (single_channel) { + *spacing = self->channel_count; + } else { + *spacing = 1; + } +} diff --git a/shared-module/audiomp3/MP3File.h b/shared-module/audiomp3/MP3File.h new file mode 100644 index 0000000000..12649ac1ad --- /dev/null +++ b/shared-module/audiomp3/MP3File.h @@ -0,0 +1,70 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H +#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H + +#include "extmod/vfs_fat.h" +#include "py/obj.h" + +#include "shared-module/audiocore/__init__.h" + +typedef struct { + mp_obj_base_t base; + struct _MP3DecInfo *decoder; + uint8_t* inbuf; + uint32_t inbuf_length; + uint32_t inbuf_offset; + uint8_t* buffers[2]; + uint32_t len; + uint32_t frame_buffer_size; + + uint32_t sample_rate; + pyb_file_obj_t* file; + + uint8_t buffer_index; + uint8_t channel_count; + bool eof; + + uint16_t read_count; + uint16_t channel_read_count[2]; +} audiomp3_mp3file_obj_t; + +// These are not available from Python because it may be called in an interrupt. +void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t* self, + bool single_channel, + uint8_t channel); +audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* self, + bool single_channel, + uint8_t channel, + uint8_t** buffer, + uint32_t* buffer_length); // length in bytes +void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t* self, bool single_channel, + bool* single_buffer, bool* samples_signed, + uint32_t* max_buffer_length, uint8_t* spacing); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H diff --git a/shared-module/audiomp3/__init__.c b/shared-module/audiomp3/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/audiomp3/__init__.h b/shared-module/audiomp3/__init__.h new file mode 100644 index 0000000000..e7b1f3aab5 --- /dev/null +++ b/shared-module/audiomp3/__init__.h @@ -0,0 +1,30 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOMP3__INIT__H +#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOMP3__INIT__H + +#endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOMP3__INIT__H From 0e2a03e3bd0f43a07700a673d54552cb53561e92 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 10 Dec 2019 15:07:39 -0500 Subject: [PATCH 156/531] revert usb.c additions --- .../boards/stm32f411ce_blackpill/mpconfigboard.h | 1 - ports/stm32f4/supervisor/usb.c | 14 +------------- supervisor/shared/usb/usb.c | 7 ------- supervisor/usb.h | 2 -- 4 files changed, 1 insertion(+), 23 deletions(-) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index b8e374f05b..a438b5baa6 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,7 +33,6 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 -#define BOARD_NO_VBUS // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index e3baf1412b..95db0aafc2 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -43,7 +43,6 @@ void init_usb_hardware(void) { PA11 ------> USB_OTG_FS_DM PA12 ------> USB_OTG_FS_DP */ - __HAL_RCC_GPIOA_CLK_ENABLE(); /* Configure DM DP Pins */ @@ -59,7 +58,7 @@ void init_usb_hardware(void) { /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 9); @@ -84,14 +83,3 @@ void init_usb_hardware(void) { /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); } - -void disable_usb_vbus(void) { - -#ifdef USB_OTG_GCCFG_VBDEN - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; -#else - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; -#endif -} diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index fca08b4eed..c1d70c5b0f 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -33,8 +33,6 @@ #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" -#include "py/mpconfig.h" - #include "tusb.h" // Serial number as hex characters. This writes directly to the USB @@ -74,11 +72,6 @@ void usb_init(void) { #if CIRCUITPY_USB_MIDI usb_midi_init(); #endif - -#ifdef BOARD_NO_VBUS - disable_usb_vbus(); -#endif - } void usb_background(void) { diff --git a/supervisor/usb.h b/supervisor/usb.h index 6b4082b6f8..c87540d408 100644 --- a/supervisor/usb.h +++ b/supervisor/usb.h @@ -37,8 +37,6 @@ void usb_background(void); // TinyUSB. void init_usb_hardware(void); -void disable_usb_vbus(void); - // Shared implementation. bool usb_enabled(void); void usb_init(void); From 33233934e9be4fee31b6b8412234279ebb7d9ef3 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 10 Dec 2019 15:13:11 -0500 Subject: [PATCH 157/531] text fix --- ports/stm32f4/supervisor/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 95db0aafc2..f327050f58 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -58,7 +58,7 @@ void init_usb_hardware(void) { /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 9); From b22fbcd77da8c9724ed08228b89cfea53afdd5b6 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 10 Dec 2019 15:11:10 -0600 Subject: [PATCH 158/531] supervisor: external_flash: don't call m_malloc_maybe when it's bad --- supervisor/shared/external_flash/external_flash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 99df553e19..e7d86240b4 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -324,6 +324,10 @@ static bool allocate_ram_cache(void) { return true; } + if (MP_STATE_MEM(gc_pool_start) == 0) { + return false; + } + MP_STATE_VM(flash_ram_cache) = m_malloc_maybe(blocks_per_sector * pages_per_block * sizeof(uint32_t), false); if (MP_STATE_VM(flash_ram_cache) == NULL) { return false; From f4a5c17b5e79cf9bd02be248620d445065891a25 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 10 Dec 2019 17:05:37 -0600 Subject: [PATCH 159/531] supervisor: external_flash: don't call m_free when it's bad It's extremely dubious that we have these handles that we think are to GC'd memory at a time when the gc pool may not be initialized. Hopefully, they WERE valid GC memory and are undisturbed by the teardown of the interpreter that can lead to this state. In this case, don't try to m_free them, the memory will become free when the GC heap is reinitialized. Closes: #2338 (together with previous commit) --- supervisor/shared/external_flash/external_flash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index e7d86240b4..9d38c07d89 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -371,7 +371,7 @@ static void release_ram_cache(void) { if (supervisor_cache != NULL) { free_memory(supervisor_cache); supervisor_cache = NULL; - } else { + } else if (MP_STATE_MEM(gc_pool_start)) { m_free(MP_STATE_VM(flash_ram_cache)); } MP_STATE_VM(flash_ram_cache) = NULL; @@ -419,7 +419,7 @@ static bool flush_ram_cache(bool keep_cache) { write_flash(current_sector + (i * pages_per_block + j) * SPI_FLASH_PAGE_SIZE, MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j], SPI_FLASH_PAGE_SIZE); - if (!keep_cache && supervisor_cache == NULL) { + if (!keep_cache && supervisor_cache == NULL && MP_STATE_MEM(gc_pool_start)) { m_free(MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j]); } } From 6305d489475f0eb91b0fba59fd93fc72191a28eb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 10 Dec 2019 17:05:47 -0600 Subject: [PATCH 160/531] gc_free: give a better error when freeing outside of VM --- py/gc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/gc.c b/py/gc.c index a8a5fde125..5e631f5ed8 100755 --- a/py/gc.c +++ b/py/gc.c @@ -667,6 +667,9 @@ void gc_free(void *ptr) { if (ptr == NULL) { GC_EXIT(); } else { + if (MP_STATE_MEM(gc_pool_start) == 0) { + reset_into_safe_mode(GC_ALLOC_OUTSIDE_VM); + } // get the GC block number corresponding to this pointer assert(VERIFY_PTR(ptr)); size_t block = BLOCK_FROM_PTR(ptr); From 013c84086288141696e4c09250c61b6f2dbdf4d2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 10 Dec 2019 17:57:17 -0500 Subject: [PATCH 161/531] working on all ports --- ports/atmel-samd/Makefile | 15 +--- ports/atmel-samd/boards/common.template.ld | 4 +- ports/atmel-samd/mpconfigport.h | 47 +++++++++--- ports/atmel-samd/peripherals | 2 +- ports/cxd56/boards/spresense/mpconfigboard.mk | 2 + ports/nrf/Makefile | 34 +++------ .../mpconfigboard.h | 3 - ports/nrf/boards/common.template.ld | 8 +- .../feather_nrf52840_express/mpconfigboard.h | 3 - .../mpconfigboard.h | 3 - .../metro_nrf52840_express/mpconfigboard.h | 3 - ports/nrf/boards/pca10059/mpconfigboard.mk | 2 +- ports/nrf/ld_defines.c | 39 ++++++++++ ports/nrf/mpconfigport.h | 76 +++++++++++++++---- ports/nrf/mpconfigport.mk | 2 +- ports/nrf/supervisor/internal_flash.c | 8 +- py/circuitpy_defns.mk | 12 +++ supervisor/supervisor.mk | 6 +- tools/build_memory_info.py | 20 +++-- 19 files changed, 189 insertions(+), 100 deletions(-) create mode 100644 ports/nrf/ld_defines.c diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 32517c8016..83fd879aad 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -157,7 +157,7 @@ endif -LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs +LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LIBS := -lgcc -lc # Use toolchain libm if we're not using our own. @@ -324,19 +324,10 @@ SRC_QSTR_PREPROCESSOR += peripherals/samd/$(CHIP_FAMILY)/clocks.c all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 -LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLATE_FILE))) - -# ld_defines.pp is generated from ld_defines.c. See py/mkrules.mk. -# Run gen_ld_files.py over ALL *.template.ld files, not just LD_TEMPLATE_FILE, -# because it may include other template files. -$(LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld - $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld - -$(BUILD)/firmware.elf: $(OBJ) $(LD_FILE) +$(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE) $(STEPECHO) "LINK $@" $(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group - $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE) + $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" diff --git a/ports/atmel-samd/boards/common.template.ld b/ports/atmel-samd/boards/common.template.ld index 4c537e0016..1054605c8c 100644 --- a/ports/atmel-samd/boards/common.template.ld +++ b/ports/atmel-samd/boards/common.template.ld @@ -6,9 +6,9 @@ MEMORY FLASH_BOOTLOADER (rx): ORIGIN = ${BOOTLOADER_START_ADDR}, LENGTH = ${BOOTLOADER_SIZE} FLASH_FIRMWARE (rx) : ORIGIN = ${CIRCUITPY_FIRMWARE_START_ADDR}, LENGTH = ${CIRCUITPY_FIRMWARE_SIZE} - FLASH_NVM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_NVM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_NVM_SIZE} - FLASH_CONFIG (r) : ORIGIN = ${CIRCUITPY_INTERNAL_CONFIG_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_CONFIG_SIZE} FLASH_FILESYSTEM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE} + FLASH_CONFIG (r) : ORIGIN = ${CIRCUITPY_INTERNAL_CONFIG_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_CONFIG_SIZE} + FLASH_NVM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_NVM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_NVM_SIZE} RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE} } diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index ecb9621945..6ab95c8a5a 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -81,12 +81,12 @@ #endif // If CIRCUITPY is internal, use half of flash for it. -#ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE - #if INTERNAL_FLASH_FILESYSTEM - #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2) - #else - #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) +#if INTERNAL_FLASH_FILESYSTEM + #ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2) #endif +#else + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) #endif // HSRAM_SIZE is defined in the ASF4 include files for each SAMD51 chip. @@ -135,9 +135,9 @@ // // bootloader (8 or 16kB) // firmware +// internal CIRCUITPY flash filesystem (optional) // internal config, used to store crystalless clock calibration info (optional) // microntroller.nvm (optional) -// internal CIRCUITPY flash filesystem (optional) // Define these regions starting up from the bottom of flash: @@ -147,18 +147,43 @@ // Define these regions start down from the top of flash: -#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR \ - (FLASH_SIZE - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE) - #define CIRCUITPY_INTERNAL_NVM_START_ADDR \ - (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_INTERNAL_NVM_SIZE) + (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE) #define CIRCUITPY_INTERNAL_CONFIG_START_ADDR \ (CIRCUITPY_INTERNAL_NVM_START_ADDR - CIRCUITPY_INTERNAL_CONFIG_SIZE) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR \ + (CIRCUITPY_INTERNAL_CONFIG_START_ADDR - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE) + // The firmware space is the space left over between the fixed lower and upper regions. #define CIRCUITPY_FIRMWARE_SIZE \ - (CIRCUITPY_INTERNAL_CONFIG_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR) + (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR) + +#if BOOTLOADER_START_ADDR % FLASH_PAGE_SIZE != 0 +#error BOOTLOADER_START_ADDR must be on a flash page boundary. +#endif + +#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash page boundary. +#endif +#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#endif + +#if CIRCUITPY_INTERNAL_CONFIG_START_ADDR % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be on a flash page boundary. +#endif +#if CIRCUITPY_INTERNAL_CONFIG_SIZE % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be a multiple of FLASH_PAGE_SIZE. +#endif + +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash page boundary. +#endif +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#endif #if CIRCUITPY_FIRMWARE_SIZE < 0 #error No space left in flash for firmware after specifying other regions! diff --git a/ports/atmel-samd/peripherals b/ports/atmel-samd/peripherals index bb26a4145c..4c0deecf88 160000 --- a/ports/atmel-samd/peripherals +++ b/ports/atmel-samd/peripherals @@ -1 +1 @@ -Subproject commit bb26a4145c86a51debc6571bb1f791e0d4fd296b +Subproject commit 4c0deecf889da0074c1dbc9a5e2d24cb7c7a31c6 diff --git a/ports/cxd56/boards/spresense/mpconfigboard.mk b/ports/cxd56/boards/spresense/mpconfigboard.mk index a2d4e5d88c..7b8ac6ff63 100644 --- a/ports/cxd56/boards/spresense/mpconfigboard.mk +++ b/ports/cxd56/boards/spresense/mpconfigboard.mk @@ -2,3 +2,5 @@ USB_VID = 0x054c USB_PID = 0x0bc2 USB_PRODUCT = "Spresense" USB_MANUFACTURER = "Sony" + +INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index b96b8affb3..e7af13a735 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -63,8 +63,6 @@ ifneq ($(SD), ) include bluetooth/bluetooth_common.mk endif -FROZEN_MPY_DIR = freeze - CROSS_COMPILE = arm-none-eabi- FATFS_DIR = lib/oofatfs @@ -92,7 +90,7 @@ INC += -I../../supervisor/shared/usb ifeq ($(DEBUG), 1) CFLAGS += -ggdb3 -Og else - CFLAGS += -Os -DNDEBUG + CFLAGS += -Os -DNDEBUG -ggdb3 CFLAGS += -flto -flto-partition=none endif @@ -118,7 +116,7 @@ CFLAGS += \ # TODO: check this CFLAGS += -D__START=main -LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs +LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LIBS := -lgcc -lc LDFLAGS += -mthumb -mcpu=cortex-m4 @@ -193,15 +191,16 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) $(addprefix shared-module/, $(SRC_SHARED_MODULE)) \ $(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL)) -SRC_S = supervisor/cpu.s +# There may be duplicates between SRC_COMMON_HAL_EXPANDED and SRC_SHARED_MODULE_EXPANDED, +# because a few modules have files both in common-hal/ and shared-modules/. +# Doing a $(sort ...) removes duplicates as part of sorting. +SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)) -FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py') -FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy)) +SRC_S = supervisor/cpu.s OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o)) -OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o)) -OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o)) ifeq ($(INTERNAL_LIBM),1) OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o)) endif @@ -219,19 +218,10 @@ SRC_QSTR_PREPROCESSOR += all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 -LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLATE_FILE))) - -# ld_defines.pp is generated from ld_defines.c. See py/mkrules.mk. -# Run gen_ld_files.py over ALL *.template.ld files, not just LD_TEMPLATE_FILE, -# because it may include other template files. -$(LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld - $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld - -$(BUILD)/firmware.elf: $(OBJ) +$(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE) $(STEPECHO) "LINK $@" - $(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group - $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE) + $(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" @@ -273,7 +263,7 @@ else ifeq ($(FLASHER), pyocd) flash: $(BUILD)/firmware.hex pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase - #pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR) +# pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR) pyocd-tool -t $(MCU_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001 pyocd-tool -t $(MCU_VARIANT) reset diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index 7ca9b12aee..5abb868204 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -30,9 +30,6 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Circuit Playground Bluefruit" #define MICROPY_HW_MCU_NAME "nRF52840" -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (4096) - #define MICROPY_HW_LED_STATUS (&pin_P1_14) // Unusually, board does not have a 32 kHz xtal. Nearly all boards do. diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index 9fd066de10..f267234924 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -9,11 +9,11 @@ MEMORY /* nRF SoftDevice */ FLASH_MBR (rx) : ORIGIN = ${MBR_START_ADDR}, LENGTH = ${MBR_SIZE} FLASH_SD (rx) : ORIGIN = ${SD_FLASH_START_ADDR}, LENGTH = ${SD_FLASH_SIZE} - FLASH_ISR (rx) : ORIGIN = ${CIRCUITPY_ISR_START_ADDR}, LENGTH = ${CIRCUITPY_ISR_LENGTH} + FLASH_ISR (rx) : ORIGIN = ${ISR_START_ADDR}, LENGTH = ${ISR_SIZE} FLASH_FIRMWARE (rx) : ORIGIN = ${CIRCUITPY_FIRMWARE_START_ADDR}, LENGTH = ${CIRCUITPY_FIRMWARE_SIZE} + FLASH_FATFS (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE} FLASH_BLE_CONFIG (r) : ORIGIN = ${CIRCUITPY_BLE_CONFIG_START_ADDR}, LENGTH = ${CIRCUITPY_BLE_CONFIG_SIZE} FLASH_NVM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_NVM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_NVM_SIZE} - FLASH_FATFS (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE} FLASH_BOOTLOADER (rx) : ORIGIN = ${BOOTLOADER_START_ADDR}, LENGTH = ${BOOTLOADER_SIZE} FLASH_BOOTLOADER_SETTINGS (r) : ORIGIN = ${BOOTLOADER_SETTINGS_START_ADDR}, LENGTH = ${BOOTLOADER_SETTINGS_SIZE} RAM (xrw) : ORIGIN = 0x20004000, LENGTH = 0x03C000 /* 240 KiB */ @@ -32,10 +32,6 @@ _estack = ORIGIN(RAM) + LENGTH(RAM); _ram_end = ORIGIN(RAM) + LENGTH(RAM); _heap_end = 0x20020000; /* tunable */ -/* Flash region for File System */ -__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); -__fatfs_flash_length = LENGTH(FLASH_FATFS); - /* define output sections */ SECTIONS { diff --git a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h index b388515e43..64988e1a28 100644 --- a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h @@ -30,9 +30,6 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Feather nRF52840 Express" #define MICROPY_HW_MCU_NAME "nRF52840" -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (4096) - #define MICROPY_HW_NEOPIXEL (&pin_P0_16) #define MICROPY_HW_LED_STATUS (&pin_P1_15) diff --git a/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h index 2f17460ae7..629463e4e2 100644 --- a/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h @@ -3,9 +3,6 @@ #define MICROPY_HW_BOARD_NAME "Adafruit ItsyBitsy nRF52840 Express" #define MICROPY_HW_MCU_NAME "nRF52840" -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (4096) - #define MICROPY_HW_LED_STATUS (&pin_P0_06) #define MICROPY_HW_APA102_MOSI (&pin_P0_08) diff --git a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h index 5188a379f6..8373551545 100644 --- a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h @@ -30,9 +30,6 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Metro nRF52840 Express" #define MICROPY_HW_MCU_NAME "nRF52840" -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (4096) - #define MICROPY_HW_NEOPIXEL (&pin_P0_13) #define MICROPY_HW_LED_STATUS (&pin_P1_13) diff --git a/ports/nrf/boards/pca10059/mpconfigboard.mk b/ports/nrf/boards/pca10059/mpconfigboard.mk index f9ff9c21c5..3f97b08218 100644 --- a/ports/nrf/boards/pca10059/mpconfigboard.mk +++ b/ports/nrf/boards/pca10059/mpconfigboard.mk @@ -5,4 +5,4 @@ USB_MANUFACTURER = "Nordic Semiconductor" MCU_CHIP = nrf52840 -INTERNAL_FLASH_FILEYSTEM = 1 +INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/nrf/ld_defines.c b/ports/nrf/ld_defines.c new file mode 100644 index 0000000000..0ec6dfdb5d --- /dev/null +++ b/ports/nrf/ld_defines.c @@ -0,0 +1,39 @@ +// Fake source file used only to capture #define values for use in ld template files. +#include "mpconfigport.h" + +// For each value needed in the LD file, create a C-like line: +// /*NAME_OF_VALUE=*/ NAME_OF_VALUE; +// The C preprocessor will replace NAME_OF_VALUE with the actual value. +// This will be post-processed by tools/gen_ld_files.py to extract the name and value. + +// The next line is a marker to start looking for definitions. Lines above the next line are ignored. +// START_LD_DEFINES + +/*MBR_START_ADDR=*/ MBR_START_ADDR; +/*MBR_SIZE=*/ MBR_SIZE; + +/*SD_FLASH_START_ADDR=*/ SD_FLASH_START_ADDR; +/*SD_FLASH_SIZE=*/ SD_FLASH_SIZE; + +/*ISR_START_ADDR=*/ ISR_START_ADDR; +/*ISR_SIZE=*/ ISR_SIZE; + +/*CIRCUITPY_DEFAULT_STACK_SIZE=*/ CIRCUITPY_DEFAULT_STACK_SIZE; + +/*CIRCUITPY_FIRMWARE_START_ADDR=*/ CIRCUITPY_FIRMWARE_START_ADDR; +/*CIRCUITPY_FIRMWARE_SIZE=*/ CIRCUITPY_FIRMWARE_SIZE; + +/*CIRCUITPY_BLE_CONFIG_START_ADDR=*/ CIRCUITPY_BLE_CONFIG_START_ADDR; +/*CIRCUITPY_BLE_CONFIG_SIZE=*/ CIRCUITPY_BLE_CONFIG_SIZE; + +/*CIRCUITPY_INTERNAL_NVM_START_ADDR=*/ CIRCUITPY_INTERNAL_NVM_START_ADDR; +/*CIRCUITPY_INTERNAL_NVM_SIZE=*/ CIRCUITPY_INTERNAL_NVM_SIZE; + +/*CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR=*/ CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR; +/*CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE=*/ CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE; + +/*BOOTLOADER_START_ADDR=*/ BOOTLOADER_START_ADDR; +/*BOOTLOADER_SIZE=*/ BOOTLOADER_SIZE; + +/*BOOTLOADER_SETTINGS_START_ADDR=*/ BOOTLOADER_SETTINGS_START_ADDR; +/*BOOTLOADER_SETTINGS_SIZE=*/ BOOTLOADER_SETTINGS_SIZE; diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 00d4a51ad8..d10f12f6a7 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -30,8 +30,13 @@ #include "ble_drv.h" +#include "nrf_mbr.h" // for MBR_SIZE +#include "nrf_sdm.h" // for SD_FLASH_SIZE +#include "peripherals/nrf/nvm.h" // for FLASH_PAGE_SIZE + #ifdef NRF52840 #define MICROPY_PY_SYS_PLATFORM "nRF52840" +#define FLASH_SIZE (0x100000) // 1MiB #endif #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) @@ -45,11 +50,12 @@ // 24kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 -#if INTERNAL_FLASH_FILESYSTEM -#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) -#else -#define CIRCUITPYINTERNAL_FLASH_FILESYSTEM_SIZE (0) -#endif +//////////////////////////////////////////////////////////////////////////////////////////////////// + +// This also includes mpconfigboard.h. +#include "py/circuitpy_mpconfig.h" + +// Definitions that might be overriden by mpconfigboard.h #ifndef CIRCUITPY_INTERNAL_NVM_SIZE #define CIRCUITPY_INTERNAL_NVM_SIZE (8192) @@ -60,14 +66,22 @@ #define BOARD_HAS_32KHZ_XTAL (1) #endif +#if INTERNAL_FLASH_FILESYSTEM + #ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (256*1024) + #endif +#else + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) +#endif + // Flash layout, starting at 0x00000000 // // SoftDevice // ISR // firmware +// internal CIRCUITPY flash filesystem (optional) // BLE config (bonding info, etc.) (optional) // microntroller.nvm (optional) -// internal CIRCUITPY flash filesystem (optional) // bootloader (note the MBR at 0x0 redirects to the bootloader here, in high flash) // bootloader settings @@ -76,14 +90,14 @@ // Define these regions starting up from the bottom of flash: #define MBR_START_ADDR (0x0) -// MBR_SIZE is from nrf_sdm.h +// MBR_SIZE is from nrf_mbr.h #define SD_FLASH_START_ADDR (MBR_START_ADDR + MBR_SIZE) // SD_FLASH_SIZE is from nrf_sdm.h -#define ISR_FLASH_START_ADDR (SD_FLASH_START_ADDR + SD_FLASH_SIZE) -#define ISR_FLASH_SIZE (0x1000) // 4kiB +#define ISR_START_ADDR (SD_FLASH_START_ADDR + SD_FLASH_SIZE) +#define ISR_SIZE (0x1000) // 4kiB -#define CIRCUITPY_FIRMWARE_START_ADDR (ISR_FLASH_START_ADDR + ISR_FLASH_LENGTH) +#define CIRCUITPY_FIRMWARE_START_ADDR (ISR_START_ADDR + ISR_SIZE) // Define these regions starting down from the bootloader: @@ -92,22 +106,52 @@ #define BOOTLOADER_SETTINGS_START_ADDR (0x000FF000) #define BOOTLOADER_SETTINGS_SIZE (0x1000) // 4kiB -#define FLASH_FATFS_SIZE (256*1024) -#define FLASH_FATFS_START_ADDR (BOOTLOADER_START_ADDR - FLASH_FATFS_SIZE) - -#define CIRCUITPY_INTERNAL_NVM_START_ADDR (FLASH_FATFS_START_ADDR - CIRCUITPY_INTERNAL_NVM_SIZE) +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (BOOTLOADER_START_ADDR - CIRCUITPY_INTERNAL_NVM_SIZE) +// 32kiB for bonding, etc. #define CIRCUITPY_BLE_CONFIG_SIZE (32*1024) #define CIRCUITPY_BLE_CONFIG_START_ADDR (CIRCUITPY_INTERNAL_NVM_START_ADDR - CIRCUITPY_BLE_CONFIG_SIZE) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR (CIRCUITPY_BLE_CONFIG_START_ADDR - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE) + // The firmware space is the space left over between the fixed lower and upper regions. -#define CIRCUITPY_FIRMWARE_SIZE (CIRCUITPY_BLE_CONFIG_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR) +#define CIRCUITPY_FIRMWARE_SIZE (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR) + +#if BOOTLOADER_START_ADDR % FLASH_PAGE_SIZE != 0 +#error BOOTLOADER_START_ADDR must be on a flash page boundary. +#endif + +#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash page boundary. +#endif +#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#endif + +#if CIRCUITPY_BLE_CONFIG_START_ADDR % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_BLE_CONFIG_SIZE must be on a flash page boundary. +#endif +#if CIRCUITPY_BLE_CONFIG_SIZE % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_BLE_CONFIG_SIZE must be a multiple of FLASH_PAGE_SIZE. +#endif + +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash page boundary. +#endif +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_PAGE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#endif #if CIRCUITPY_FIRMWARE_SIZE < 0 #error No space left in flash for firmware after specifying other regions! #endif -#include "py/circuitpy_mpconfig.h" +#if CIRCUITPY_FIRMWARE_SIZE < 0 +#error No space left in flash for firmware after specifying other regions! +#endif + + + #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS \ diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 47cabffb5e..9b738d4b3a 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -53,7 +53,7 @@ CIRCUITPY_FREQUENCYIO = 0 # nRF52840-specific -ifeq($(MCU_CHIP),nrf52840) +ifeq ($(MCU_CHIP),nrf52840) MCU_SERIES = m4 MCU_VARIANT = nrf52 MCU_SUB_VARIANT = nrf52840 diff --git a/ports/nrf/supervisor/internal_flash.c b/ports/nrf/supervisor/internal_flash.c index c43454eb39..07aa5079f4 100644 --- a/ports/nrf/supervisor/internal_flash.c +++ b/ports/nrf/supervisor/internal_flash.c @@ -42,10 +42,6 @@ #include "nrf_sdm.h" #endif -// defined in linker -extern uint32_t __fatfs_flash_start_addr[]; -extern uint32_t __fatfs_flash_length[]; - #define NO_CACHE 0xffffffff uint8_t _flash_cache[FLASH_PAGE_SIZE] __attribute__((aligned(4))); @@ -56,7 +52,7 @@ uint32_t _flash_page_addr = NO_CACHE; /* Internal Flash API *------------------------------------------------------------------*/ static inline uint32_t lba2addr(uint32_t block) { - return ((uint32_t)__fatfs_flash_start_addr) + block * FILESYSTEM_BLOCK_SIZE; + return CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR + block * FILESYSTEM_BLOCK_SIZE; } void supervisor_flash_init(void) { @@ -67,7 +63,7 @@ uint32_t supervisor_flash_get_block_size(void) { } uint32_t supervisor_flash_get_block_count(void) { - return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE ; + return CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE ; } void supervisor_flash_flush(void) { diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 34c097e36b..265b552bb1 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -402,6 +402,18 @@ $(addprefix lib/,\ ) endif +ifdef LD_TEMPLATE_FILE +# Generate a linker script (.ld file) from a template, for those builds that use it. +GENERATED_LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLATE_FILE))) +# +# ld_defines.pp is generated from ld_defines.c. See py/mkrules.mk. +# Run gen_ld_files.py over ALL *.template.ld files, not just LD_TEMPLATE_FILE, +# because it may include other template files. +$(GENERATED_LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld + $(STEPECHO) "GEN $@" + $(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld +endif + .PHONY: check-release-needs-clean-build check-release-needs-clean-build: diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 87d506b3b8..96a14c25b4 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -25,14 +25,12 @@ CFLAGS += -DINTERNAL_FLASH_FILESYSTEM=$(INTERNAL_FLASH_FILESYSTEM) ifndef QSPI_FLASH_FILESYSTEM QSPI_FLASH_FILESYSTEM = 0 endif -# EXPRESS_BOARD is obsolete and should be removed when samd-peripherals is updated. -CFLAGS += -DQSPI_FLASH_FILESYSTEM=$(QSPI_FLASH_FILESYSTEM) -DEXPRESS_BOARD +CFLAGS += -DQSPI_FLASH_FILESYSTEM=$(QSPI_FLASH_FILESYSTEM) ifndef SPI_FLASH_FILESYSTEM SPI_FLASH_FILESYSTEM = 0 endif -# EXPRESS_BOARD is obsolete and should be removed when samd-peripherals is updated. -CFLAGS += -DSPI_FLASH_FILESYSTEM=$(SPI_FLASH_FILESYSTEM) -DEXPRESS_BOARD +CFLAGS += -DSPI_FLASH_FILESYSTEM=$(SPI_FLASH_FILESYSTEM) ifeq ($(CIRCUITPY_BLEIO),1) SRC_SUPERVISOR += supervisor/shared/bluetooth.c diff --git a/tools/build_memory_info.py b/tools/build_memory_info.py index f128561ab2..afe49650e2 100644 --- a/tools/build_memory_info.py +++ b/tools/build_memory_info.py @@ -41,7 +41,8 @@ data = 0 bss = 0 # stdin is the linker output. for line in sys.stdin: - print(line) + # Uncomment to see linker output. + # print(line) line = line.strip() if not line.startswith("text"): text, data, bss = map(int, line.split()[:3]) @@ -51,7 +52,7 @@ regions = {} with open(sys.argv[1], "r") as f: for line in f: line = line.strip() - if line.startswith(("FLASH_FIRMWARE", "RAM")): + if line.startswith(("FLASH_FIRMWARE", "FLASH", "RAM")): regions[line.split()[0]] = line.split("=")[-1] for region in regions: @@ -62,10 +63,17 @@ for region in regions: space = M_PATTERN.sub(M_REPLACE, space) regions[region] = eval(space) -free_flash = regions["FLASH_FIRMWARE"] - text - data -free_ram = regions["RAM"] - data - bss -print("{} bytes free in flash firmware space out of {} bytes ({}kB).".format(free_flash, regions["FLASH_FIRMWARE"], regions["FLASH_FIRMWARE"] / 1024)) -print("{} bytes free in ram for heap out of {} bytes ({}kB).".format(free_ram, regions["RAM"], regions["RAM"] / 1024)) +# TODO Remove check for both FLASH_FIRMWARE and FLASH after all ports are converted to use FLASH_FIRMWARE. +try: + firmware_region = regions["FLASH_FIRMWARE"] +except KeyError: + firmware_region = regions["FLASH"] +ram_region = regions["RAM"] + +free_flash = firmware_region - text - data +free_ram = ram_region - data - bss +print("{} bytes free in flash firmware space out of {} bytes ({}kB).".format(free_flash, firmware_region, firmware_region / 1024)) +print("{} bytes free in ram for heap out of {} bytes ({}kB).".format(free_ram, ram_region, ram_region / 1024)) print() # Check that we have free flash space. GCC doesn't fail when the text + data From 222dd29a142a530b43fdf4d1ea01e276962b9886 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 10 Dec 2019 20:42:39 -0500 Subject: [PATCH 162/531] Fix slice step. --- shared-bindings/_pixelbuf/PixelBuf.c | 8 +++++--- shared-module/_pixelbuf/PixelBuf.c | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index dabc23d359..feda2c573a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -391,6 +391,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; + if (slice.step > 1) { + len = (len / slice.step) + (len % slice.step ? 1 : 0); + } uint8_t *readbuf = self->two_buffers ? self->rawbuf : self->buf; return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, slice.step, self->byteorder.is_dotstar); } else { // Set @@ -399,10 +402,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) mp_raise_ValueError(translate("tuple/list required on RHS")); - size_t dst_len = (slice.stop - slice.start) / slice.step; + size_t dst_len = (slice.stop - slice.start); if (slice.step > 1) { - if ((slice.stop - slice.start) % slice.step) - dst_len ++; + dst_len = (dst_len / slice.step) + (dst_len % slice.step ? 1 : 0); } mp_obj_t *src_objs; size_t num_items; diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index a0071903a9..020151bc31 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -96,9 +96,6 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar) { mp_obj_t elems[len]; - if (slice_step > 1) { - len = len / slice_step; - } for (uint i = 0; i < len; i++) { elems[i] = pixelbuf_get_pixel(buf + ((i * slice_step) * step), byteorder, dotstar); } From c6221c5956018941804457274e4fbed03de7e403 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 10 Dec 2019 21:08:51 -0500 Subject: [PATCH 163/531] Remove no-longer-used nrf and atmel-samd .ld files --- .../samd21x18-bootloader-crystalless.ld | 13 -- ...8-bootloader-external-flash-crystalless.ld | 13 -- .../samd21x18-bootloader-external-flash.ld | 13 -- .../atmel-samd/boards/samd21x18-bootloader.ld | 14 --- .../boards/samd21x18-external-flash.ld | 13 -- ports/atmel-samd/boards/samd21x18.ld | 13 -- .../samd51x18-bootloader-external-flash.ld | 13 -- .../samd51x19-bootloader-external-flash.ld | 13 -- .../atmel-samd/boards/samd51x19-bootloader.ld | 13 -- .../samd51x20-bootloader-external-flash.ld | 13 -- .../atmel-samd/boards/samd51x20-bootloader.ld | 12 -- .../boards/samd51x20-external-flash.ld | 12 -- ports/atmel-samd/boards/samd51x20.ld | 13 -- ports/nrf/boards/adafruit_nrf52840_s140_v6.ld | 52 -------- ports/nrf/boards/common.ld | 115 ------------------ ports/nrf/boards/nrf52840_1M_256k.ld | 28 ----- .../nrf/boards/nrf52840_1M_256k_s140_6.0.0.ld | 28 ----- 17 files changed, 391 deletions(-) delete mode 100644 ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld delete mode 100644 ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld delete mode 100644 ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld delete mode 100644 ports/atmel-samd/boards/samd21x18-bootloader.ld delete mode 100644 ports/atmel-samd/boards/samd21x18-external-flash.ld delete mode 100644 ports/atmel-samd/boards/samd21x18.ld delete mode 100644 ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld delete mode 100644 ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld delete mode 100644 ports/atmel-samd/boards/samd51x19-bootloader.ld delete mode 100644 ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld delete mode 100644 ports/atmel-samd/boards/samd51x20-bootloader.ld delete mode 100644 ports/atmel-samd/boards/samd51x20-external-flash.ld delete mode 100644 ports/atmel-samd/boards/samd51x20.ld delete mode 100644 ports/nrf/boards/adafruit_nrf52840_s140_v6.ld delete mode 100644 ports/nrf/boards/common.ld delete mode 100644 ports/nrf/boards/nrf52840_1M_256k.ld delete mode 100644 ports/nrf/boards/nrf52840_1M_256k_s140_6.0.0.ld diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld b/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld deleted file mode 100644 index 1ee745eb17..0000000000 --- a/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD21x18 (256K flash, 32K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 8KiB for the bootloader, 256b for persistent config (clock), 64k for the flash file system and 256b for the user config. */ - FLASH (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 256K - 8K - 256 - 64K - 256 - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -} - -INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld deleted file mode 100644 index d8f4cc2365..0000000000 --- a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD21x18 (256K flash, 32K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 8KiB for the bootloader, 256b for internal config and 256b for user config. */ - FLASH (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 256K - 8K - 256 - 256 - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -} - -INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld deleted file mode 100644 index f663326d69..0000000000 --- a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD21x18 (256K flash, 32K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 8KiB for the bootloader and 256b for user config. */ - FLASH (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 256K - 8K - 256 - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K /* 32 KiB RAM */ -} - -INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-bootloader.ld b/ports/atmel-samd/boards/samd21x18-bootloader.ld deleted file mode 100644 index 666ac79c47..0000000000 --- a/ports/atmel-samd/boards/samd21x18-bootloader.ld +++ /dev/null @@ -1,14 +0,0 @@ -/* - GNU linker script for SAMD21x18 (256K flash, 32K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 8KiB for the bootloader, 64k for the flash file system, and 256b - for user config. */ - FLASH (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 256K - 8K - 64K - 256 - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -} - -INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18-external-flash.ld b/ports/atmel-samd/boards/samd21x18-external-flash.ld deleted file mode 100644 index 6afdab7345..0000000000 --- a/ports/atmel-samd/boards/samd21x18-external-flash.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD21x18 (256K flash, 32K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* 256 KiB but leave 256b for internal config and 256b for user config (protected eeprom) */ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K - 256 - 256 - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -} - -INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd21x18.ld b/ports/atmel-samd/boards/samd21x18.ld deleted file mode 100644 index c035f5117e..0000000000 --- a/ports/atmel-samd/boards/samd21x18.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD21x18 (256K flash, 32K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 256b for internal config, 64k for the flash file system and 256b for user config. */ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K - 256 - 64K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K -} - -INCLUDE "samd21-common.ld" diff --git a/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld deleted file mode 100644 index b22bef3f3a..0000000000 --- a/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD51x18 (256K flash, 128K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 16KiB for the bootloader. 8K for user data*/ - FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 256K - 16K - 8K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K -} - -INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld deleted file mode 100644 index f1493f2510..0000000000 --- a/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD51x19 (512K flash, 192K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 16KiB for the bootloader. 8K for user data*/ - FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 512K - 16K - 8K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K -} - -INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x19-bootloader.ld b/ports/atmel-samd/boards/samd51x19-bootloader.ld deleted file mode 100644 index c73db2ece9..0000000000 --- a/ports/atmel-samd/boards/samd51x19-bootloader.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD51x19 (512K flash, 192K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 16KiB for the bootloader, 256KiB for the internal file system, and 8KiB for user binary data. */ - FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 512K - 16K - 256K - 8K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K -} - -INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld deleted file mode 100644 index ee28fdf1cc..0000000000 --- a/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD51x20 (1MB flash, 256K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 16KiB for the bootloader. */ - FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 1M - 16K - 8K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K -} - -INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20-bootloader.ld b/ports/atmel-samd/boards/samd51x20-bootloader.ld deleted file mode 100644 index ea0e0569f5..0000000000 --- a/ports/atmel-samd/boards/samd51x20-bootloader.ld +++ /dev/null @@ -1,12 +0,0 @@ -/* - GNU linker script for SAMD51x20 (1MB flash, 256K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* Leave 16KiB for the bootloader, 512k for the filesystem and 8k for user config data. */ - FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 1M - 16K - 512K - 8K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K -} -INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20-external-flash.ld b/ports/atmel-samd/boards/samd51x20-external-flash.ld deleted file mode 100644 index 5212363fe1..0000000000 --- a/ports/atmel-samd/boards/samd51x20-external-flash.ld +++ /dev/null @@ -1,12 +0,0 @@ -/* - GNU linker script for SAMD51x20 (1MB flash, 256K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1M - 8K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K -} - -INCLUDE "samd51-common.ld" diff --git a/ports/atmel-samd/boards/samd51x20.ld b/ports/atmel-samd/boards/samd51x20.ld deleted file mode 100644 index 1f0b661720..0000000000 --- a/ports/atmel-samd/boards/samd51x20.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - GNU linker script for SAMD51x20 (1MB flash, 256K RAM) -*/ - -/* Specify the memory areas */ -MEMORY -{ - /* 1024 KiB minus 512KiB for the internal file system and 8KiB for the user nvm. */ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1M - 512K - 8K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K -} - -INCLUDE "samd51-common.ld" diff --git a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld b/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld deleted file mode 100644 index 2d158c4964..0000000000 --- a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld +++ /dev/null @@ -1,52 +0,0 @@ -/* - GNU linker script for NRF52840 w/S140 6.x.x SoftDevice - - MEMORY MAP - ------------------------------------------------------------------------ - START ADDR END ADDR SIZE DESCRIPTION - ---------- ---------- ------- ----------------------------------------- - 0x000FF000..0x000FFFFF ( 4KB) Bootloader Settings - 0x000FE000..0x000FEFFF ( 4KB) Master Boot Record Params - 0x000F4000..0x000FDFFF ( 40KB) Bootloader (UF2 + CDC + OTA) - - 0x000ED000..0x000F3FFF (28KB ) Private Config Data (Bonding, Keys, etc.) - 0x000AD000..0x000ECFFF (256KB) User Filesystem - 0x00026000..0x000ACFFF (540KB) Application Code (including ISR vector) - 0x00001000..0x00025FFF (148KB) SoftDevice - 0x00000000..0x00000FFF (4KB) Master Boot Record -*/ - - -/* Specify the memory areas (S140 6.x.x) */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1M - - FLASH_ISR (rx) : ORIGIN = 0x00026000, LENGTH = 0x001000 - FLASH_TEXT (rx) : ORIGIN = 0x00027000, LENGTH = 0x086000 - FLASH_FATFS (r) : ORIGIN = 0x000AD000, LENGTH = 0x040000 - FLASH_NVM (r) : ORIGIN = 0x000EC000, LENGTH = 0x001000 - FLASH_CONFIG (r): ORIGIN = 0x000ED000, LENGTH = 0x007000 - - /* 0x2000000 - RAM:ORIGIN is reserved for Softdevice */ - /* SoftDevice 6.1.0 takes 0x1628 bytes (5.54 kb) minimum. */ - /* To measure the minimum required amount of memory for given configuration, set this number - high enough to work and then check the mutation of the value done by sd_ble_enable. */ - RAM (xrw) : ORIGIN = 0x20000000 + 16K, LENGTH = 256K - 16K -} - -/* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; -_minimum_heap_size = 0; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector and soft device init */ -_ram_start = ORIGIN(RAM); -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20020000; /* tunable */ - -INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/common.ld b/ports/nrf/boards/common.ld deleted file mode 100644 index fade4b9e1b..0000000000 --- a/ports/nrf/boards/common.ld +++ /dev/null @@ -1,115 +0,0 @@ -/* Flash region for File System */ -__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); -__fatfs_flash_length = LENGTH(FLASH_FATFS); - -/* Flash region for configuration information (bonding info, keys, etc.) */ -__config_flash_start_addr = ORIGIN(FLASH_CONFIG); -__config_flash_length = LENGTH(FLASH_CONFIG); - -/* Flash region for microcontroller.nvm region */ -__nvm_flash_start_addr = ORIGIN(FLASH_NVM); -__nvm_flash_length = LENGTH(FLASH_NVM); - -/* define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - - . = ALIGN(4); - } >FLASH_ISR - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - /* *(.glue_7) */ /* glue arm to thumb code */ - /* *(.glue_7t) */ /* glue thumb to arm code */ - - . = ALIGN(4); - _etext = .; /* define a global symbol at end of code */ - } >FLASH_TEXT - - /* - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } >FLASH - - .ARM : - { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - */ - - /* used by the startup to initialize data */ - _sidata = .; - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT (_sidata) - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ - _ram_start = .; /* create a global symbol at ram start for garbage collector */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - _sbss = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ - } >RAM - - /* this is to define the start of the heap, and make sure we have a minimum size */ - .heap : - { - . = ALIGN(4); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - _heap_start = .; /* define a global symbol at heap start */ - . = . + _minimum_heap_size; - } >RAM - - /* this just checks there is enough RAM for the stack */ - .stack : - { - . = ALIGN(4); - . = . + _minimum_stack_size; - . = ALIGN(4); - } >RAM - - /* Remove information from the standard libraries */ - /* - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - */ - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/ports/nrf/boards/nrf52840_1M_256k.ld b/ports/nrf/boards/nrf52840_1M_256k.ld deleted file mode 100644 index eb8a18aef6..0000000000 --- a/ports/nrf/boards/nrf52840_1M_256k.ld +++ /dev/null @@ -1,28 +0,0 @@ -/* - GNU linker script for NRF52840 blank w/ no SoftDevice -*/ - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000 /* entire flash, 1 MiB */ - FLASH_ISR (rx) : ORIGIN = 0x00000000, LENGTH = 0x001000 /* sector 0, 4 KiB */ - FLASH_TEXT (rx) : ORIGIN = 0x00001000, LENGTH = 0x0E6000 /* 920 KiB */ - FLASH_FATFS (r) : ORIGIN = 0x000E7000, LENGTH = 0x019000 /* File system 100 KiB */ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x040000 /* 256 KiB */ -} - -/* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 40K; -_minimum_heap_size = 0; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20020000; /* tunable */ - -INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf52840_1M_256k_s140_6.0.0.ld b/ports/nrf/boards/nrf52840_1M_256k_s140_6.0.0.ld deleted file mode 100644 index 90d6c402d0..0000000000 --- a/ports/nrf/boards/nrf52840_1M_256k_s140_6.0.0.ld +++ /dev/null @@ -1,28 +0,0 @@ -/* - GNU linker script for NRF52840 w/ s140 6.0.0 SoftDevice -*/ - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000 /* entire flash, 1 MiB */ - FLASH_ISR (rx) : ORIGIN = 0x00026000, LENGTH = 0x001000 /* sector 0, 4 KiB */ - FLASH_TEXT (rx) : ORIGIN = 0x00027000, LENGTH = 0x099000 /* 612 KiB */ - FLASH_FATFS (r) : ORIGIN = 0x000C0000, LENGTH = 0x040000 /* File system 256 KiB */ - RAM (xrw) : ORIGIN = 0x20004000, LENGTH = 0x03C000 /* 240 KiB */ -} - -/* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 40K; -_minimum_heap_size = 0; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20020000; /* tunable */ - -INCLUDE "boards/common.ld" From d9ca4c9a608c08585e37eba88f86a1d89e1335e4 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 10 Dec 2019 22:39:44 -0500 Subject: [PATCH 164/531] fix build failures --- .../boards/kicksat-sprite/mpconfigboard.h | 2 - .../boards/kicksat-sprite/mpconfigboard.mk | 1 - ports/atmel-samd/mpconfigport.h | 64 ++++++++++++------- .../electronut_labs_papyr/mpconfigboard.mk | 2 +- .../mpconfigboard.mk | 2 +- ports/nrf/mpconfigport.h | 4 -- tools/build_memory_info.py | 2 +- 7 files changed, 44 insertions(+), 33 deletions(-) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h index 6664524d24..4d911ad64c 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h @@ -10,8 +10,6 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define CALIBRATE_CRYSTALLESS 1 - #define CIRCUITPY_INTERNAL_NVM_SIZE 0 #define DEFAULT_I2C_BUS_SCL (&pin_PA17) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index b89469776b..df1a2d8eb3 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -6,7 +6,6 @@ USB_MANUFACTURER = "maholli" CHIP_VARIANT = SAMD51G19A CHIP_FAMILY = samd51 -QSPI_FLASH_FILESYSTEM = 0 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = MPZ diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 6ab95c8a5a..a319c6199a 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -30,15 +30,11 @@ // Definitions for which SAMD chip we're using. #include "include/sam.h" +// Definitions that control circuitpy_mpconfig.h: //////////////////////////////////////////////////////////////////////////////////////////////////// -#ifdef SAMD21 -#if INTERNAL_FLASH_FILESYSTEM -#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) -#else -#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) -#endif +#ifdef SAMD21 // HMCRAMC0_SIZE is defined in the ASF4 include files for each SAMD21 chip. #define RAM_SIZE HMCRAMC0_SIZE @@ -66,29 +62,12 @@ X(EISDIR) \ X(EINVAL) \ -#ifndef CIRCUITPY_INTERNAL_NVM_SIZE -#define CIRCUITPY_INTERNAL_NVM_SIZE (256) -#endif - #endif // SAMD21 //////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef SAMD51 -#ifndef CIRCUITPY_INTERNAL_NVM_SIZE -#define CIRCUITPY_INTERNAL_NVM_SIZE (8192) -#endif - -// If CIRCUITPY is internal, use half of flash for it. -#if INTERNAL_FLASH_FILESYSTEM - #ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE - #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2) - #endif -#else - #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) -#endif - // HSRAM_SIZE is defined in the ASF4 include files for each SAMD51 chip. #define RAM_SIZE HSRAM_SIZE #define BOOTLOADER_SIZE (16*1024) @@ -113,6 +92,45 @@ // This also includes mpconfigboard.h. #include "py/circuitpy_mpconfig.h" +// Definitions that can be overridden by mpconfigboard.h: + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef SAMD21 + +#if INTERNAL_FLASH_FILESYSTEM +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024) +#else +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) +#endif + +#ifndef CIRCUITPY_INTERNAL_NVM_SIZE +#define CIRCUITPY_INTERNAL_NVM_SIZE (256) +#endif + +#endif // SAMD21 + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef SAMD51 + +#ifndef CIRCUITPY_INTERNAL_NVM_SIZE +#define CIRCUITPY_INTERNAL_NVM_SIZE (8192) +#endif + +// If CIRCUITPY is internal, use half of flash for it. +#if INTERNAL_FLASH_FILESYSTEM + #ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2) + #endif +#else + #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0) +#endif + +#endif // SAMD51 + +//////////////////////////////////////////////////////////////////////////////////////////////////// + #ifndef CALIBRATE_CRYSTALLESS #define CALIBRATE_CRYSTALLESS (0) #endif diff --git a/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.mk b/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.mk index be7175e4ea..569dccc9c4 100644 --- a/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.mk +++ b/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.mk @@ -5,4 +5,4 @@ USB_MANUFACTURER = "Electronut Labs" MCU_CHIP = nrf52840 -INTERNAL_FLASH_FILEYSTEM = 1 +INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.mk b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.mk index 0a29c54e55..55ca410d9f 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.mk +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.mk @@ -5,4 +5,4 @@ USB_MANUFACTURER = "makerdiary" MCU_CHIP = nrf52840 -INTERNAL_FLASH_FILEYSTEM = 1 +INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index d10f12f6a7..c6d148234b 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -146,10 +146,6 @@ #error No space left in flash for firmware after specifying other regions! #endif -#if CIRCUITPY_FIRMWARE_SIZE < 0 -#error No space left in flash for firmware after specifying other regions! -#endif - diff --git a/tools/build_memory_info.py b/tools/build_memory_info.py index afe49650e2..f61b843ced 100644 --- a/tools/build_memory_info.py +++ b/tools/build_memory_info.py @@ -61,7 +61,7 @@ for region in regions: space = space.split("/*")[0] space = K_PATTERN.sub(K_REPLACE, space) space = M_PATTERN.sub(M_REPLACE, space) - regions[region] = eval(space) + regions[region] = int(eval(space)) # TODO Remove check for both FLASH_FIRMWARE and FLASH after all ports are converted to use FLASH_FIRMWARE. try: From 73b6e5d8e6e992eae027b76dc55ceb2ea907e672 Mon Sep 17 00:00:00 2001 From: iot49 Date: Tue, 10 Dec 2019 19:44:11 -0800 Subject: [PATCH 165/531] added correct include files --- ports/nrf/fatfs_port.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ports/nrf/fatfs_port.c b/ports/nrf/fatfs_port.c index 83698fd19c..cb1bfa8347 100644 --- a/ports/nrf/fatfs_port.c +++ b/ports/nrf/fatfs_port.c @@ -27,9 +27,8 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" #include "lib/timeutils/timeutils.h" - -extern void common_hal_rtc_get_time(timeutils_struct_time_t *tm); -extern void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm); +#include "shared-bindings/rtc/RTC.h" +#include "shared-bindings/time/__init__.h" DWORD get_fattime(void) { #if CIRCUITPY_RTC From 1e11f2708b345468ae9b1762339bf3511c8ab7eb Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 11 Dec 2019 09:34:56 -0500 Subject: [PATCH 166/531] remove debugging leftovers --- ports/nrf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 4bb72324fb..e6070fc329 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -90,7 +90,7 @@ INC += -I../../supervisor/shared/usb ifeq ($(DEBUG), 1) CFLAGS += -ggdb3 -Og else - CFLAGS += -Os -DNDEBUG -ggdb3 + CFLAGS += -Os -DNDEBUG CFLAGS += -flto -flto-partition=none endif From d67a9a827111114c1984390fd303e9812af6654c Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 11 Dec 2019 11:41:10 -0800 Subject: [PATCH 167/531] Added PyPortal Pynt alias --- tools/build_board_info.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 710cdb0c22..7c4484a659 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -49,6 +49,7 @@ extension_by_board = { aliases_by_board = { "circuitplayground_express": ["circuitplayground_express_4h", "circuitplayground_express_digikey_pycon2019"], "pybadge": ["edgebadge"], + "pyportal": ["pyportal_pynt"], "gemma_m0": ["gemma_m0_pycon2018"], "pewpew10": ["pewpew13"] } From 006d85d5c2c50c694df4b0eda1fab6f93d073b9f Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Wed, 11 Dec 2019 14:49:59 -0500 Subject: [PATCH 168/531] add make file and board configuration, add accelerometer pin mappings --- .../boards/teknikio_bluebird/mpconfigboard.h | 46 +++---------- .../boards/teknikio_bluebird/mpconfigboard.mk | 34 ++++++++-- ports/nrf/boards/teknikio_bluebird/pins.c | 68 ++----------------- 3 files changed, 44 insertions(+), 104 deletions(-) diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h index 348028c0f7..2b8707ad08 100644 --- a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h @@ -27,48 +27,24 @@ //https://github.com/Teknikio/TKInventionBuilderFramework + #include "nrfx/hal/nrf_gpio.h" -#define MICROPY_HW_BOARD_NAME "Adafruit Circuit Playground Bluefruit" +#define MICROPY_HW_BOARD_NAME "Teknikio Bluebird" #define MICROPY_HW_MCU_NAME "nRF52840" -#define MICROPY_PY_SYS_PLATFORM "CircuitPlaygroundBluefruit" - -#define FLASH_SIZE (0x100000) -#define FLASH_PAGE_SIZE (4096) - -#define MICROPY_HW_LED_STATUS (&pin_P1_14) - -// Unusually, board does not have a 32 kHz xtal. Nearly all boards do. -#define BOARD_HAS_32KHZ_XTAL (0) - -#if QSPI_FLASH_FILESYSTEM -#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 21) -#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 23) -#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 00) -#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 22) -#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) -#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 15) -#endif - -#if SPI_FLASH_FILESYSTEM -#define SPI_FLASH_MOSI_PIN &pin_P0_21 -#define SPI_FLASH_MISO_PIN &pin_P0_23 -#define SPI_FLASH_SCK_PIN &pin_P0_19 -#define SPI_FLASH_CS_PIN &pin_P0_15 -#endif #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 -#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) +#define MICROPY_HW_NEOPIXEL (&pin_P0_26) -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) +#define DEFAULT_I2C_BUS_SCL (&pin_P0_27) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_26) -#define DEFAULT_I2C_BUS_SCL (&pin_P0_04) -#define DEFAULT_I2C_BUS_SDA (&pin_P0_05) +#define DEFAULT_SPI_BUS_SCK (&pin_P1_15) +#define DEFAULT_SPI_BUS_MOSI (&pin_P1_13) +#define DEFAULT_SPI_BUS_MISO (&pin_P1_14) -#define DEFAULT_SPI_BUS_SCK (&pin_P0_05) -#define DEFAULT_SPI_BUS_MOSI (&pin_P1_03) -#define DEFAULT_SPI_BUS_MISO (&pin_P0_29) +#define DEFAULT_UART_BUS_RX (&pin_P1_07) +#define DEFAULT_UART_BUS_TX (&pin_P1_08) -#define DEFAULT_UART_BUS_RX (&pin_P0_30) -#define DEFAULT_UART_BUS_TX (&pin_P0_14) +#define BOARD_HAS_CRYSTAL 1 // according to the schematic we do \ No newline at end of file diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk index dbb32629c6..833a6faa82 100644 --- a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk @@ -1,7 +1,7 @@ USB_VID = 0x239A USB_PID = 0x8046 -USB_PRODUCT = "Circuit Playground Bluefruit" -USB_MANUFACTURER = "Adafruit Industries LLC" +USB_PRODUCT = "Bluebird" +USB_MANUFACTURER = "Teknikio" MCU_SERIES = m4 MCU_VARIANT = nrf52 @@ -21,6 +21,30 @@ endif NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 -QSPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = "GD25Q16C" +INTERNAL_FLASH_FILESYSTEM = 1 + + +USB_VID = 0x239A +USB_PID = 0x802A +USB_PRODUCT = "PCA10059" +USB_MANUFACTURER = "Nordic Semiconductor" + +MCU_SERIES = m4 +MCU_VARIANT = nrf52 +MCU_SUB_VARIANT = nrf52840 +MCU_CHIP = nrf52840 +SD ?= s140 +SOFTDEV_VERSION ?= 6.1.0 + +BOOT_SETTING_ADDR = 0xFF000 +BOOT_FILE = boards/$(BOARD)/bootloader/$(SOFTDEV_VERSION)/$(BOARD)_bootloader_$(SOFTDEV_VERSION)_s140 + +ifeq ($(SD),) + LD_FILE = boards/nrf52840_1M_256k.ld +else + LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld + CIRCUITPY_BLEIO = 1 +endif + +NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 + diff --git a/ports/nrf/boards/teknikio_bluebird/pins.c b/ports/nrf/boards/teknikio_bluebird/pins.c index e8e5f4110d..b41d9c2fce 100644 --- a/ports/nrf/boards/teknikio_bluebird/pins.c +++ b/ports/nrf/boards/teknikio_bluebird/pins.c @@ -1,71 +1,11 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_AUDIO), MP_ROM_PTR(&pin_P0_26) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_26) }, - { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_P0_26) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_02) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_02) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_02) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_29) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_29) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_29) }, - - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_03) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_03) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, - - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_04) }, - { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_04) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_04) }, - - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_05) }, - { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_05) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_05) }, - - { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_30) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_30) }, - - // This cannot be A7, as it is on CPX. We don't have enough analog inputs. - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_14) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_14) }, - - { MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_P0_28) }, - { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_P0_28) }, - - { MP_ROM_QSTR(MP_QSTR_TEMPERATURE), MP_ROM_PTR(&pin_P0_31) }, - { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_P0_31) }, - - { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_P1_02) }, - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P1_02) }, - - { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_P1_15) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_15) }, - - { MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_P1_06) }, - { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_06) }, - - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) }, - { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_14) }, - - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_13) }, - { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_13) }, - - { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_17) }, - { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_16) }, - - { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_P1_13) }, - { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_P1_10) }, - { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SCL), MP_ROM_PTR(&pin_P1_12) }, - - { MP_ROM_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_P1_04) }, - - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_P1_12) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SCL), MP_ROM_PTR(&pin_P1_11) }, }; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); \ No newline at end of file From a273a7c55e5396d231ed663497c93694febc5812 Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Wed, 11 Dec 2019 15:23:16 -0500 Subject: [PATCH 169/531] add remaining peripheral pin maps and digital/analog pin definitions --- ports/nrf/boards/teknikio_bluebird/pins.c | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/ports/nrf/boards/teknikio_bluebird/pins.c b/ports/nrf/boards/teknikio_bluebird/pins.c index b41d9c2fce..a90dc7daa2 100644 --- a/ports/nrf/boards/teknikio_bluebird/pins.c +++ b/ports/nrf/boards/teknikio_bluebird/pins.c @@ -2,6 +2,57 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_12) }, + + { MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_P0_11) }, + + { MP_ROM_QSTR(MP_QSTR_P1_09), MP_ROM_PTR(&pin_P1_09) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P1_09) }, + + { MP_ROM_QSTR(MP_QSTR_P1_08), MP_ROM_PTR(&pin_P1_08) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_08) }, + + { MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_08) }, + + { MP_ROM_QSTR(MP_QSTR_P0_07), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_07) }, + + { MP_ROM_QSTR(MP_QSTR_P0_06), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_06) }, + + { MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_04) }, + + { MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_29) }, + + { MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_02) }, + + { MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_26) }, + + { MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_LIGHT_ENABLE), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_P1_15) }, { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_P1_10) }, { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_P1_12) }, From 0da5dceccfbbb1b339309ea5bef192b31cb70061 Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Wed, 11 Dec 2019 15:25:16 -0500 Subject: [PATCH 170/531] update bluebird makefile --- .../boards/teknikio_bluebird/mpconfigboard.mk | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk index 833a6faa82..c2b8b7605a 100644 --- a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x8046 +USB_PID = 0x802A USB_PRODUCT = "Bluebird" USB_MANUFACTURER = "Teknikio" @@ -23,28 +23,3 @@ NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 INTERNAL_FLASH_FILESYSTEM = 1 - -USB_VID = 0x239A -USB_PID = 0x802A -USB_PRODUCT = "PCA10059" -USB_MANUFACTURER = "Nordic Semiconductor" - -MCU_SERIES = m4 -MCU_VARIANT = nrf52 -MCU_SUB_VARIANT = nrf52840 -MCU_CHIP = nrf52840 -SD ?= s140 -SOFTDEV_VERSION ?= 6.1.0 - -BOOT_SETTING_ADDR = 0xFF000 -BOOT_FILE = boards/$(BOARD)/bootloader/$(SOFTDEV_VERSION)/$(BOARD)_bootloader_$(SOFTDEV_VERSION)_s140 - -ifeq ($(SD),) - LD_FILE = boards/nrf52840_1M_256k.ld -else - LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld - CIRCUITPY_BLEIO = 1 -endif - -NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 - From ae64a669ddd47c5e5ed01b6f94f8c206f1f65cf6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 11 Dec 2019 15:43:06 -0500 Subject: [PATCH 171/531] address review comments --- .../common-hal/frequencyio/FrequencyIn.c | 22 +++++++++---------- ports/nrf/README.md | 12 ++-------- ports/nrf/common-hal/_bleio/Adapter.c | 2 +- ports/nrf/mpconfigport.h | 5 ++--- .../stm32f412zg_discovery/mpconfigboard.h | 2 +- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index 6258818c83..cbb0671045 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -213,17 +213,17 @@ void frequencyin_samd51_start_dpll() { // Will also enable the Lock Bypass due to low-frequency sources causing DPLL unlocks // as outlined in the Errata (1.12.1) OSCCTRL->Dpll[1].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0) | OSCCTRL_DPLLRATIO_LDR(2999); - if (BOARD_HAS_CRYSTAL) { // we can use XOSC32K directly as the source - OSC32KCTRL->XOSC32K.bit.EN32K = 1; - OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK(1) | - OSCCTRL_DPLLCTRLB_LBYPASS; - } else { - // can't use OSCULP32K directly; need to setup a GCLK as a reference, - // which must be done in samd/clocks.c to avoid waiting for sync - return; - //OSC32KCTRL->OSCULP32K.bit.EN32K = 1; - //OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK(0); - } +#if BOARD_HAS_CRYSTAL + // we can use XOSC32K directly as the source + OSC32KCTRL->XOSC32K.bit.EN32K = 1; + OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK(1) | OSCCTRL_DPLLCTRLB_LBYPASS; +#else + // can't use OSCULP32K directly; need to setup a GCLK as a reference, + // which must be done in samd/clocks.c to avoid waiting for sync + return; + //OSC32KCTRL->OSCULP32K.bit.EN32K = 1; + //OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK(0); +#endif OSCCTRL->Dpll[1].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_ENABLE; while (!(OSCCTRL->Dpll[1].DPLLSTATUS.bit.LOCK || OSCCTRL->Dpll[1].DPLLSTATUS.bit.CLKRDY)) {} diff --git a/ports/nrf/README.md b/ports/nrf/README.md index 64f5b8aff5..88dd472738 100644 --- a/ports/nrf/README.md +++ b/ports/nrf/README.md @@ -5,21 +5,13 @@ This is a port of CircuitPython to the Nordic Semiconductor nRF52 series of chip > **NOTE**: There are board-specific READMEs that may be more up to date than the generic board-neutral documentation below. -## Compile and Flash - -Prerequisite steps for building the nrf port: - - git clone .git circuitpython - cd circuitpython - git submodule update --init --recursive - make -C mpy-cross +## Flash Some boards have UF2 bootloaders and can simply be flashed in the normal way, by copying firmware.uf2 to the BOOT drive. -To build and flash issue the following command inside the ports/nrf/ folder: +For some boards, you can use the `flash` target: - make BOARD=pca10056 make BOARD=pca10056 flash ## Segger Targets diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 1c9f1fcfaf..cee40a5a0c 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -59,8 +59,8 @@ const nvm_bytearray_obj_t common_hal_bleio_nvm_obj = { .base = { .type = &nvm_bytearray_type, }, - .len = CIRCUITPY_BLE_CONFIG_SIZE, .start_address = (uint8_t*) CIRCUITPY_BLE_CONFIG_START_ADDR, + .len = CIRCUITPY_BLE_CONFIG_SIZE, }; STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index c6d148234b..71bf6bc8f0 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -81,12 +81,10 @@ // firmware // internal CIRCUITPY flash filesystem (optional) // BLE config (bonding info, etc.) (optional) -// microntroller.nvm (optional) +// microcontroller.nvm (optional) // bootloader (note the MBR at 0x0 redirects to the bootloader here, in high flash) // bootloader settings -// Bootloader values from https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/master/src/linker/s140_v6.ld - // Define these regions starting up from the bottom of flash: #define MBR_START_ADDR (0x0) @@ -101,6 +99,7 @@ // Define these regions starting down from the bootloader: +// Bootloader values from https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/master/src/linker/s140_v6.ld #define BOOTLOADER_START_ADDR (0x000F4000) #define BOOTLOADER_SIZE (0xA000) // 40kiB #define BOOTLOADER_SETTINGS_START_ADDR (0x000FF000) diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h index 1d47142a83..3ab9a55853 100644 --- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h @@ -33,4 +33,4 @@ #define FLASH_PAGE_SIZE (0x4000) #define DEFAULT_I2C_BUS_SCL (&pin_PB10) -#define DEFAULT_I2C_BUS_SDA (&pin_PB09) \ No newline at end of file +#define DEFAULT_I2C_BUS_SDA (&pin_PB09) From 70d899d3540b39fa743c5f5aa81d5ab8b647b713 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 11 Dec 2019 17:58:21 -0500 Subject: [PATCH 172/531] WIP to successful USB test --- ports/stm32f4/Makefile | 2 +- ports/stm32f4/boards/STM32F401.ld | 106 +++++ ports/stm32f4/boards/STM32F401_boot.ld | 106 +++++ .../boards/meowbit_v121/mpconfigboard.h | 20 +- .../boards/meowbit_v121/mpconfigboard.mk | 12 +- ports/stm32f4/boards/meowbit_v121/pins.c | 8 +- ports/stm32f4/boards/startup_stm32f401xe.s | 448 ++++++++++++++++++ .../common-hal/microcontroller/__init__.c | 4 +- ports/stm32f4/peripherals/stm32f4/pins.h | 8 +- .../peripherals/stm32f4/stm32f401xe/clocks.c | 2 +- .../peripherals/stm32f4/stm32f401xe/gpio.c | 2 - ports/stm32f4/supervisor/port.c | 11 + 12 files changed, 694 insertions(+), 35 deletions(-) create mode 100644 ports/stm32f4/boards/STM32F401.ld create mode 100644 ports/stm32f4/boards/STM32F401_boot.ld create mode 100644 ports/stm32f4/boards/startup_stm32f401xe.s diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 2727ea954f..3943944ccb 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -22,7 +22,7 @@ # 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. -DEBUG = 1 +#DEBUG = 1 # Select the board to build for. ifeq ($(BOARD),) diff --git a/ports/stm32f4/boards/STM32F401.ld b/ports/stm32f4/boards/STM32F401.ld new file mode 100644 index 0000000000..b3d772a784 --- /dev/null +++ b/ports/stm32f4/boards/STM32F401.ld @@ -0,0 +1,106 @@ +/* + GNU linker script for STM32F401 with bootloader (such as the Meowbit) +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K - 64K /* entire flash, sans bootloader */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 64K /* sector 4, 0-3 used by bootloader*/ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 /* more bootloader schnenaigans */ +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 2K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +ENTRY(Reset_Handler) + +/* define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + + /* This first flash block is 16K annd 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. */ + + . = ALIGN(4); + } >FLASH_ISR + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + /* *(.glue_7) */ /* glue arm to thumb code */ + /* *(.glue_7t) */ /* glue thumb to arm code */ + + . = ALIGN(4); + _etext = .; /* define a global symbol at end of code */ + } >FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ + } >RAM AT> FLASH_TEXT + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + _sbss = .; /* define a global symbol at bss start; used by startup code */ + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ + } >RAM + + /* this is to define the start of the heap, and make sure we have a minimum size */ + .heap : + { + . = ALIGN(4); + . = . + _minimum_heap_size; + . = ALIGN(4); + } >RAM + + /* this just checks there is enough RAM for the stack */ + .stack : + { + . = ALIGN(4); + . = . + _minimum_stack_size; + . = ALIGN(4); + } >RAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/ports/stm32f4/boards/STM32F401_boot.ld b/ports/stm32f4/boards/STM32F401_boot.ld new file mode 100644 index 0000000000..7f582fdf9f --- /dev/null +++ b/ports/stm32f4/boards/STM32F401_boot.ld @@ -0,0 +1,106 @@ +/* + GNU linker script for STM32F401 with bootloader (such as the Meowbit) +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash, sans bootloader */ + FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4, 0-3 used by bootloader*/ + FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 /* more bootloader schnenaigans */ +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 2K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +ENTRY(Reset_Handler) + +/* define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + + /* This first flash block is 16K annd 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. */ + + . = ALIGN(4); + } >FLASH_ISR + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + /* *(.glue_7) */ /* glue arm to thumb code */ + /* *(.glue_7t) */ /* glue thumb to arm code */ + + . = ALIGN(4); + _etext = .; /* define a global symbol at end of code */ + } >FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ + } >RAM AT> FLASH_TEXT + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + _sbss = .; /* define a global symbol at bss start; used by startup code */ + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ + } >RAM + + /* this is to define the start of the heap, and make sure we have a minimum size */ + .heap : + { + . = ALIGN(4); + . = . + _minimum_heap_size; + . = ALIGN(4); + } >RAM + + /* this just checks there is enough RAM for the stack */ + .stack : + { + . = ALIGN(4); + . = . + _minimum_stack_size; + . = ALIGN(4); + } >RAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index b2d53d9999..f2fe3ca804 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -29,24 +29,14 @@ #define MICROPY_HW_BOARD_NAME "MEOWBIT" #define MICROPY_HW_MCU_NAME "STM32F401xE" -#define FLASH_SIZE (0x100000) +#define FLASH_SIZE (0x80000) #define FLASH_PAGE_SIZE (0x4000) #define AUTORESET_DELAY_MS 500 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) // On-board flash -#define SPI_FLASH_MOSI_PIN &pin_PB05 -#define SPI_FLASH_MISO_PIN &pin_PB04 -#define SPI_FLASH_SCK_PIN &pin_PB03 -#define SPI_FLASH_CS_PIN &pin_PA15 - -#define DEFAULT_I2C_BUS_SCL (&pin_PB06) -#define DEFAULT_I2C_BUS_SDA (&pin_PB07) - -#define DEFAULT_SPI_BUS_SCK (&pin_PB13) -#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) -#define DEFAULT_SPI_BUS_MISO (&pin_PB14) - -#define DEFAULT_UART_BUS_RX (&pin_PB11) -#define DEFAULT_UART_BUS_TX (&pin_PB10) +#define SPI_FLASH_MOSI_PIN (&pin_PB15) +#define SPI_FLASH_MISO_PIN (&pin_PB14) +#define SPI_FLASH_SCK_PIN (&pin_PB13) +#define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 7998e04523..8b605975d5 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -1,12 +1,12 @@ USB_VID = 0x239A USB_PID = 0x805A -USB_PRODUCT = "Feather STM32F405 Express" -USB_MANUFACTURER = "Adafruit Industries LLC" +USB_PRODUCT = "Meowbit" +USB_MANUFACTURER = "Kittenbot" USB_DEVICES = "CDC,MSC" SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = GD25Q16C +EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ LONGINT_IMPL = MPZ MCU_SERIES = m4 @@ -14,6 +14,6 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F405.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 \ No newline at end of file +LD_FILE = boards/STM32F401.ld +TEXT0_ADDR = 0x08010000 +TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 169fbf2744..dc0003dd15 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -1,11 +1,7 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - - - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) } }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/startup_stm32f401xe.s b/ports/stm32f4/boards/startup_stm32f401xe.s new file mode 100644 index 0000000000..815ac17197 --- /dev/null +++ b/ports/stm32f4/boards/startup_stm32f401xe.s @@ -0,0 +1,448 @@ +/** + ****************************************************************************** + * @file startup_stm32f401xe.s + * @author MCD Application Team + * @brief STM32F401xExx Devices vector table for GCC based toolchains. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + /* bl __libc_init_array */ +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + +g_pfnVectors: + .word _estack + .word Reset_Handler + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word 0 /* Reserved */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word 0 /* Reserved */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word FPU_IRQHandler /* FPU */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word SPI4_IRQHandler /* SPI4 */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c index ffab5d1e50..b9a3c16e4f 100644 --- a/ports/stm32f4/common-hal/microcontroller/__init__.c +++ b/ports/stm32f4/common-hal/microcontroller/__init__.c @@ -169,8 +169,8 @@ STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) }, #endif { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, -#if MCU_PACKAGE != 100 - { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, +#if (0) +// { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, #endif { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) }, diff --git a/ports/stm32f4/peripherals/stm32f4/pins.h b/ports/stm32f4/peripherals/stm32f4/pins.h index ced83562ec..e6a32b64e1 100644 --- a/ports/stm32f4/peripherals/stm32f4/pins.h +++ b/ports/stm32f4/peripherals/stm32f4/pins.h @@ -77,13 +77,17 @@ extern const mp_obj_type_t mcu_pin_type; #define NO_PIN 0xff // Choose based on chip -#ifdef STM32F412Zx -#include "stm32f412zx/pins.h" +#ifdef STM32F401xE +#include "stm32f401xe/pins.h" #endif #ifdef STM32F411xE #include "stm32f411xe/pins.h" #endif +#ifdef STM32F412Zx +#include "stm32f412zx/pins.h" +#endif #ifdef STM32F405xx #include "stm32f405xx/pins.h" #endif + #endif // __MICROPY_INCLUDED_STM32F4_PERIPHERALS_PINS_H__ diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c index 883c252d51..53af29b3b7 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c @@ -44,7 +44,7 @@ void stm32f4_peripherals_clocks_init(void) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLM = 12; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLQ = 7; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c index 45dc8fc6fa..28afee5d8e 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c @@ -29,8 +29,6 @@ #include "common-hal/microcontroller/Pin.h" void stm32f4_peripherals_gpio_init(void) { - //Enable all GPIO for now - GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c index df5a70cd12..3962f6fa62 100644 --- a/ports/stm32f4/supervisor/port.c +++ b/ports/stm32f4/supervisor/port.c @@ -52,6 +52,17 @@ safe_mode_t port_init(void) { tick_init(); board_init(); + //Configure LED pins + GPIO_InitTypeDef GPIO_InitStruct = {0}; + GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); + return NO_SAFE_MODE; } From 8c841af9461eba6252690c38bc3e726f2fd09e8b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 11 Dec 2019 22:04:10 -0600 Subject: [PATCH 173/531] MP3File: Avoid crash in get_buffer when deinitted When a playing mp3 is deinitted, it's possible to reach get_buffer, but all the internal pointers are NULL. This would lead to a hard fault. Avoid it by returning GET_BUFFER_ERROR instead. --- shared-module/audiomp3/MP3File.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index cabb461056..f0c4adc263 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -227,6 +227,9 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* uint8_t channel, uint8_t** bufptr, uint32_t* buffer_length) { + if (!self->inbuf) { + return GET_BUFFER_ERROR; + } if (!single_channel) { channel = 0; } From fd03fd5e4f7d6a7fb5e126a5e56955e73a0d0711 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 12 Dec 2019 00:19:03 -0500 Subject: [PATCH 174/531] sd_flash_operation_status should be volatile --- ports/nrf/bluetooth/ble_drv.c | 2 +- ports/nrf/bluetooth/ble_drv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index 63d67a7f4a..7dbb315826 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.c @@ -43,7 +43,7 @@ nrf_nvic_state_t nrf_nvic_state = { 0 }; // Flag indicating progress of internal flash operation. -sd_flash_operation_status_t sd_flash_operation_status; +volatile sd_flash_operation_status_t sd_flash_operation_status; __attribute__((aligned(4))) static uint8_t m_ble_evt_buf[sizeof(ble_evt_t) + (BLE_GATT_ATT_MTU_DEFAULT)]; diff --git a/ports/nrf/bluetooth/ble_drv.h b/ports/nrf/bluetooth/ble_drv.h index 7716cab8be..91990da6df 100644 --- a/ports/nrf/bluetooth/ble_drv.h +++ b/ports/nrf/bluetooth/ble_drv.h @@ -59,7 +59,7 @@ typedef enum { } sd_flash_operation_status_t; // Flag indicating progress of internal flash operation. -extern sd_flash_operation_status_t sd_flash_operation_status; +extern volatile sd_flash_operation_status_t sd_flash_operation_status; typedef struct ble_drv_evt_handler_entry { struct ble_drv_evt_handler_entry *next; From 1e95466bac139028efbb44e82cacf757d284b905 Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Thu, 12 Dec 2019 07:48:50 -0500 Subject: [PATCH 175/531] Add teknikio_bluebird to build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fd816b30b..b5ee03a02d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,6 +153,7 @@ jobs: - "stm32f411ve_discovery" - "stm32f412zg_discovery" - "stringcar_m0_express" + - "teknikio_bluebird" - "trellis_m4_express" - "trinket_m0" - "trinket_m0_haxpress" From 1cdac3f16a9244c992e8494a7246ab643cdb47c0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 12 Dec 2019 08:44:15 -0600 Subject: [PATCH 176/531] MP3File: Fix stereo playback on samd AudioOut There were several problems with the way this worked -- the read_count approach was too complicated and I made a mistake "simplifying" it from WaveFile. And when the right channel was returned, it was off by 1 byte, making it into static. Instead, directly track which is the "other" channel that has data available, and by using the right data type make the "+ channel" arithmetic give the right result. This requires a double cast (int16_t*)(void*) due to an alignment warning; the alignment is now ensured manually, but the compiler doesn't make the necessary inference that the low address bit must be clear. --- shared-module/audiomp3/MP3File.c | 46 +++++++++++++++++++------------- shared-module/audiomp3/MP3File.h | 6 ++--- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index f0c4adc263..f4861da360 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -151,10 +151,13 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, self->channel_count = fi.nChans; self->frame_buffer_size = fi.outputSamps*sizeof(int16_t); + if ((intptr_t)buffer & 1) { + buffer += 1; buffer_size -= 1; + } if (buffer_size >= 2 * self->frame_buffer_size) { self->len = buffer_size / 2 / self->frame_buffer_size * self->frame_buffer_size; - self->buffers[0] = buffer; - self->buffers[1] = buffer + self->len; + self->buffers[0] = (int16_t*)(void*)buffer; + self->buffers[1] = (int16_t*)(void*)buffer + self->len; } else { self->len = 2 * self->frame_buffer_size; self->buffers[0] = m_malloc(self->len, false); @@ -218,6 +221,7 @@ void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t* self, f_lseek(&self->file->fp, 0); self->inbuf_offset = self->inbuf_length; self->eof = 0; + self->other_channel = -1; mp3file_update_inbuf(self); mp3file_find_sync_word(self); } @@ -234,26 +238,30 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* channel = 0; } - uint16_t channel_read_count = self->channel_read_count[channel]++; - bool need_more_data = self->read_count++ == channel_read_count; - - *bufptr = self->buffers[self->buffer_index] + channel; + *bufptr = (uint8_t*)(self->buffers[self->buffer_index] + channel); *buffer_length = self->frame_buffer_size; - if (need_more_data) { - self->buffer_index = !self->buffer_index; - int16_t *buffer = (int16_t *)(void *)self->buffers[self->buffer_index]; + if (channel == self->other_channel) { + *bufptr = (uint8_t*)(self->buffers[self->other_buffer_index] + channel); + self->other_channel = -1; + return GET_BUFFER_MORE_DATA; + } - if (!mp3file_find_sync_word(self)) { - return self->eof ? GET_BUFFER_DONE : GET_BUFFER_ERROR; - } - int bytes_left = BYTES_LEFT(self); - uint8_t *inbuf = READ_PTR(self); - int err = MP3Decode(self->decoder, &inbuf, &bytes_left, buffer, 0); - CONSUME(self, BYTES_LEFT(self) - bytes_left); - if (err) { - return GET_BUFFER_DONE; - } + self->other_channel = 1-channel; + self->other_buffer_index = self->buffer_index; + + self->buffer_index = !self->buffer_index; + int16_t *buffer = (int16_t *)(void *)self->buffers[self->buffer_index]; + + if (!mp3file_find_sync_word(self)) { + return self->eof ? GET_BUFFER_DONE : GET_BUFFER_ERROR; + } + int bytes_left = BYTES_LEFT(self); + uint8_t *inbuf = READ_PTR(self); + int err = MP3Decode(self->decoder, &inbuf, &bytes_left, buffer, 0); + CONSUME(self, BYTES_LEFT(self) - bytes_left); + if (err) { + return GET_BUFFER_DONE; } return GET_BUFFER_MORE_DATA; diff --git a/shared-module/audiomp3/MP3File.h b/shared-module/audiomp3/MP3File.h index 12649ac1ad..9d99e8d1f0 100644 --- a/shared-module/audiomp3/MP3File.h +++ b/shared-module/audiomp3/MP3File.h @@ -39,7 +39,7 @@ typedef struct { uint8_t* inbuf; uint32_t inbuf_length; uint32_t inbuf_offset; - uint8_t* buffers[2]; + int16_t* buffers[2]; uint32_t len; uint32_t frame_buffer_size; @@ -50,8 +50,8 @@ typedef struct { uint8_t channel_count; bool eof; - uint16_t read_count; - uint16_t channel_read_count[2]; + int8_t other_channel; + int8_t other_buffer_index; } audiomp3_mp3file_obj_t; // These are not available from Python because it may be called in an interrupt. From 1244125bdcf6500a01b24773cf798fe01eee4c63 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 12:21:00 -0500 Subject: [PATCH 177/531] update tinyusb --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index e413c9efa3..7a05b177a4 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit e413c9efa303d70de019a91aa415384fe80ca78f +Subproject commit 7a05b177a43b368fea1d60ca344fe4ae9902a432 From 885a1415d0b9b223ce8f77ea4e4d773c2eb28a5c Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 12:47:40 -0500 Subject: [PATCH 178/531] Update stm32 usb.c --- ports/stm32f4/supervisor/usb.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index f327050f58..6e9b233a47 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -32,6 +32,8 @@ #include "lib/mp-readline/readline.h" #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" + #include "common-hal/microcontroller/Pin.h" void init_usb_hardware(void) { @@ -79,7 +81,21 @@ void init_usb_hardware(void) { HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); never_reset_pin_number(0, 8); #endif + +#ifdef BOARD_NO_VBUS + disable_usb_vbus(); +#endif /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); } + +STATIC void disable_usb_vbus(void) { +#ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; +#else + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; +#endif +} From d44a758a2d9066dfb369ccdf1f6ed82e0b6e3c13 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 12:48:37 -0500 Subject: [PATCH 179/531] Add no VBUS option to blackpill --- ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index a438b5baa6..b8e374f05b 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,6 +33,7 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 +#define BOARD_NO_VBUS // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) From 9339903a30908fcf4f1e06dfa466d72761c62955 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 13:24:46 -0500 Subject: [PATCH 180/531] Revert "delete old boards" This reverts commit 00e953e86cb1871a29b3e4329c1de816f7a1d897. --- ports/stm32f4/boards/pyb_nano_v2/board.c | 39 ++ .../boards/pyb_nano_v2/mpconfigboard.h | 52 +++ .../boards/pyb_nano_v2/mpconfigboard.mk | 19 + ports/stm32f4/boards/pyb_nano_v2/pins.c | 33 ++ .../boards/pyb_nano_v2/stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ .../boards/stm32f411ce_blackpill/board.c | 39 ++ .../stm32f411ce_blackpill/mpconfigboard.h | 52 +++ .../stm32f411ce_blackpill/mpconfigboard.mk | 19 + .../boards/stm32f411ce_blackpill/pins.c | 33 ++ .../stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ 10 files changed, 1166 insertions(+) create mode 100644 ports/stm32f4/boards/pyb_nano_v2/board.c create mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h create mode 100644 ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/pyb_nano_v2/pins.c create mode 100644 ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/board.c create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/pins.c create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h diff --git a/ports/stm32f4/boards/pyb_nano_v2/board.c b/ports/stm32f4/boards/pyb_nano_v2/board.c new file mode 100644 index 0000000000..82b0c506ed --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h new file mode 100644 index 0000000000..67ddc885ae --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define AUTORESET_DELAY_MS 500 +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PB05 +#define SPI_FLASH_MISO_PIN &pin_PB04 +#define SPI_FLASH_SCK_PIN &pin_PB03 +#define SPI_FLASH_CS_PIN &pin_PA15 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PB11) +#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk new file mode 100644 index 0000000000..5bad4e81f3 --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x805A +USB_PRODUCT = "Feather STM32F405 Express" +USB_MANUFACTURER = "Adafruit Industries LLC" +USB_DEVICES = "CDC,MSC" + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f405xx +MCU_PACKAGE = 64 +CMSIS_MCU = STM32F405xx +LD_FILE = boards/STM32F405.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/pyb_nano_v2/pins.c b/ports/stm32f4/boards/pyb_nano_v2/pins.c new file mode 100644 index 0000000000..4aa1f362ad --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/pins.c @@ -0,0 +1,33 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..68a49b4ba8 --- /dev/null +++ b/ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h @@ -0,0 +1,440 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)40000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/board.c b/ports/stm32f4/boards/stm32f411ce_blackpill/board.c new file mode 100644 index 0000000000..82b0c506ed --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h new file mode 100644 index 0000000000..67ddc885ae --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define AUTORESET_DELAY_MS 500 +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PB05 +#define SPI_FLASH_MISO_PIN &pin_PB04 +#define SPI_FLASH_SCK_PIN &pin_PB03 +#define SPI_FLASH_CS_PIN &pin_PA15 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PB11) +#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk new file mode 100644 index 0000000000..5bad4e81f3 --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x805A +USB_PRODUCT = "Feather STM32F405 Express" +USB_MANUFACTURER = "Adafruit Industries LLC" +USB_DEVICES = "CDC,MSC" + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f405xx +MCU_PACKAGE = 64 +CMSIS_MCU = STM32F405xx +LD_FILE = boards/STM32F405.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c new file mode 100644 index 0000000000..4aa1f362ad --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c @@ -0,0 +1,33 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..68a49b4ba8 --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h @@ -0,0 +1,440 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)40000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 63046d800d64081a4f7756476f5249179179ff5e Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 19 Aug 2019 15:50:02 +1000 Subject: [PATCH 181/531] py: Introduce MP_UNREACHABLE macro to annotate unreachable code. And use it to replace the same pattern at the end of nlrthumb.c:nlr_jump. --- py/mpconfig.h | 9 +++++++++ py/nlrthumb.c | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/py/mpconfig.h b/py/mpconfig.h index 3ec383817e..a0d211bfaa 100755 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1440,6 +1440,15 @@ typedef double mp_float_t; #define MP_UNLIKELY(x) __builtin_expect((x), 0) #endif +// To annotate that code is unreachable +#ifndef MP_UNREACHABLE +#if defined(__GNUC__) +#define MP_UNREACHABLE __builtin_unreachable(); +#else +#define MP_UNREACHABLE for (;;); +#endif +#endif + #ifndef MP_HTOBE16 #if MP_ENDIANNESS_LITTLE # define MP_HTOBE16(x) ((uint16_t)( (((x) & 0xff) << 8) | (((x) >> 8) & 0xff) )) diff --git a/py/nlrthumb.c b/py/nlrthumb.c index 69d3f868af..eb32e2ce5b 100644 --- a/py/nlrthumb.c +++ b/py/nlrthumb.c @@ -127,11 +127,7 @@ NORETURN void nlr_jump(void *val) { : // clobbered registers ); - #if defined(__GNUC__) - __builtin_unreachable(); - #else - for (;;); // needed to silence compiler warning - #endif + MP_UNREACHABLE } #endif // MICROPY_NLR_THUMB From 1cf0ce094a4a1571b7404643e7a3b992592317a5 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 19 Aug 2019 15:51:40 +1000 Subject: [PATCH 182/531] py/nlr: Use MP_UNREACHABLE at the end of arch-specific nlr_jump funcs. Recent versions of gcc perform optimisations which can lead to the following code from the MP_NLR_JUMP_HEAD macro being omitted: top->ret_val = val; \ MP_NLR_RESTORE_PYSTACK(top); \ *_top_ptr = top->prev; \ This is noticeable (at least) in the unix coverage on x86-64 built with gcc 9.1.0. This is because the nlr_jump function is marked as no-return, so gcc deduces that the above code has no effect. Adding MP_UNREACHABLE tells the compiler that the asm code may branch elsewhere, and so it cannot optimise away the code. --- py/nlrx64.c | 2 +- py/nlrx86.c | 2 +- py/nlrxtensa.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/py/nlrx64.c b/py/nlrx64.c index 9b2b22c225..569ad84fb0 100644 --- a/py/nlrx64.c +++ b/py/nlrx64.c @@ -108,7 +108,7 @@ NORETURN void nlr_jump(void *val) { : // clobbered registers ); - for (;;); // needed to silence compiler warning + MP_UNREACHABLE } #endif // MICROPY_NLR_X64 diff --git a/py/nlrx86.c b/py/nlrx86.c index 4900a4c0d2..6fbbe44327 100644 --- a/py/nlrx86.c +++ b/py/nlrx86.c @@ -100,7 +100,7 @@ NORETURN void nlr_jump(void *val) { : // clobbered registers ); - for (;;); // needed to silence compiler warning + MP_UNREACHABLE } #endif // MICROPY_NLR_X86 diff --git a/py/nlrxtensa.c b/py/nlrxtensa.c index d66c7a9a7f..5640350043 100644 --- a/py/nlrxtensa.c +++ b/py/nlrxtensa.c @@ -77,7 +77,7 @@ NORETURN void nlr_jump(void *val) { : // clobbered registers ); - for (;;); // needed to silence compiler warning + MP_UNREACHABLE } #endif // MICROPY_NLR_XTENSA From 767d47dd6025e8046b03e6b307fd0ba6a81cf504 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 17 Jun 2019 23:19:34 +1000 Subject: [PATCH 183/531] py/nlrthumb: Save and restore VFP registers s16-s21 when CPU has them. These s16-s21 registers are used by gcc so need to be saved. Future versions of gcc (beyond v9.1.0), or other compilers, may eventually need additional registers saved/restored. See issue #4844. --- py/nlr.h | 9 ++++++++- py/nlrthumb.c | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/py/nlr.h b/py/nlr.h index b442aaf8a0..1b95002d3b 100644 --- a/py/nlr.h +++ b/py/nlr.h @@ -54,7 +54,14 @@ #endif #elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__) #define MICROPY_NLR_THUMB (1) - #define MICROPY_NLR_NUM_REGS (10) + #if defined(__SOFTFP__) + #define MICROPY_NLR_NUM_REGS (10) + #else + // With hardware FP registers s16-s31 are callee save so in principle + // should be saved and restored by the NLR code. gcc only uses s16-s21 + // so only save/restore those as an optimisation. + #define MICROPY_NLR_NUM_REGS (10 + 6) + #endif #elif defined(__xtensa__) #define MICROPY_NLR_XTENSA (1) #define MICROPY_NLR_NUM_REGS (10) diff --git a/py/nlrthumb.c b/py/nlrthumb.c index eb32e2ce5b..056aa358e7 100644 --- a/py/nlrthumb.c +++ b/py/nlrthumb.c @@ -63,6 +63,11 @@ __attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) { "str r10, [r0, #36] \n" // store r10 into nlr_buf "str r11, [r0, #40] \n" // store r11 into nlr_buf "str r13, [r0, #44] \n" // store r13=sp into nlr_buf + #if MICROPY_NLR_NUM_REGS == 16 + "vstr d8, [r0, #48] \n" // store s16-s17 into nlr_buf + "vstr d9, [r0, #56] \n" // store s18-s19 into nlr_buf + "vstr d10, [r0, #64] \n" // store s20-s21 into nlr_buf + #endif "str lr, [r0, #8] \n" // store lr into nlr_buf #endif @@ -118,6 +123,11 @@ NORETURN void nlr_jump(void *val) { "ldr r10, [r0, #36] \n" // load r10 from nlr_buf "ldr r11, [r0, #40] \n" // load r11 from nlr_buf "ldr r13, [r0, #44] \n" // load r13=sp from nlr_buf + #if MICROPY_NLR_NUM_REGS == 16 + "vldr d8, [r0, #48] \n" // load s16-s17 from nlr_buf + "vldr d9, [r0, #56] \n" // load s18-s19 from nlr_buf + "vldr d10, [r0, #64] \n" // load s20-s21 from nlr_buf + #endif "ldr lr, [r0, #8] \n" // load lr from nlr_buf #endif "movs r0, #1 \n" // return 1, non-local return From 7889b999ccb32b78ddabc2b2738f0a9d182b9411 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 12 Dec 2019 14:35:24 -0500 Subject: [PATCH 184/531] Fix flash write error handling; clean up safe mode message printing --- main.c | 4 +- ports/nrf/common-hal/nvm/ByteArray.c | 11 +++- ports/nrf/peripherals/nrf/nvm.c | 15 ++--- ports/nrf/peripherals/nrf/nvm.h | 2 +- ports/nrf/supervisor/internal_flash.c | 6 +- supervisor/shared/safe_mode.c | 80 ++++++++++++++++++--------- supervisor/shared/safe_mode.h | 3 +- 7 files changed, 78 insertions(+), 43 deletions(-) diff --git a/main.c b/main.c index a6c7c05816..2bbfd1be0c 100755 --- a/main.c +++ b/main.c @@ -264,9 +264,7 @@ bool run_code_py(safe_mode_t safe_mode) { rgb_status_animation_t animation; prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { - #ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP - #endif + RUN_BACKGROUND_TASKS; if (reload_requested) { reload_requested = false; return true; diff --git a/ports/nrf/common-hal/nvm/ByteArray.c b/ports/nrf/common-hal/nvm/ByteArray.c index ee270f79bb..bace8221c8 100644 --- a/ports/nrf/common-hal/nvm/ByteArray.c +++ b/ports/nrf/common-hal/nvm/ByteArray.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "py/runtime.h" #include "common-hal/nvm/ByteArray.h" #include @@ -43,16 +44,20 @@ uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { } static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) { - // Write a whole page to flash, buffering it first and then erasing and rewriting + // Write a whole page to flash, buffering it first and then erasing and rewriting // it since we can only clear a whole page at a time. + bool status; if (offset == 0 && len == FLASH_PAGE_SIZE) { - nrf_nvm_safe_flash_page_write(page_addr, bytes); + status = nrf_nvm_safe_flash_page_write(page_addr, bytes); } else { uint8_t buffer[FLASH_PAGE_SIZE]; memcpy(buffer, (uint8_t *)page_addr, FLASH_PAGE_SIZE); memcpy(buffer + offset, bytes, len); - nrf_nvm_safe_flash_page_write(page_addr, buffer); + status = nrf_nvm_safe_flash_page_write(page_addr, buffer); + } + if (!status) { + mp_raise_OSError_msg(translate("Flash write failed")); } } diff --git a/ports/nrf/peripherals/nrf/nvm.c b/ports/nrf/peripherals/nrf/nvm.c index d8fddc4dcf..7118b9c870 100644 --- a/ports/nrf/peripherals/nrf/nvm.c +++ b/ports/nrf/peripherals/nrf/nvm.c @@ -50,7 +50,7 @@ STATIC sd_flash_operation_status_t sd_flash_operation_wait_until_done(void) { } #endif -void nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { +bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { #ifdef BLUETOOTH_SD uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); @@ -61,11 +61,11 @@ void nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { sd_flash_operation_start(); err_code = sd_flash_page_erase(page_addr / FLASH_PAGE_SIZE); if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Flash erase failed to start, err 0x%04x"), err_code); + return false; } status = sd_flash_operation_wait_until_done(); if (status == SD_FLASH_OPERATION_ERROR) { - mp_raise_OSError_msg(translate("Flash erase failed")); + return false; } // Divide a full page into parts, because writing a full page causes an assertion failure. @@ -78,18 +78,19 @@ void nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { (uint32_t *)data + i * words_to_write, words_to_write); if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Flash write failed to start, err 0x%04x"), err_code); + return false; } status = sd_flash_operation_wait_until_done(); if (status == SD_FLASH_OPERATION_ERROR) { - mp_raise_OSError_msg(translate("Flash write failed")); + return false; } } - return; + return true; } #endif nrf_nvmc_page_erase(page_addr); nrf_nvmc_write_bytes(page_addr, data, FLASH_PAGE_SIZE); -} + return true; +} diff --git a/ports/nrf/peripherals/nrf/nvm.h b/ports/nrf/peripherals/nrf/nvm.h index 4eac3d7283..c1a2a76dad 100644 --- a/ports/nrf/peripherals/nrf/nvm.h +++ b/ports/nrf/peripherals/nrf/nvm.h @@ -31,4 +31,4 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (0) #endif -void nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data); +bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data); diff --git a/ports/nrf/supervisor/internal_flash.c b/ports/nrf/supervisor/internal_flash.c index dcacd4d27f..4688e0ceeb 100644 --- a/ports/nrf/supervisor/internal_flash.c +++ b/ports/nrf/supervisor/internal_flash.c @@ -34,6 +34,7 @@ #include "py/obj.h" #include "py/runtime.h" #include "lib/oofatfs/ff.h" +#include "supervisor/shared/safe_mode.h" #include "peripherals/nrf/nvm.h" @@ -75,7 +76,9 @@ void supervisor_flash_flush(void) { // Skip if data is the same if (memcmp(_flash_cache, (void *)_flash_page_addr, FLASH_PAGE_SIZE) != 0) { - nrf_nvm_safe_flash_page_write(_flash_page_addr, _flash_cache); + if (!nrf_nvm_safe_flash_page_write(_flash_page_addr, _flash_cache)) { + reset_into_safe_mode(FLASH_WRITE_FAIL); + } } } @@ -120,4 +123,3 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32 void supervisor_flash_release_cache(void) { } - diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 363181da06..9e3b864028 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -94,44 +94,72 @@ void __attribute__((noinline,)) reset_into_safe_mode(safe_mode_t reason) { reset_cpu(); } + + +#define FILE_AN_ISSUE translate("\r\nPlease file an issue with the contents of your CIRCUITPY drive at \nhttps://github.com/adafruit/circuitpython/issues\r\n") + void print_safe_mode_message(safe_mode_t reason) { if (reason == NO_SAFE_MODE) { return; } serial_write("\r\n"); - // Output a user safe mode string if its set. + // Output a user safe mode string if it's set. #ifdef BOARD_USER_SAFE_MODE if (reason == USER_SAFE_MODE) { serial_write_compressed(translate("You requested starting safe mode by ")); serial_write(BOARD_USER_SAFE_MODE_ACTION); - serial_write("\r\n"); - serial_write_compressed(translate("To exit, please reset the board without ")); + serial_write_compressed(translate("\r\nTo exit, please reset the board without ")); serial_write(BOARD_USER_SAFE_MODE_ACTION); serial_write("\r\n"); } else #endif - if (reason == MANUAL_SAFE_MODE) { - serial_write_compressed(translate("The reset button was pressed while booting CircuitPython. Press again to exit safe mode.\n")); - } else if (reason == PROGRAMMATIC_SAFE_MODE) { - serial_write_compressed(translate("The `microcontroller` module was used to boot into safe mode. Press reset to exit safe mode.\n")); - } else { - serial_write_compressed(translate("You are running in safe mode which means something unanticipated happened.\n")); - if (reason == HARD_CRASH || reason == MICROPY_NLR_JUMP_FAIL || reason == MICROPY_FATAL_ERROR || reason == GC_ALLOC_OUTSIDE_VM) { - serial_write_compressed(translate("Looks like our core CircuitPython code crashed hard. Whoops!\nPlease file an issue at https://github.com/adafruit/circuitpython/issues\n with the contents of your CIRCUITPY drive and this message:\n")); - if (reason == HARD_CRASH) { - serial_write_compressed(translate("Crash into the HardFault_Handler.\n")); - } else if (reason == MICROPY_NLR_JUMP_FAIL) { - serial_write_compressed(translate("MicroPython NLR jump failed. Likely memory corruption.\n")); - } else if (reason == MICROPY_FATAL_ERROR) { - serial_write_compressed(translate("MicroPython fatal error.\n")); - } else if (reason == GC_ALLOC_OUTSIDE_VM) { - serial_write_compressed(translate("Attempted heap allocation when MicroPython VM not running.\n")); - } - } else if (reason == BROWNOUT) { - serial_write_compressed(translate("The microcontroller's power dipped. Please make sure your power supply provides\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\n")); - } else if (reason == HEAP_OVERWRITTEN) { - serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\nPlease increase stack size limits and press reset (after ejecting CIRCUITPY).\nIf you didn't change the stack, then file an issue here with the contents of your CIRCUITPY drive:\n")); - serial_write("https://github.com/adafruit/circuitpython/issues\r\n"); + switch (reason) { + case MANUAL_SAFE_MODE: + serial_write_compressed(translate("CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.\r\n")); + return; + case PROGRAMMATIC_SAFE_MODE: + serial_write_compressed(translate("The `microcontroller` module was used to boot into safe mode. Press reset to exit safe mode.\r\n")); + return; + default: + break; } - } + + serial_write_compressed(translate("You are in safe mode: something unanticipated happened.\r\n")); + switch (reason) { + case BROWNOUT: + serial_write_compressed(translate("The microcontroller's power dipped. Make sure your power supply provides\r\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\r\n")); + return; + case HEAP_OVERWRITTEN: + serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\r\nPlease increase the stack size if you know how, or if not:")); + serial_write_compressed(FILE_AN_ISSUE); + return; + default: + break; + } + + serial_write_compressed(translate("CircuitPython core code crashed hard. Whoops!\r\n")); + switch (reason) { + case HARD_CRASH: + serial_write_compressed(translate("Crash into the HardFault_Handler.")); + return; + case MICROPY_NLR_JUMP_FAIL: + serial_write_compressed(translate("MicroPython NLR jump failed. Likely memory corruption.")); + return; + case MICROPY_FATAL_ERROR: + serial_write_compressed(translate("MicroPython fatal error.")); + break; + case GC_ALLOC_OUTSIDE_VM: + serial_write_compressed(translate("Attempted heap allocation when MicroPython VM not running.")); + break; + case NORDIC_SOFT_DEVICE_ASSERT: + serial_write_compressed(translate("Nordic Soft Device failure assertion.")); + break; + case FLASH_WRITE_FAIL: + serial_write_compressed(translate("Failed to write internal flash.")); + break; + default: + serial_write_compressed(translate("Unknown reason.")); + break; + } + serial_write_compressed(FILE_AN_ISSUE); } diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h index 8c5dcd9c5d..e05fca0e46 100644 --- a/supervisor/shared/safe_mode.h +++ b/supervisor/shared/safe_mode.h @@ -38,7 +38,8 @@ typedef enum { MICROPY_FATAL_ERROR, GC_ALLOC_OUTSIDE_VM, PROGRAMMATIC_SAFE_MODE, - NORDIC_SOFT_DEVICE_ASSERT + NORDIC_SOFT_DEVICE_ASSERT, + FLASH_WRITE_FAIL, } safe_mode_t; safe_mode_t wait_for_safe_mode_reset(void); From 1b3028bed139149247ff5e692f24ec5356450f83 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 12 Dec 2019 14:51:50 -0500 Subject: [PATCH 185/531] make translate and remove backslash-r's --- locale/ID.po | 116 ++++++++++++--------- locale/circuitpython.pot | 89 ++++++++-------- locale/de_DE.po | 176 +++++++++++++++++++------------ locale/en_US.po | 89 ++++++++-------- locale/en_x_pirate.po | 89 ++++++++-------- locale/es.po | 191 ++++++++++++++++++++++------------ locale/fil.po | 168 +++++++++++++++++++----------- locale/fr.po | 190 +++++++++++++++++++++------------ locale/it_IT.po | 130 ++++++++++++++--------- locale/ko.po | 89 ++++++++-------- locale/pl.po | 182 ++++++++++++++++++++------------ locale/pt_BR.po | 92 ++++++++-------- locale/zh_Latn_pinyin.po | 185 ++++++++++++++++++++------------ supervisor/shared/safe_mode.c | 20 ++-- 14 files changed, 1073 insertions(+), 733 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 4be18ec0de..c147a5f5f9 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,6 +23,19 @@ msgid "" "Code done running. Waiting for reload.\n" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr "" @@ -294,7 +307,7 @@ msgid "Array values should be single bytes." msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -454,6 +467,16 @@ msgstr "" msgid "CharacteristicBuffer writing not provided" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "" @@ -515,7 +538,7 @@ msgid "Couldn't allocate second buffer" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -632,28 +655,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -826,13 +839,6 @@ msgstr "" msgid "Length must be non-negative" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "" @@ -847,11 +853,11 @@ msgid "Maximum x value when mirrored is %d" msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" +msgid "MicroPython fatal error." msgstr "" #: shared-bindings/audiobusio/PDMIn.c @@ -920,6 +926,10 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -1103,10 +1113,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" #: supervisor/shared/safe_mode.c @@ -1116,21 +1123,11 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -#, fuzzy msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"Tegangan dari mikrokontroler turun atau mati. Pastikan sumber tegangan " -"memberikan daya\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1164,10 +1161,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Untuk keluar, silahkan reset board tanpa " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Terlalu banyak channel dalam sampel" @@ -1246,6 +1239,10 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1323,12 +1320,8 @@ msgstr "" "Untuk menampilkan modul built-in silahkan ketik `help(\"modules\")`.\n" #: supervisor/shared/safe_mode.c -#, fuzzy -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" -"Anda sedang menjalankan mode aman (safe mode) yang berarti sesuatu yang " -"sangat buruk telah terjadi.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2853,6 +2846,19 @@ msgstr "" #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Dukungan soft device, id: 0x%08lX, pc: 0x%08l" +#, fuzzy +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "Tegangan dari mikrokontroler turun atau mati. Pastikan sumber tegangan " +#~ "memberikan daya\n" + +#~ msgid "To exit, please reset the board without " +#~ msgstr "Untuk keluar, silahkan reset board tanpa " + #~ msgid "UART(%d) does not exist" #~ msgstr "UART(%d) tidak ada" @@ -2870,6 +2876,14 @@ msgstr "" #~ "Gunakan esptool untuk menghapus flash dan upload ulang Python sebagai " #~ "gantinya" +#, fuzzy +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "" +#~ "Anda sedang menjalankan mode aman (safe mode) yang berarti sesuatu yang " +#~ "sangat buruk telah terjadi.\n" + #~ msgid "[addrinfo error %d]" #~ msgstr "[addrinfo error %d]" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index f007202071..3b605d99fd 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,6 +23,19 @@ msgid "" "Code done running. Waiting for reload.\n" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr "" @@ -292,7 +305,7 @@ msgid "Array values should be single bytes." msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -444,6 +457,16 @@ msgstr "" msgid "CharacteristicBuffer writing not provided" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "" @@ -505,7 +528,7 @@ msgid "Couldn't allocate second buffer" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -621,28 +644,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -815,13 +828,6 @@ msgstr "" msgid "Length must be non-negative" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "" @@ -836,11 +842,11 @@ msgid "Maximum x value when mirrored is %d" msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" +msgid "MicroPython fatal error." msgstr "" #: shared-bindings/audiobusio/PDMIn.c @@ -909,6 +915,10 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1087,10 +1097,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" #: supervisor/shared/safe_mode.c @@ -1101,18 +1108,11 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" - #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" @@ -1145,10 +1145,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "" - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "" @@ -1227,6 +1223,10 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1297,8 +1297,7 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" #: supervisor/shared/safe_mode.c diff --git a/locale/de_DE.po b/locale/de_DE.po index 1756a7717e..f1158b1b3a 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -25,6 +25,19 @@ msgstr "" "\n" "Der Code wurde ausgeführt. Warte auf reload.\n" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " Datei \"%q\"" @@ -294,7 +307,7 @@ msgid "Array values should be single bytes." msgstr "Array-Werte sollten aus Einzelbytes bestehen." #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -448,6 +461,16 @@ msgstr "Kann nicht ohne MOSI-Pin schreiben." msgid "CharacteristicBuffer writing not provided" msgstr "Schreiben von CharacteristicBuffer ist nicht vorgesehen" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Clock pin init fehlgeschlagen." @@ -509,8 +532,8 @@ msgid "Couldn't allocate second buffer" msgstr "Konnte second buffer nicht zuteilen" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" -msgstr "Absturz in HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." +msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -625,28 +648,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Mutex konnte nicht freigegeben werden. Status: 0x%04x" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Datei existiert" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -823,17 +836,6 @@ msgstr "Länge muss ein int sein" msgid "Length must be non-negative" msgstr "Länge darf nicht negativ sein" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" -"Sieht aus, als wäre der CircuitPython-Kernel-Code abgestürzt. Uups!\n" -"Bitte melde das Problem unter https://github.com/adafruit/circuitpython/" -"issues\n" -"mit dem Inhalt deines CIRCUITPY-Laufwerks und dieser Nachricht:\n" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "MISO pin Initialisierung fehlgeschlagen" @@ -848,14 +850,12 @@ msgid "Maximum x value when mirrored is %d" msgstr "Maximaler x-Wert beim Spiegeln ist %d" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" -"MicroPython-NLR-Sprung ist fehlgeschlagen. Wahrscheinlich " -"Speicherbeschädigung.\n" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" -msgstr "Schwerwiegender MicroPython-Fehler\n" +msgid "MicroPython fatal error." +msgstr "" #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -924,6 +924,10 @@ msgstr "Kein Speicherplatz mehr verfügbar auf dem Gerät" msgid "No such file/directory" msgstr "Keine solche Datei/Verzeichnis" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1110,17 +1114,8 @@ msgstr "Stream fehlt readinto() oder write() Methode." #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" -"Der CircuitPython-Heap war beschädigt, weil der Stack zu klein war.\n" -"Bitte erhöhe die stack size limits und drücke die Reset-Taste (nach Auswurf " -"des CIRCUITPY-Laufwerks)\n" -"Wenn du den Stack nicht geändert hast, melde bitte das Problem unter https://" -"github.com/adafruit/circuitpython/issues\n" -"mit dem Inhalt deines CIRCUITPY-Laufwerks.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1132,23 +1127,10 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"Die Stromversorgung des Mikrocontrollers ist eingebrochen. Stelle sicher, " -"dass deine Stromversorgung genug Leistung für die gesamte Schaltung zur " -"Verfügung stellt und drücke die Reset-Taste (nach Auswurf des CIRCUITPY-" -"Laufwerks)\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" -"Die Reset-Taste wurde beim Booten von CircuitPython gedrückt. Drücke sie " -"erneut um den abgesicherten Modus zu verlassen. \n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1182,10 +1164,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Zum beenden, resette bitte das board ohne " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Zu viele Kanäle im sample" @@ -1264,6 +1242,10 @@ msgstr "Unerwarteter nrfx uuid-Typ" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1343,11 +1325,8 @@ msgstr "" "aus.\n" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" -"Sie laufen im abgesicherten Modus, was bedeutet, dass etwas Unerwartetes " -"passiert ist.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2737,6 +2716,9 @@ msgstr "" #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Konnte ble_uuid nicht decodieren. Status: 0x%04x" +#~ msgid "Crash into the HardFault_Handler.\n" +#~ msgstr "Absturz in HardFault_Handler.\n" + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Daten sind zu groß für das advertisement packet" @@ -2871,9 +2853,27 @@ msgstr "" #~ msgid "Invalid data pin" #~ msgstr "Ungültiger data pin" +#~ msgid "" +#~ "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ "Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +#~ " with the contents of your CIRCUITPY drive and this message:\n" +#~ msgstr "" +#~ "Sieht aus, als wäre der CircuitPython-Kernel-Code abgestürzt. Uups!\n" +#~ "Bitte melde das Problem unter https://github.com/adafruit/circuitpython/" +#~ "issues\n" +#~ "mit dem Inhalt deines CIRCUITPY-Laufwerks und dieser Nachricht:\n" + #~ msgid "Maximum PWM frequency is %dhz." #~ msgstr "Maximale PWM Frequenz ist %dHz" +#~ msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +#~ msgstr "" +#~ "MicroPython-NLR-Sprung ist fehlgeschlagen. Wahrscheinlich " +#~ "Speicherbeschädigung.\n" + +#~ msgid "MicroPython fatal error.\n" +#~ msgstr "Schwerwiegender MicroPython-Fehler\n" + #~ msgid "Minimum PWM frequency is 1hz." #~ msgstr "Minimale PWM Frequenz ist %dHz" @@ -2920,6 +2920,41 @@ msgstr "" #~ msgid "STA required" #~ msgstr "STA erforderlich" +#~ msgid "" +#~ "The CircuitPython heap was corrupted because the stack was too small.\n" +#~ "Please increase stack size limits and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ "If you didn't change the stack, then file an issue here with the contents " +#~ "of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Der CircuitPython-Heap war beschädigt, weil der Stack zu klein war.\n" +#~ "Bitte erhöhe die stack size limits und drücke die Reset-Taste (nach " +#~ "Auswurf des CIRCUITPY-Laufwerks)\n" +#~ "Wenn du den Stack nicht geändert hast, melde bitte das Problem unter " +#~ "https://github.com/adafruit/circuitpython/issues\n" +#~ "mit dem Inhalt deines CIRCUITPY-Laufwerks.\n" + +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "Die Stromversorgung des Mikrocontrollers ist eingebrochen. Stelle sicher, " +#~ "dass deine Stromversorgung genug Leistung für die gesamte Schaltung zur " +#~ "Verfügung stellt und drücke die Reset-Taste (nach Auswurf des CIRCUITPY-" +#~ "Laufwerks)\n" + +#~ msgid "" +#~ "The reset button was pressed while booting CircuitPython. Press again to " +#~ "exit safe mode.\n" +#~ msgstr "" +#~ "Die Reset-Taste wurde beim Booten von CircuitPython gedrückt. Drücke sie " +#~ "erneut um den abgesicherten Modus zu verlassen. \n" + +#~ msgid "To exit, please reset the board without " +#~ msgstr "Zum beenden, resette bitte das board ohne " + #~ msgid "UART(%d) does not exist" #~ msgstr "UART(%d) existiert nicht" @@ -2942,6 +2977,13 @@ msgstr "" #~ msgid "Voice index too high" #~ msgstr "Voice index zu hoch" +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "" +#~ "Sie laufen im abgesicherten Modus, was bedeutet, dass etwas Unerwartetes " +#~ "passiert ist.\n" + #~ msgid "buffer too long" #~ msgstr "Buffer zu lang" diff --git a/locale/en_US.po b/locale/en_US.po index 79940e95ed..c6f342186f 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -23,6 +23,19 @@ msgid "" "Code done running. Waiting for reload.\n" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr "" @@ -292,7 +305,7 @@ msgid "Array values should be single bytes." msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -444,6 +457,16 @@ msgstr "" msgid "CharacteristicBuffer writing not provided" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "" @@ -505,7 +528,7 @@ msgid "Couldn't allocate second buffer" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -621,28 +644,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -815,13 +828,6 @@ msgstr "" msgid "Length must be non-negative" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "" @@ -836,11 +842,11 @@ msgid "Maximum x value when mirrored is %d" msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" +msgid "MicroPython fatal error." msgstr "" #: shared-bindings/audiobusio/PDMIn.c @@ -909,6 +915,10 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1087,10 +1097,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" #: supervisor/shared/safe_mode.c @@ -1101,18 +1108,11 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" - #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" @@ -1145,10 +1145,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "" - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "" @@ -1227,6 +1223,10 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1297,8 +1297,7 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" #: supervisor/shared/safe_mode.c diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 9fe49ec9f1..54d246e2de 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -25,6 +25,19 @@ msgstr "" "\n" "Captin's orders are complete. Holdin' fast fer reload.\n" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr "" @@ -294,7 +307,7 @@ msgid "Array values should be single bytes." msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -448,6 +461,16 @@ msgstr "" msgid "CharacteristicBuffer writing not provided" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "" @@ -509,7 +532,7 @@ msgid "Couldn't allocate second buffer" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -625,28 +648,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -819,13 +832,6 @@ msgstr "" msgid "Length must be non-negative" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "" @@ -840,11 +846,11 @@ msgid "Maximum x value when mirrored is %d" msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" +msgid "MicroPython fatal error." msgstr "" #: shared-bindings/audiobusio/PDMIn.c @@ -913,6 +919,10 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1091,10 +1101,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" #: supervisor/shared/safe_mode.c @@ -1105,18 +1112,11 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" - #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" @@ -1149,10 +1149,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "" - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "" @@ -1231,6 +1227,10 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1301,8 +1301,7 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" #: supervisor/shared/safe_mode.c diff --git a/locale/es.po b/locale/es.po index b5c375481c..7ced099be5 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -25,6 +25,19 @@ msgstr "" "\n" "El código terminó su ejecución. Esperando para recargar.\n" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " Archivo \"%q\"" @@ -296,10 +309,8 @@ msgid "Array values should be single bytes." msgstr "Valores del array deben ser bytes individuales." #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" -"Intento de allocation de heap cuando la VM de MicroPython no estaba " -"corriendo.\n" #: main.c msgid "Auto-reload is off.\n" @@ -452,6 +463,16 @@ msgstr "No se puede escribir sin pin MOSI." msgid "CharacteristicBuffer writing not provided" msgstr "CharateristicBuffer escritura no proporcionada" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Clock pin init fallido" @@ -513,8 +534,8 @@ msgid "Couldn't allocate second buffer" msgstr "No se pudo asignar el segundo buffer" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" -msgstr "Choque en el HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." +msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -629,28 +650,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "No se puede liberar el mutex, err 0x%04x" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "El archivo ya existe" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "Falló borrado de flash" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "Falló el iniciar borrado de flash, err 0x%04x" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "Falló la escritura" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "Falló el iniciar la escritura de flash, err 0x%04x" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "Frecuencia capturada por encima de la capacidad. Captura en pausa." @@ -825,17 +836,6 @@ msgstr "Length debe ser un int" msgid "Length must be non-negative" msgstr "Longitud no deberia ser negativa" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" -"Parece que nuestro código de CircuitPython ha fallado con fuerza. Whoops!\n" -"Por favor, crea un issue en https://github.com/adafruit/circuitpython/" -"issues\n" -" con el contenido de su unidad CIRCUITPY y este mensaje:\n" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "MISO pin init fallido." @@ -850,12 +850,12 @@ msgid "Maximum x value when mirrored is %d" msgstr "Valor máximo de x cuando se refleja es %d" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" -msgstr "MicroPython NLR salto fallido. Probable corrupción de memoria.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." +msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" -msgstr "Error fatal de MicroPython.\n" +msgid "MicroPython fatal error." +msgstr "" #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -923,6 +923,10 @@ msgstr "No queda espacio en el dispositivo" msgid "No such file/directory" msgstr "No existe el archivo/directorio" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1112,17 +1116,8 @@ msgstr "A Stream le falta el método readinto() o write()." #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" -"El heap de CircuitPython estaba corrupto porque el stack era demasiado " -"pequeño.\n" -"Aumente los límites del tamaño del stacj y presione reset (después de " -"expulsarCIRCUITPY).\n" -"Si no cambió el stack, entonces reporte un issue aquí con el contenido desu " -"unidad CIRCUITPY:\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1132,23 +1127,10 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"La alimentación del microcontrolador cayó. Por favor asegurate de que tu " -"fuente de alimentación provee\n" -"suficiente energia para todo el circuito y presiona el botón de reset " -"(despuesde expulsar CIRCUITPY).\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" -"El botón reset fue presionado mientras arrancaba CircuitPython. Presiona " -"otra vez para salir del modo seguro.\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1182,10 +1164,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "Ancho del Tile debe dividir exactamente el ancho de mapa de bits" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Para salir, por favor reinicia la tarjeta sin " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Demasiados canales en sample." @@ -1264,6 +1242,10 @@ msgstr "Tipo de uuid nrfx inesperado" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1341,11 +1323,8 @@ msgstr "" "Para listar los módulos incorporados por favor haga `help(\"modules\")`.\n" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" -"Estás ejecutando en modo seguro, lo cual significa que algo realmente malo " -"ha sucedido.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2702,6 +2681,11 @@ msgstr "paso cero" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "" +#~ "Intento de allocation de heap cuando la VM de MicroPython no estaba " +#~ "corriendo.\n" + #~ msgid "Can't add services in Central mode" #~ msgstr "No se pueden agregar servicio en modo Central" @@ -2735,6 +2719,9 @@ msgstr "paso cero" #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "No se puede descodificar ble_uuid, err 0x%04x" +#~ msgid "Crash into the HardFault_Handler.\n" +#~ msgstr "Choque en el HardFault_Handler.\n" + #, fuzzy #~ msgid "Data too large for the advertisement packet" #~ msgstr "Los datos no caben en el paquete de anuncio." @@ -2849,6 +2836,15 @@ msgstr "paso cero" #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "No se puede escribir el valor del atributo. err: 0x%04x" +#~ msgid "Flash erase failed" +#~ msgstr "Falló borrado de flash" + +#~ msgid "Flash erase failed to start, err 0x%04x" +#~ msgstr "Falló el iniciar borrado de flash, err 0x%04x" + +#~ msgid "Flash write failed to start, err 0x%04x" +#~ msgstr "Falló el iniciar la escritura de flash, err 0x%04x" + #~ msgid "Function requires lock." #~ msgstr "La función requiere lock" @@ -2864,9 +2860,26 @@ msgstr "paso cero" #~ msgid "Invalid data pin" #~ msgstr "Pin de datos inválido" +#~ msgid "" +#~ "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ "Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +#~ " with the contents of your CIRCUITPY drive and this message:\n" +#~ msgstr "" +#~ "Parece que nuestro código de CircuitPython ha fallado con fuerza. " +#~ "Whoops!\n" +#~ "Por favor, crea un issue en https://github.com/adafruit/circuitpython/" +#~ "issues\n" +#~ " con el contenido de su unidad CIRCUITPY y este mensaje:\n" + #~ msgid "Maximum PWM frequency is %dhz." #~ msgstr "La frecuencia máxima del PWM es %dhz." +#~ msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +#~ msgstr "MicroPython NLR salto fallido. Probable corrupción de memoria.\n" + +#~ msgid "MicroPython fatal error.\n" +#~ msgstr "Error fatal de MicroPython.\n" + #~ msgid "Minimum PWM frequency is 1hz." #~ msgstr "La frecuencia mínima del PWM es 1hz" @@ -2926,9 +2939,44 @@ msgstr "paso cero" #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Soft device assert, id: 0x%08lX, pc: 0x%08lX" +#~ msgid "" +#~ "The CircuitPython heap was corrupted because the stack was too small.\n" +#~ "Please increase stack size limits and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ "If you didn't change the stack, then file an issue here with the contents " +#~ "of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "El heap de CircuitPython estaba corrupto porque el stack era demasiado " +#~ "pequeño.\n" +#~ "Aumente los límites del tamaño del stacj y presione reset (después de " +#~ "expulsarCIRCUITPY).\n" +#~ "Si no cambió el stack, entonces reporte un issue aquí con el contenido " +#~ "desu unidad CIRCUITPY:\n" + +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "La alimentación del microcontrolador cayó. Por favor asegurate de que tu " +#~ "fuente de alimentación provee\n" +#~ "suficiente energia para todo el circuito y presiona el botón de reset " +#~ "(despuesde expulsar CIRCUITPY).\n" + +#~ msgid "" +#~ "The reset button was pressed while booting CircuitPython. Press again to " +#~ "exit safe mode.\n" +#~ msgstr "" +#~ "El botón reset fue presionado mientras arrancaba CircuitPython. Presiona " +#~ "otra vez para salir del modo seguro.\n" + #~ msgid "Tile indices must be 0 - 255" #~ msgstr "Los índices de Tile deben ser 0 - 255" +#~ msgid "To exit, please reset the board without " +#~ msgstr "Para salir, por favor reinicia la tarjeta sin " + #~ msgid "UART(%d) does not exist" #~ msgstr "UART(%d) no existe" @@ -2951,6 +2999,13 @@ msgstr "paso cero" #~ msgid "Voice index too high" #~ msgstr "Index de voz demasiado alto" +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "" +#~ "Estás ejecutando en modo seguro, lo cual significa que algo realmente " +#~ "malo ha sucedido.\n" + #~ msgid "bad GATT role" #~ msgstr "mal GATT role" diff --git a/locale/fil.po b/locale/fil.po index ba20e69b81..16fac72244 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -23,6 +23,19 @@ msgid "" "Code done running. Waiting for reload.\n" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " File \"%q\"" @@ -296,7 +309,7 @@ msgid "Array values should be single bytes." msgstr "Array values ay dapat single bytes." #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -452,6 +465,16 @@ msgstr "Hindi maaring isulat kapag walang MOSI pin." msgid "CharacteristicBuffer writing not provided" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Nabigo sa pag init ng Clock pin." @@ -514,8 +537,8 @@ msgid "Couldn't allocate second buffer" msgstr "Hindi ma-iallocate ang second buffer" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" -msgstr "Nagcrash sa HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." +msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -635,28 +658,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Mayroong file" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -831,17 +844,6 @@ msgstr "Haba ay dapat int" msgid "Length must be non-negative" msgstr "Haba ay dapat hindi negatibo" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" -"Mukhang ang core CircuitPython code nag crash. Ay!\n" -"Maaring mag file ng issue sa https://github.com/adafruit/circuitpython/" -"issues\n" -"kasama ng laman ng iyong CIRCUITPY drive at ang message na ito:\n" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "Hindi ma-initialize ang MISO pin." @@ -856,12 +858,12 @@ msgid "Maximum x value when mirrored is %d" msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" -msgstr "CircuitPython NLR jump nabigo. Maaring memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." +msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" -msgstr "CircuitPython fatal na pagkakamali.\n" +msgid "MicroPython fatal error." +msgstr "" #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -929,6 +931,10 @@ msgstr "" msgid "No such file/directory" msgstr "Walang file/directory" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -1116,16 +1122,8 @@ msgstr "Stream kulang ng readinto() o write() method." #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" -"Ang CircuitPython heap ay na corrupt dahil ang stack ay maliit.\n" -"Maaring i-increase ang stack size limit at i-press ang reset (pagkatapos i-" -"eject ang CIRCUITPY.\n" -"Kung hindi mo pinalitan ang stack, mag file ng issue dito kasama ng laman ng " -"CIRCUITPY drive:\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1135,22 +1133,10 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"Ang kapangyarihan ng mikrokontroller ay bumaba. Mangyaring suriin ang power " -"supply \n" -"pindutin ang reset (pagkatapos i-eject ang CIRCUITPY).\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" -"Ang reset button ay pinindot habang nag boot ang CircuitPython. Pindutin " -"ulit para lumabas sa safe mode.\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1184,10 +1170,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Para lumabas, paki-reset ang board na wala ang " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Sobra ang channels sa sample." @@ -1267,6 +1249,10 @@ msgstr "hindi inaasahang indent" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1346,9 +1332,8 @@ msgstr "" "Para makita ang listahan ng modules, `help(“modules”)`.\n" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" -msgstr "Ikaw ay tumatakbo sa safe mode dahil may masamang nangyari.\n" +msgid "You are in safe mode: something unanticipated happened.\n" +msgstr "" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2735,6 +2720,9 @@ msgstr "zero step" #~ msgid "Cannot update i/f status" #~ msgstr "Hindi ma-update i/f status" +#~ msgid "Crash into the HardFault_Handler.\n" +#~ msgstr "Nagcrash sa HardFault_Handler.\n" + #, fuzzy #~ msgid "Data too large for the advertisement packet" #~ msgstr "Hindi makasya ang data sa loob ng advertisement packet" @@ -2871,9 +2859,25 @@ msgstr "zero step" #~ msgid "Invalid data pin" #~ msgstr "Mali ang data pin" +#~ msgid "" +#~ "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ "Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +#~ " with the contents of your CIRCUITPY drive and this message:\n" +#~ msgstr "" +#~ "Mukhang ang core CircuitPython code nag crash. Ay!\n" +#~ "Maaring mag file ng issue sa https://github.com/adafruit/circuitpython/" +#~ "issues\n" +#~ "kasama ng laman ng iyong CIRCUITPY drive at ang message na ito:\n" + #~ msgid "Maximum PWM frequency is %dhz." #~ msgstr "Pinakamataas na PWM frequency ay %dhz." +#~ msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +#~ msgstr "CircuitPython NLR jump nabigo. Maaring memory corruption.\n" + +#~ msgid "MicroPython fatal error.\n" +#~ msgstr "CircuitPython fatal na pagkakamali.\n" + #~ msgid "Minimum PWM frequency is 1hz." #~ msgstr "Pinakamababang PWM frequency ay 1hz." @@ -2918,6 +2922,39 @@ msgstr "zero step" #~ msgid "STA required" #~ msgstr "STA kailangan" +#~ msgid "" +#~ "The CircuitPython heap was corrupted because the stack was too small.\n" +#~ "Please increase stack size limits and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ "If you didn't change the stack, then file an issue here with the contents " +#~ "of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Ang CircuitPython heap ay na corrupt dahil ang stack ay maliit.\n" +#~ "Maaring i-increase ang stack size limit at i-press ang reset (pagkatapos " +#~ "i-eject ang CIRCUITPY.\n" +#~ "Kung hindi mo pinalitan ang stack, mag file ng issue dito kasama ng laman " +#~ "ng CIRCUITPY drive:\n" + +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "Ang kapangyarihan ng mikrokontroller ay bumaba. Mangyaring suriin ang " +#~ "power supply \n" +#~ "pindutin ang reset (pagkatapos i-eject ang CIRCUITPY).\n" + +#~ msgid "" +#~ "The reset button was pressed while booting CircuitPython. Press again to " +#~ "exit safe mode.\n" +#~ msgstr "" +#~ "Ang reset button ay pinindot habang nag boot ang CircuitPython. Pindutin " +#~ "ulit para lumabas sa safe mode.\n" + +#~ msgid "To exit, please reset the board without " +#~ msgstr "Para lumabas, paki-reset ang board na wala ang " + #~ msgid "UART(%d) does not exist" #~ msgstr "Walang UART(%d)" @@ -2937,6 +2974,11 @@ msgstr "zero step" #~ msgid "Voice index too high" #~ msgstr "Index ng Voice ay masyadong mataas" +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "Ikaw ay tumatakbo sa safe mode dahil may masamang nangyari.\n" + #~ msgid "[addrinfo error %d]" #~ msgstr "[addrinfo error %d]" diff --git a/locale/fr.po b/locale/fr.po index e103cd06d2..9762b5e7da 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -25,6 +25,19 @@ msgstr "" "\n" "Fin d'éxecution du code. En attente de recharge.\n" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " Fichier \"%q\"" @@ -300,9 +313,8 @@ msgid "Array values should be single bytes." msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'." #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" -"Tentative d'allocation de tas alors que la VM MicroPython ne tourne pas.\n" #: main.c msgid "Auto-reload is off.\n" @@ -458,6 +470,16 @@ msgstr "Impossible d'écrire sans broche MOSI." msgid "CharacteristicBuffer writing not provided" msgstr "Ecriture sur 'CharacteristicBuffer' non fournie" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Echec de l'init. de la broche d'horloge" @@ -520,8 +542,8 @@ msgid "Couldn't allocate second buffer" msgstr "Impossible d'allouer le 2e tampon" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" -msgstr "Plantage vers le 'HardFault_Handler'.\n" +msgid "Crash into the HardFault_Handler." +msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -639,28 +661,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Impossible de libérer mutex, err 0x%04x" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Le fichier existe" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "L'effacement de la flash a échoué" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "Echec du démarrage de l'effacement de la flash, err 0x%04x" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "L'écriture de la flash échoué" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "Echec du démarrage de l'écriture de la flash, err 0x%04x" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "La fréquence capturée est au delà des capacités. Capture en pause." @@ -839,17 +851,6 @@ msgstr "La longueur doit être un nombre entier" msgid "Length must be non-negative" msgstr "La longueur ne doit pas être négative" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" -"On dirait que notre code CircuitPython a durement planté. Oups !\n" -"Merci de remplir un ticket sur https://github.com/adafruit/circuitpython/" -"issues\n" -"avec le contenu de votre lecteur CIRCUITPY et ce message:\n" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "Echec de l'init. de la broche MISO" @@ -864,12 +865,12 @@ msgid "Maximum x value when mirrored is %d" msgstr "La valeur max. de x est %d lors d'une opération miroir" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" -msgstr "Saut MicroPython NLR a échoué. Corruption de mémoire possible.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." +msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" -msgstr "Erreur fatale de MicroPython.\n" +msgid "MicroPython fatal error." +msgstr "" #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -937,6 +938,10 @@ msgstr "Il n'y a plus d'espace libre sur le périphérique" msgid "No such file/directory" msgstr "Fichier/dossier introuvable" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -1131,17 +1136,8 @@ msgstr "Il manque une méthode readinto() ou write() au flux." #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" -"Le tas (heap) de CircuitPython a été corrompu parce que la pile était trop " -"petite.\n" -"Augmentez la limite de taille de la pile et appuyez sur 'reset' (après avoir " -"éjecté CIRCUITPY).\n" -"Si vous n'avez pas modifié la pile, merci de remplir un ticket avec le " -"contenu de votre lecteur CIRCUITPY :\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1150,25 +1146,11 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -#, fuzzy msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"L'alimentation du microcontroleur a chuté. Merci de vérifier que votre " -"alimentation fournit\n" -"suffisamment de puissance pour l'ensemble du circuit et appuyez sur " -"'reset' (après avoir éjecté CIRCUITPY).\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" -"Le bouton 'reset' a été appuyé pendant le démarrage de CircuitPython. " -"Appuyer de nouveau pour quitter de le mode sans-échec.\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1203,10 +1185,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "La largeur de la tuile doit diviser exactement la largeur de l'image" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Pour quitter, redémarrez la carte SVP sans " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Trop de canaux dans l'échantillon." @@ -1289,6 +1267,10 @@ msgstr "Type inattendu pour l'uuid nrfx" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1367,11 +1349,8 @@ msgstr "" "Pour lister les modules inclus, tapez `help(\"modules\")`.\n" #: supervisor/shared/safe_mode.c -#, fuzzy -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" -"Vous êtes en mode sans-échec ce qui signifie qu'un imprévu est survenu.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2753,6 +2732,10 @@ msgstr "'step' nul" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "" +#~ "Tentative d'allocation de tas alors que la VM MicroPython ne tourne pas.\n" + #~ msgid "Can't add services in Central mode" #~ msgstr "Impossible d'ajouter des services en mode Central" @@ -2786,6 +2769,9 @@ msgstr "'step' nul" #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Impossible de décoder le 'ble_uuid', err 0x%04x" +#~ msgid "Crash into the HardFault_Handler.\n" +#~ msgstr "Plantage vers le 'HardFault_Handler'.\n" + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Données trop volumineuses pour le paquet de diffusion" @@ -2912,6 +2898,15 @@ msgstr "'step' nul" #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Impossible d'écrire la valeur de 'gatts', err 0x%04x" +#~ msgid "Flash erase failed" +#~ msgstr "L'effacement de la flash a échoué" + +#~ msgid "Flash erase failed to start, err 0x%04x" +#~ msgstr "Echec du démarrage de l'effacement de la flash, err 0x%04x" + +#~ msgid "Flash write failed to start, err 0x%04x" +#~ msgstr "Echec du démarrage de l'écriture de la flash, err 0x%04x" + #~ msgid "Function requires lock." #~ msgstr "La fonction nécessite un verrou." @@ -2927,9 +2922,25 @@ msgstr "'step' nul" #~ msgid "Invalid data pin" #~ msgstr "Broche de données invalide" +#~ msgid "" +#~ "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ "Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +#~ " with the contents of your CIRCUITPY drive and this message:\n" +#~ msgstr "" +#~ "On dirait que notre code CircuitPython a durement planté. Oups !\n" +#~ "Merci de remplir un ticket sur https://github.com/adafruit/circuitpython/" +#~ "issues\n" +#~ "avec le contenu de votre lecteur CIRCUITPY et ce message:\n" + #~ msgid "Maximum PWM frequency is %dhz." #~ msgstr "La fréquence de PWM maximale est %dHz" +#~ msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +#~ msgstr "Saut MicroPython NLR a échoué. Corruption de mémoire possible.\n" + +#~ msgid "MicroPython fatal error.\n" +#~ msgstr "Erreur fatale de MicroPython.\n" + #~ msgid "Minimum PWM frequency is 1hz." #~ msgstr "La fréquence de PWM minimale est 1Hz" @@ -2986,9 +2997,45 @@ msgstr "'step' nul" #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Assertion en mode 'soft-device', id: 0x%08lX, pc: 0x%08lX" +#~ msgid "" +#~ "The CircuitPython heap was corrupted because the stack was too small.\n" +#~ "Please increase stack size limits and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ "If you didn't change the stack, then file an issue here with the contents " +#~ "of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Le tas (heap) de CircuitPython a été corrompu parce que la pile était " +#~ "trop petite.\n" +#~ "Augmentez la limite de taille de la pile et appuyez sur 'reset' (après " +#~ "avoir éjecté CIRCUITPY).\n" +#~ "Si vous n'avez pas modifié la pile, merci de remplir un ticket avec le " +#~ "contenu de votre lecteur CIRCUITPY :\n" + +#, fuzzy +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "L'alimentation du microcontroleur a chuté. Merci de vérifier que votre " +#~ "alimentation fournit\n" +#~ "suffisamment de puissance pour l'ensemble du circuit et appuyez sur " +#~ "'reset' (après avoir éjecté CIRCUITPY).\n" + +#~ msgid "" +#~ "The reset button was pressed while booting CircuitPython. Press again to " +#~ "exit safe mode.\n" +#~ msgstr "" +#~ "Le bouton 'reset' a été appuyé pendant le démarrage de CircuitPython. " +#~ "Appuyer de nouveau pour quitter de le mode sans-échec.\n" + #~ msgid "Tile indices must be 0 - 255" #~ msgstr "Les indices des tuiles doivent être compris entre 0 et 255 " +#~ msgid "To exit, please reset the board without " +#~ msgstr "Pour quitter, redémarrez la carte SVP sans " + #~ msgid "UART(%d) does not exist" #~ msgstr "UART(%d) n'existe pas" @@ -3011,6 +3058,13 @@ msgstr "'step' nul" #~ msgid "Voice index too high" #~ msgstr "Index de la voix trop grand" +#, fuzzy +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "" +#~ "Vous êtes en mode sans-échec ce qui signifie qu'un imprévu est survenu.\n" + #~ msgid "bad GATT role" #~ msgstr "mauvais rôle GATT" diff --git a/locale/it_IT.po b/locale/it_IT.po index c1a445fa24..0a3c30d2bd 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -23,6 +23,19 @@ msgid "" "Code done running. Waiting for reload.\n" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " File \"%q\"" @@ -295,7 +308,7 @@ msgid "Array values should be single bytes." msgstr "Valori di Array dovrebbero essere bytes singulari" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -453,6 +466,16 @@ msgstr "Impossibile scrivere senza pin MOSI." msgid "CharacteristicBuffer writing not provided" msgstr "CharacteristicBuffer scritura non dato" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Inizializzazione del pin di clock fallita." @@ -515,7 +538,7 @@ msgid "Couldn't allocate second buffer" msgstr "Impossibile allocare il secondo buffer" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -635,28 +658,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "File esistente" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "Cancellamento di Flash fallito" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "Iniziamento di Cancellamento di Flash fallito, err 0x%04x" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "Impostazione di Flash fallito" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "Iniziamento di Impostazione di Flash dallito, err 0x%04x" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -834,13 +847,6 @@ msgstr "Length deve essere un intero" msgid "Length must be non-negative" msgstr "Length deve essere non negativo" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "inizializzazione del pin MISO fallita." @@ -855,12 +861,12 @@ msgid "Maximum x value when mirrored is %d" msgstr "Valore massimo di x quando rispachiato è %d" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" -msgstr "Errore fatale in MicroPython.\n" +msgid "MicroPython fatal error." +msgstr "" #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -929,6 +935,10 @@ msgstr "Non che spazio sul dispositivo" msgid "No such file/directory" msgstr "Nessun file/directory esistente" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -1123,10 +1133,7 @@ msgstr "Metodi mancanti readinto() o write() allo stream." #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" #: supervisor/shared/safe_mode.c @@ -1136,21 +1143,11 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -#, fuzzy msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"La potenza del microcontrollore è calata. Assicurati che l'alimentazione sia " -"attaccata correttamente\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1184,10 +1181,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Per uscire resettare la scheda senza " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "" @@ -1267,6 +1260,10 @@ msgstr "indentazione inaspettata" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1338,12 +1335,8 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -#, fuzzy -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" -"Sei nella modalità sicura che significa che qualcosa di molto brutto è " -"successo.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2862,6 +2855,15 @@ msgstr "zero step" #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" +#~ msgid "Flash erase failed" +#~ msgstr "Cancellamento di Flash fallito" + +#~ msgid "Flash erase failed to start, err 0x%04x" +#~ msgstr "Iniziamento di Cancellamento di Flash fallito, err 0x%04x" + +#~ msgid "Flash write failed to start, err 0x%04x" +#~ msgstr "Iniziamento di Impostazione di Flash dallito, err 0x%04x" + #~ msgid "GPIO16 does not support pull up." #~ msgstr "GPIO16 non supporta pull-up" @@ -2877,6 +2879,9 @@ msgstr "zero step" #~ msgid "Maximum PWM frequency is %dhz." #~ msgstr "Frequenza massima su PWM è %dhz" +#~ msgid "MicroPython fatal error.\n" +#~ msgstr "Errore fatale in MicroPython.\n" + #~ msgid "Minimum PWM frequency is 1hz." #~ msgstr "Frequenza minima su PWM è 1hz" @@ -2922,6 +2927,19 @@ msgstr "zero step" #~ msgid "STA required" #~ msgstr "STA richiesta" +#, fuzzy +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "La potenza del microcontrollore è calata. Assicurati che l'alimentazione " +#~ "sia attaccata correttamente\n" + +#~ msgid "To exit, please reset the board without " +#~ msgstr "Per uscire resettare la scheda senza " + #~ msgid "UART(%d) does not exist" #~ msgstr "UART(%d) non esistente" @@ -2937,6 +2955,14 @@ msgstr "zero step" #~ msgid "Use esptool to erase flash and re-upload Python instead" #~ msgstr "Usa esptool per cancellare la flash e ricaricare Python invece" +#, fuzzy +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "" +#~ "Sei nella modalità sicura che significa che qualcosa di molto brutto è " +#~ "successo.\n" + #~ msgid "[addrinfo error %d]" #~ msgstr "[errore addrinfo %d]" diff --git a/locale/ko.po b/locale/ko.po index 93a476b876..78f0c756b1 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -25,6 +25,19 @@ msgstr "" "\n" "실행 완료 코드. 재장전 을 기다리는 중입니다\n" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " 파일 \"%q\"" @@ -294,7 +307,7 @@ msgid "Array values should be single bytes." msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -448,6 +461,16 @@ msgstr "" msgid "CharacteristicBuffer writing not provided" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "" @@ -509,7 +532,7 @@ msgid "Couldn't allocate second buffer" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -625,28 +648,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -819,13 +832,6 @@ msgstr "길이는 정수(int) 여야합니다" msgid "Length must be non-negative" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "" @@ -840,11 +846,11 @@ msgid "Maximum x value when mirrored is %d" msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" +msgid "MicroPython fatal error." msgstr "" #: shared-bindings/audiobusio/PDMIn.c @@ -913,6 +919,10 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1091,10 +1101,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" #: supervisor/shared/safe_mode.c @@ -1105,18 +1112,11 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" - #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" @@ -1149,10 +1149,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "" - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "" @@ -1232,6 +1228,10 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1302,8 +1302,7 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" #: supervisor/shared/safe_mode.c diff --git a/locale/pl.po b/locale/pl.po index 8efab18675..60aac45a3f 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -24,6 +24,19 @@ msgstr "" "\n" "Kod wykonany. Czekam na przeładowanie.\n" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " Plik \"%q\"" @@ -293,8 +306,8 @@ msgid "Array values should be single bytes." msgstr "Wartości powinny być bajtami." #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" -msgstr "Próba alokacji pamięci na stercie gdy VM nie działa.\n" +msgid "Attempted heap allocation when MicroPython VM not running." +msgstr "" #: main.c msgid "Auto-reload is off.\n" @@ -447,6 +460,16 @@ msgstr "Nie można pisać bez nóżki MOSI." msgid "CharacteristicBuffer writing not provided" msgstr "Pisanie do CharacteristicBuffer niewspierane" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Nie powiodło się ustawienie nóżki zegara" @@ -508,8 +531,8 @@ msgid "Couldn't allocate second buffer" msgstr "Nie udała się alokacja drugiego bufora" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" -msgstr "Katastrofa w HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." +msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -624,28 +647,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Nie udało się zwolnić blokady, błąd 0x%04x" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Plik istnieje" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "Nie udało się skasować flash" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "Nie udało się rozpocząć kasowania flash, błąd 0x%04x" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "Zapis do flash nie powiódł się" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "Nie udało się rozpocząć zapisu do flash, błąd 0x%04x" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "Uzyskana częstotliwość jest niemożliwa. Spauzowano." @@ -820,17 +833,6 @@ msgstr "Długość musi być całkowita" msgid "Length must be non-negative" msgstr "Długość musi być nieujemna" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" -"Ojej, wygląda na to, że CircuitPython natrafił na poważny problem!\n" -"Prosimy o zgłoszenie błędu pod adresem https://github.com/adafruit/" -"circuitpython/issues\n" -" z zawartością dysku CIRCUITPY oraz tym komunikatem:\n" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "Nie powiodło się ustawienie nóżki MISO." @@ -845,13 +847,12 @@ msgid "Maximum x value when mirrored is %d" msgstr "Największa wartość x przy odwróceniu to %d" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" -"Skok NLR MicroPythona nie powiódł się. Prawdopodobne skażenie pamięci.\n" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" -msgstr "Krytyczny błąd MicroPythona.\n" +msgid "MicroPython fatal error." +msgstr "" #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -919,6 +920,10 @@ msgstr "Brak miejsca" msgid "No such file/directory" msgstr "Brak pliku/katalogu" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1097,16 +1102,8 @@ msgstr "Strumień nie ma metod readinto() lub write()." #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" -"Sterta CircuitPythona jest skażona z powodu zbyt małego stosu.\n" -"Proszę zwiększyć limity wielkości stosu i nazisnąć reset (po odmontowaniu " -"CIRCUITPY).\n" -"Jeśli wielkość stosu nie była zmieniana, proszę zgłosić błąd zawierający " -"zawartość CIRCUITPY tutaj:\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1116,22 +1113,10 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"Zasilanie mikrokontrolera gwałtownie spadło. Proszę upewnić się,\n" -"że zasilanie jest wystarczające dla całego obwodu in nacisnąć reset (po " -"odmontowaniu CIRCUITPY).\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" -"Przycisk reset został wciśnięty podczas startu CircuitPythona. Wciśnij go " -"ponownie aby wyjść z trybu bezpieczeństwa.\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1165,10 +1150,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "Szerokość bitmapy musi być wielokrotnością szerokości kafelka" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "By wyjść, proszę zresetować płytkę bez " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Zbyt wiele kanałów." @@ -1247,6 +1228,10 @@ msgstr "Nieoczekiwany typ nrfx uuid." msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1320,10 +1305,8 @@ msgstr "" "Aby zobaczyć wbudowane moduły, wpisz `help(\"modules\")`.\n" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" -"Uruchomiono w trybie bezpieczeństwa, gdyż nastąpiło coś nieoczekiwanego.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2660,6 +2643,9 @@ msgstr "zerowy krok" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Adres nie ma długości %d bajtów lub zły format" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "Próba alokacji pamięci na stercie gdy VM nie działa.\n" + #~ msgid "Can't add services in Central mode" #~ msgstr "Nie można dodać serwisów w trybie Central" @@ -2681,6 +2667,9 @@ msgstr "zerowy krok" #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Nie można zdekodować ble_uuid, błąd 0x%04x" +#~ msgid "Crash into the HardFault_Handler.\n" +#~ msgstr "Katastrofa w HardFault_Handler.\n" + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" @@ -2763,6 +2752,15 @@ msgstr "zerowy krok" #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Nie udało się zapisać gatts, błąd 0x%04x" +#~ msgid "Flash erase failed" +#~ msgstr "Nie udało się skasować flash" + +#~ msgid "Flash erase failed to start, err 0x%04x" +#~ msgstr "Nie udało się rozpocząć kasowania flash, błąd 0x%04x" + +#~ msgid "Flash write failed to start, err 0x%04x" +#~ msgstr "Nie udało się rozpocząć zapisu do flash, błąd 0x%04x" + #~ msgid "Invalid bit clock pin" #~ msgstr "Zła nóżka zegara" @@ -2772,6 +2770,23 @@ msgstr "zerowy krok" #~ msgid "Invalid data pin" #~ msgstr "Zła nóżka danych" +#~ msgid "" +#~ "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ "Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +#~ " with the contents of your CIRCUITPY drive and this message:\n" +#~ msgstr "" +#~ "Ojej, wygląda na to, że CircuitPython natrafił na poważny problem!\n" +#~ "Prosimy o zgłoszenie błędu pod adresem https://github.com/adafruit/" +#~ "circuitpython/issues\n" +#~ " z zawartością dysku CIRCUITPY oraz tym komunikatem:\n" + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +#~ msgstr "" +#~ "Skok NLR MicroPythona nie powiódł się. Prawdopodobne skażenie pamięci.\n" + +#~ msgid "MicroPython fatal error.\n" +#~ msgstr "Krytyczny błąd MicroPythona.\n" + #~ msgid "Must be a Group subclass." #~ msgstr "Musi dziedziczyć z Group." @@ -2783,15 +2798,54 @@ msgstr "zerowy krok" #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Soft device assert, id: 0x%08lX, pc: 0x%08lX" +#~ msgid "" +#~ "The CircuitPython heap was corrupted because the stack was too small.\n" +#~ "Please increase stack size limits and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ "If you didn't change the stack, then file an issue here with the contents " +#~ "of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Sterta CircuitPythona jest skażona z powodu zbyt małego stosu.\n" +#~ "Proszę zwiększyć limity wielkości stosu i nazisnąć reset (po odmontowaniu " +#~ "CIRCUITPY).\n" +#~ "Jeśli wielkość stosu nie była zmieniana, proszę zgłosić błąd zawierający " +#~ "zawartość CIRCUITPY tutaj:\n" + +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "Zasilanie mikrokontrolera gwałtownie spadło. Proszę upewnić się,\n" +#~ "że zasilanie jest wystarczające dla całego obwodu in nacisnąć reset (po " +#~ "odmontowaniu CIRCUITPY).\n" + +#~ msgid "" +#~ "The reset button was pressed while booting CircuitPython. Press again to " +#~ "exit safe mode.\n" +#~ msgstr "" +#~ "Przycisk reset został wciśnięty podczas startu CircuitPythona. Wciśnij go " +#~ "ponownie aby wyjść z trybu bezpieczeństwa.\n" + #~ msgid "Tile indices must be 0 - 255" #~ msgstr "Indeks kafelka musi być pomiędzy 0 a 255 włącznie" +#~ msgid "To exit, please reset the board without " +#~ msgstr "By wyjść, proszę zresetować płytkę bez " + #~ msgid "UUID integer value not in range 0 to 0xffff" #~ msgstr "Wartość UUID poza zakresem 0 do 0xffff" #~ msgid "Voice index too high" #~ msgstr "Zbyt wysoki indeks głosu" +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "" +#~ "Uruchomiono w trybie bezpieczeństwa, gdyż nastąpiło coś nieoczekiwanego.\n" + #~ msgid "bad GATT role" #~ msgstr "zła rola GATT" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 1ca6b7d9a5..0aa2ac6308 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -23,6 +23,19 @@ msgid "" "Code done running. Waiting for reload.\n" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " Arquivo \"%q\"" @@ -295,7 +308,7 @@ msgid "Array values should be single bytes." msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" +msgid "Attempted heap allocation when MicroPython VM not running." msgstr "" #: main.c @@ -449,6 +462,16 @@ msgstr "Não é possível ler sem um pino MOSI" msgid "CharacteristicBuffer writing not provided" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Inicialização do pino de Clock falhou." @@ -511,7 +534,7 @@ msgid "Couldn't allocate second buffer" msgstr "Não pôde alocar segundo buffer" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -630,28 +653,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Arquivo já existe" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -827,13 +840,6 @@ msgstr "Tamanho deve ser um int" msgid "Length must be non-negative" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "Inicialização do pino MISO falhou" @@ -848,11 +854,11 @@ msgid "Maximum x value when mirrored is %d" msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" +msgid "MicroPython fatal error." msgstr "" #: shared-bindings/audiobusio/PDMIn.c @@ -921,6 +927,10 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -1104,10 +1114,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" #: supervisor/shared/safe_mode.c @@ -1118,18 +1125,11 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" - #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" @@ -1162,10 +1162,6 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Para sair, por favor, reinicie a placa sem " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Muitos canais na amostra." @@ -1244,6 +1240,10 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1315,8 +1315,7 @@ msgid "" msgstr "" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -2837,6 +2836,9 @@ msgstr "passo zero" #~ msgid "STA required" #~ msgstr "STA requerido" +#~ msgid "To exit, please reset the board without " +#~ msgstr "Para sair, por favor, reinicie a placa sem " + #~ msgid "UART(%d) does not exist" #~ msgstr "UART(%d) não existe" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 40966090d4..bd5b80a724 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 13:55-0600\n" +"POT-Creation-Date: 2019-12-12 14:51-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -25,6 +25,19 @@ msgstr "" "\n" "Dàimǎ yǐ wánchéng yùnxíng. Zhèngzài děngdài chóngxīn jiāzài.\n" +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"To exit, please reset the board without " +msgstr "" + #: py/obj.c msgid " File \"%q\"" msgstr " Wénjiàn \"%q\"" @@ -294,8 +307,8 @@ msgid "Array values should be single bytes." msgstr "Shùzǔ zhí yīnggāi shì dāngè zì jié." #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running.\n" -msgstr "MicroPython VM wèi yùnxíng shí chángshì duī fēnpèi.\n" +msgid "Attempted heap allocation when MicroPython VM not running." +msgstr "" #: main.c msgid "Auto-reload is off.\n" @@ -448,6 +461,16 @@ msgstr "Wúfǎ xiě rù MOSI de yǐn jiǎo." msgid "CharacteristicBuffer writing not provided" msgstr "Wèi tígōng zìfú huǎncún xiě rù" +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"CircuitPython is in safe mode because you pressed the reset button during " +"boot. Press again to exit safe mode.\n" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." msgstr "Shízhōng de yǐn jiǎo chūshǐhuà shībài." @@ -509,8 +532,8 @@ msgid "Couldn't allocate second buffer" msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū" #: supervisor/shared/safe_mode.c -msgid "Crash into the HardFault_Handler.\n" -msgstr "Bēngkuì dào HardFault_Handler.\n" +msgid "Crash into the HardFault_Handler." +msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -625,28 +648,18 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "Wúfǎ shìfàng mutex, err 0x%04x" +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Wénjiàn cúnzài" -#: ports/nrf/peripherals/nrf/nvm.c -msgid "Flash erase failed" -msgstr "Flash cā chú shībài" - -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash erase failed to start, err 0x%04x" -msgstr "Flash cā chú shībài, err 0x%04x" - -#: ports/nrf/peripherals/nrf/nvm.c +#: ports/nrf/common-hal/nvm/ByteArray.c msgid "Flash write failed" msgstr "Flash xiě rù shībài" -#: ports/nrf/peripherals/nrf/nvm.c -#, c-format -msgid "Flash write failed to start, err 0x%04x" -msgstr "Flash xiě rù shībài, err 0x%04x" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "Pínlǜ bǔhuò gāo yú nénglì. Bǔhuò zàntíng." @@ -821,17 +834,6 @@ msgstr "Chángdù bìxū shì yīgè zhěngshù" msgid "Length must be non-negative" msgstr "Chángdù bìxū shìfēi fùshù" -#: supervisor/shared/safe_mode.c -msgid "" -"Looks like our core CircuitPython code crashed hard. Whoops!\n" -"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" -" with the contents of your CIRCUITPY drive and this message:\n" -msgstr "" -"Kàn lái wǒmen de héxīn CircuitPython dàimǎ bēngkuì dé hěn lìhài. Āi yōu!\n" -"Qǐng zài https://Github.Com/adafruit/circuitpython/issues\n" -"shàng tíjiāo yīgè wèntí, qízhōng bāohán nín de CIRCUITPY qūdòngqì de nèiróng " -"hé cǐ xiāoxī:\n" - #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." msgstr "MISO yǐn jiǎo chūshǐhuà shībài." @@ -846,12 +848,12 @@ msgid "Maximum x value when mirrored is %d" msgstr "Jìngxiàng shí de zuìdà X zhí wèi%d" #: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption.\n" -msgstr "MicroPython NLR tiàoyuè shībài. Kěnéng nèicún fǔbài.\n" +msgid "MicroPython NLR jump failed. Likely memory corruption." +msgstr "" #: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error.\n" -msgstr "MicroPython zhìmìng cuòwù.\n" +msgid "MicroPython fatal error." +msgstr "" #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -919,6 +921,10 @@ msgstr "Shèbèi shàng méiyǒu kònggé" msgid "No such file/directory" msgstr "Méiyǒu cǐ lèi wénjiàn/mùlù" +#: supervisor/shared/safe_mode.c +msgid "Nordic Soft Device failure assertion." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1101,16 +1107,8 @@ msgstr "Liú quēshǎo readinto() huò write() fāngfǎ." #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" -"Please increase stack size limits and press reset (after ejecting " -"CIRCUITPY).\n" -"If you didn't change the stack, then file an issue here with the contents of " -"your CIRCUITPY drive:\n" +"Please increase the stack size if you know how, or if not:" msgstr "" -"Yóuyú duīzhàn tài xiǎo, huánliú Python rè sǔnhuài.\n" -"Qǐng zēngjiā duīzhàn chǐcùn xiànzhì, ránhòu chóngxīn shèzhì (zài dànchū " -"CIRCUITPY).\n" -"Rúguǒ nín méiyǒu gǎibiàn duīzhàn, qǐng zài cǐ chù tíchū yīgè wèntí, bìng zài " -"rù nín de CIRCUITPY qūdòngqì:\n" #: supervisor/shared/safe_mode.c msgid "" @@ -1122,22 +1120,10 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" +"The microcontroller's power dipped. Make sure your power supply provides\n" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"Wēi kòngzhì qì de diànliàng bèi chōng chū. Qǐng quèbǎo nín de diànyuán wèi\n" -"zhěnggè diànlù tígōng zúgòu de diànyuán bìng àn xià fùwèi (zài dànchū " -"CIRCUITPY hòu).\n" - -#: supervisor/shared/safe_mode.c -msgid "" -"The reset button was pressed while booting CircuitPython. Press again to " -"exit safe mode.\n" -msgstr "" -"Qǐdòng CircuitPython shí, chóng zhì ànniǔ bèi àn xià. Zàicì àn xià yǐ tuìchū " -"ānquán móshì\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1171,10 +1157,6 @@ msgstr "Píng pū zhí chāochū fànwéi" msgid "Tile width must exactly divide bitmap width" msgstr "Píng pū kuāndù bìxū huàfēn wèi tú kuāndù" -#: supervisor/shared/safe_mode.c -msgid "To exit, please reset the board without " -msgstr "Yào tuìchū, qǐng chóng zhì bǎnkuài ér bùyòng " - #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Too many channels in sample." msgstr "Chōuyàng zhōng de píndào tài duō." @@ -1253,6 +1235,10 @@ msgstr "Yìwài de nrfx uuid lèixíng" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" @@ -1328,11 +1314,8 @@ msgstr "" "Ruò yào liè chū nèizài de mókuài, qǐng qǐng zuò yǐxià `help(\"modules\")`.\n" #: supervisor/shared/safe_mode.c -msgid "" -"You are running in safe mode which means something unanticipated happened.\n" +msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" -"Nǐ zhèngzài ānquán móshì xià yùnxíng, zhè yì wèi zhuó yìwài fāshēng de " -"shìqíng.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2673,6 +2656,9 @@ msgstr "líng bù" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "MicroPython VM wèi yùnxíng shí chángshì duī fēnpèi.\n" + #~ msgid "Can't add services in Central mode" #~ msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" @@ -2697,6 +2683,9 @@ msgstr "líng bù" #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Wúfǎ jiěmǎ kě dú_uuid, err 0x%04x" +#~ msgid "Crash into the HardFault_Handler.\n" +#~ msgstr "Bēngkuì dào HardFault_Handler.\n" + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Guǎnggào bāo de shùjù tài dà" @@ -2802,6 +2791,15 @@ msgstr "líng bù" #~ msgid "Failed to write gatts value, err 0x%04x" #~ msgstr "Xiě rù gatts zhí,err 0x%04x shībài" +#~ msgid "Flash erase failed" +#~ msgstr "Flash cā chú shībài" + +#~ msgid "Flash erase failed to start, err 0x%04x" +#~ msgstr "Flash cā chú shībài, err 0x%04x" + +#~ msgid "Flash write failed to start, err 0x%04x" +#~ msgstr "Flash xiě rù shībài, err 0x%04x" + #~ msgid "Invalid bit clock pin" #~ msgstr "Wúxiào de wèi shízhōng yǐn jiǎo" @@ -2811,6 +2809,22 @@ msgstr "líng bù" #~ msgid "Invalid data pin" #~ msgstr "Wúxiào de shùjù yǐn jiǎo" +#~ msgid "" +#~ "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ "Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +#~ " with the contents of your CIRCUITPY drive and this message:\n" +#~ msgstr "" +#~ "Kàn lái wǒmen de héxīn CircuitPython dàimǎ bēngkuì dé hěn lìhài. Āi yōu!\n" +#~ "Qǐng zài https://Github.Com/adafruit/circuitpython/issues\n" +#~ "shàng tíjiāo yīgè wèntí, qízhōng bāohán nín de CIRCUITPY qūdòngqì de " +#~ "nèiróng hé cǐ xiāoxī:\n" + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +#~ msgstr "MicroPython NLR tiàoyuè shībài. Kěnéng nèicún fǔbài.\n" + +#~ msgid "MicroPython fatal error.\n" +#~ msgstr "MicroPython zhìmìng cuòwù.\n" + #~ msgid "Must be a Group subclass." #~ msgstr "Bìxū shì fēnzǔ zi lèi." @@ -2835,15 +2849,56 @@ msgstr "líng bù" #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Ruǎn shèbèi wéihù, id: 0X%08lX, pc: 0X%08lX" +#~ msgid "" +#~ "The CircuitPython heap was corrupted because the stack was too small.\n" +#~ "Please increase stack size limits and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ "If you didn't change the stack, then file an issue here with the contents " +#~ "of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Yóuyú duīzhàn tài xiǎo, huánliú Python rè sǔnhuài.\n" +#~ "Qǐng zēngjiā duīzhàn chǐcùn xiànzhì, ránhòu chóngxīn shèzhì (zài dànchū " +#~ "CIRCUITPY).\n" +#~ "Rúguǒ nín méiyǒu gǎibiàn duīzhàn, qǐng zài cǐ chù tíchū yīgè wèntí, bìng " +#~ "zài rù nín de CIRCUITPY qūdòngqì:\n" + +#~ msgid "" +#~ "The microcontroller's power dipped. Please make sure your power supply " +#~ "provides\n" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "Wēi kòngzhì qì de diànliàng bèi chōng chū. Qǐng quèbǎo nín de diànyuán " +#~ "wèi\n" +#~ "zhěnggè diànlù tígōng zúgòu de diànyuán bìng àn xià fùwèi (zài dànchū " +#~ "CIRCUITPY hòu).\n" + +#~ msgid "" +#~ "The reset button was pressed while booting CircuitPython. Press again to " +#~ "exit safe mode.\n" +#~ msgstr "" +#~ "Qǐdòng CircuitPython shí, chóng zhì ànniǔ bèi àn xià. Zàicì àn xià yǐ " +#~ "tuìchū ānquán móshì\n" + #~ msgid "Tile indices must be 0 - 255" #~ msgstr "Píng pū zhǐshù bìxū wèi 0 - 255" +#~ msgid "To exit, please reset the board without " +#~ msgstr "Yào tuìchū, qǐng chóng zhì bǎnkuài ér bùyòng " + #~ msgid "UUID integer value not in range 0 to 0xffff" #~ msgstr "UUID zhěngshù zhí bùzài fànwéi 0 zhì 0xffff" #~ msgid "Voice index too high" #~ msgstr "Yǔyīn suǒyǐn tài gāo" +#~ msgid "" +#~ "You are running in safe mode which means something unanticipated " +#~ "happened.\n" +#~ msgstr "" +#~ "Nǐ zhèngzài ānquán móshì xià yùnxíng, zhè yì wèi zhuó yìwài fāshēng de " +#~ "shìqíng.\n" + #~ msgid "bad GATT role" #~ msgstr "zǒng xiédìng de bùliáng juésè" diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 9e3b864028..aba31e9c9e 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -96,48 +96,48 @@ void __attribute__((noinline,)) reset_into_safe_mode(safe_mode_t reason) { -#define FILE_AN_ISSUE translate("\r\nPlease file an issue with the contents of your CIRCUITPY drive at \nhttps://github.com/adafruit/circuitpython/issues\r\n") +#define FILE_AN_ISSUE translate("\nPlease file an issue with the contents of your CIRCUITPY drive at \nhttps://github.com/adafruit/circuitpython/issues\n") void print_safe_mode_message(safe_mode_t reason) { if (reason == NO_SAFE_MODE) { return; } - serial_write("\r\n"); + serial_write("\n"); // Output a user safe mode string if it's set. #ifdef BOARD_USER_SAFE_MODE if (reason == USER_SAFE_MODE) { serial_write_compressed(translate("You requested starting safe mode by ")); serial_write(BOARD_USER_SAFE_MODE_ACTION); - serial_write_compressed(translate("\r\nTo exit, please reset the board without ")); + serial_write_compressed(translate("\nTo exit, please reset the board without ")); serial_write(BOARD_USER_SAFE_MODE_ACTION); - serial_write("\r\n"); + serial_write("\n"); } else #endif switch (reason) { case MANUAL_SAFE_MODE: - serial_write_compressed(translate("CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.\r\n")); + serial_write_compressed(translate("CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.\n")); return; case PROGRAMMATIC_SAFE_MODE: - serial_write_compressed(translate("The `microcontroller` module was used to boot into safe mode. Press reset to exit safe mode.\r\n")); + serial_write_compressed(translate("The `microcontroller` module was used to boot into safe mode. Press reset to exit safe mode.\n")); return; default: break; } - serial_write_compressed(translate("You are in safe mode: something unanticipated happened.\r\n")); + serial_write_compressed(translate("You are in safe mode: something unanticipated happened.\n")); switch (reason) { case BROWNOUT: - serial_write_compressed(translate("The microcontroller's power dipped. Make sure your power supply provides\r\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\r\n")); + serial_write_compressed(translate("The microcontroller's power dipped. Make sure your power supply provides\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\n")); return; case HEAP_OVERWRITTEN: - serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\r\nPlease increase the stack size if you know how, or if not:")); + serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\nPlease increase the stack size if you know how, or if not:")); serial_write_compressed(FILE_AN_ISSUE); return; default: break; } - serial_write_compressed(translate("CircuitPython core code crashed hard. Whoops!\r\n")); + serial_write_compressed(translate("CircuitPython core code crashed hard. Whoops!\n")); switch (reason) { case HARD_CRASH: serial_write_compressed(translate("Crash into the HardFault_Handler.")); From e11fabd5e0979fa257a81d6025a0df0b6652b600 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 12 Dec 2019 14:57:23 -0500 Subject: [PATCH 186/531] moved nrf internal filesystem to just below bootloader --- ports/atmel-samd/mpconfigport.h | 10 +++++----- ports/nrf/boards/common.template.ld | 2 +- ports/nrf/mpconfigport.h | 28 +++++++++++++++++----------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index a319c6199a..846e8db707 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -151,11 +151,11 @@ // Flash layout, starting at 0x00000000 // -// bootloader (8 or 16kB) -// firmware -// internal CIRCUITPY flash filesystem (optional) -// internal config, used to store crystalless clock calibration info (optional) -// microntroller.nvm (optional) +// - bootloader (8 or 16kB) +// - firmware +// - internal CIRCUITPY flash filesystem (optional) +// - internal config, used to store crystalless clock calibration info (optional) +// - microntroller.nvm (optional) // Define these regions starting up from the bottom of flash: diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index f267234924..931f95ee9e 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -11,9 +11,9 @@ MEMORY FLASH_SD (rx) : ORIGIN = ${SD_FLASH_START_ADDR}, LENGTH = ${SD_FLASH_SIZE} FLASH_ISR (rx) : ORIGIN = ${ISR_START_ADDR}, LENGTH = ${ISR_SIZE} FLASH_FIRMWARE (rx) : ORIGIN = ${CIRCUITPY_FIRMWARE_START_ADDR}, LENGTH = ${CIRCUITPY_FIRMWARE_SIZE} - FLASH_FATFS (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE} FLASH_BLE_CONFIG (r) : ORIGIN = ${CIRCUITPY_BLE_CONFIG_START_ADDR}, LENGTH = ${CIRCUITPY_BLE_CONFIG_SIZE} FLASH_NVM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_NVM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_NVM_SIZE} + FLASH_FATFS (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE} FLASH_BOOTLOADER (rx) : ORIGIN = ${BOOTLOADER_START_ADDR}, LENGTH = ${BOOTLOADER_SIZE} FLASH_BOOTLOADER_SETTINGS (r) : ORIGIN = ${BOOTLOADER_SETTINGS_START_ADDR}, LENGTH = ${BOOTLOADER_SETTINGS_SIZE} RAM (xrw) : ORIGIN = 0x20004000, LENGTH = 0x03C000 /* 240 KiB */ diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 71bf6bc8f0..cb25870dc0 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -76,14 +76,16 @@ // Flash layout, starting at 0x00000000 // -// SoftDevice -// ISR -// firmware -// internal CIRCUITPY flash filesystem (optional) -// BLE config (bonding info, etc.) (optional) -// microcontroller.nvm (optional) -// bootloader (note the MBR at 0x0 redirects to the bootloader here, in high flash) -// bootloader settings +// - SoftDevice +// - ISR +// - firmware +// - BLE config (bonding info, etc.) (optional) +// - microcontroller.nvm (optional) +// - internal CIRCUITPY flash filesystem (optional) +// The flash filesystem is adjacent to the bootloader, so that its location will not change even if +// other regions change in size. +// - bootloader (note the MBR at 0x0 redirects to the bootloader here, in high flash) +// - bootloader settings // Define these regions starting up from the bottom of flash: @@ -105,14 +107,18 @@ #define BOOTLOADER_SETTINGS_START_ADDR (0x000FF000) #define BOOTLOADER_SETTINGS_SIZE (0x1000) // 4kiB -#define CIRCUITPY_INTERNAL_NVM_START_ADDR (BOOTLOADER_START_ADDR - CIRCUITPY_INTERNAL_NVM_SIZE) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR (BOOTLOADER_START_ADDR - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE) + +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE > 0 && CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR != (BOOTLOADER_START_ADDR - 256*1024) +#warning Internal flash filesystem location has moved! +#endif + +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_INTERNAL_NVM_SIZE) // 32kiB for bonding, etc. #define CIRCUITPY_BLE_CONFIG_SIZE (32*1024) #define CIRCUITPY_BLE_CONFIG_START_ADDR (CIRCUITPY_INTERNAL_NVM_START_ADDR - CIRCUITPY_BLE_CONFIG_SIZE) -#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR (CIRCUITPY_BLE_CONFIG_START_ADDR - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE) - // The firmware space is the space left over between the fixed lower and upper regions. #define CIRCUITPY_FIRMWARE_SIZE (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR) From 842f8b2d3dd3db3b29929840afcb9a23072a99b3 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 16:27:32 -0500 Subject: [PATCH 187/531] Revert "Remove meowbit for now" This reverts commit 006182f4e867840266a0c3a669fc7938ef03a9fc. --- ports/stm32f4/boards/meowbit_v121/board.c | 39 ++ .../boards/meowbit_v121/mpconfigboard.h | 52 +++ .../boards/meowbit_v121/mpconfigboard.mk | 19 + ports/stm32f4/boards/meowbit_v121/pins.c | 33 ++ .../boards/meowbit_v121/stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ 5 files changed, 583 insertions(+) create mode 100644 ports/stm32f4/boards/meowbit_v121/board.c create mode 100644 ports/stm32f4/boards/meowbit_v121/mpconfigboard.h create mode 100644 ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/meowbit_v121/pins.c create mode 100644 ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h diff --git a/ports/stm32f4/boards/meowbit_v121/board.c b/ports/stm32f4/boards/meowbit_v121/board.c new file mode 100644 index 0000000000..82b0c506ed --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h new file mode 100644 index 0000000000..67ddc885ae --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "Feather STM32F405 Express" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define AUTORESET_DELAY_MS 500 +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PB05 +#define SPI_FLASH_MISO_PIN &pin_PB04 +#define SPI_FLASH_SCK_PIN &pin_PB03 +#define SPI_FLASH_CS_PIN &pin_PA15 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PB11) +#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk new file mode 100644 index 0000000000..5bad4e81f3 --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x805A +USB_PRODUCT = "Feather STM32F405 Express" +USB_MANUFACTURER = "Adafruit Industries LLC" +USB_DEVICES = "CDC,MSC" + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f405xx +MCU_PACKAGE = 64 +CMSIS_MCU = STM32F405xx +LD_FILE = boards/STM32F405.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08010000 \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c new file mode 100644 index 0000000000..4aa1f362ad --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -0,0 +1,33 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..68a49b4ba8 --- /dev/null +++ b/ports/stm32f4/boards/meowbit_v121/stm32f4xx_hal_conf.h @@ -0,0 +1,440 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)40000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 2be18a7b530149926d492f7b8d5c583849906964 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 16:30:24 -0500 Subject: [PATCH 188/531] revert dumb thing --- ....h~parent of 352bd95f5... remove blackpill | 41 +++++++++++++++++++ .../boards/stm32f411ce_blackpill/pins.c | 1 - 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill new file mode 100644 index 0000000000..8a482ce7dc --- /dev/null +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "stm32f411ce-blackpill" +#define MICROPY_HW_MCU_NAME "STM32F411CE" + +#define FLASH_SIZE (0x80000) +#define FLASH_PAGE_SIZE (0x4000) + +#define BOARD_OSC_DIV 25 + +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c index 5797a9762b..aa9736fc4c 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/pins.c @@ -34,7 +34,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_C15), MP_ROM_PTR(&pin_PC15) }, { MP_ROM_QSTR(MP_QSTR_C14), MP_ROM_PTR(&pin_PC14) }, { MP_ROM_QSTR(MP_QSTR_C13), MP_ROM_PTR(&pin_PC13) }, - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PC13) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 7e0719117bca20ab4345504d888aa5638abdb98c Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 16:32:33 -0500 Subject: [PATCH 189/531] Revert "remove F401 additions to streamline" This reverts commit 12737e282152d7bed7dac540029af9dd5b423ec6. --- ports/stm32f4/peripherals/stm32f4/periph.h | 6 + .../peripherals/stm32f4/stm32f401xe/clocks.c | 61 +++++++ .../peripherals/stm32f4/stm32f401xe/gpio.c | 54 ++++++ .../peripherals/stm32f4/stm32f401xe/periph.c | 172 ++++++++++++++++++ .../peripherals/stm32f4/stm32f401xe/periph.h | 57 ++++++ .../peripherals/stm32f4/stm32f401xe/pins.c | 123 +++++++++++++ .../peripherals/stm32f4/stm32f401xe/pins.h | 121 ++++++++++++ 7 files changed, 594 insertions(+) create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h diff --git a/ports/stm32f4/peripherals/stm32f4/periph.h b/ports/stm32f4/peripherals/stm32f4/periph.h index 0d1374e850..ac98b89320 100644 --- a/ports/stm32f4/peripherals/stm32f4/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/periph.h @@ -140,6 +140,12 @@ typedef struct { //Starter Lines +#ifdef STM32F401xE +#define HAS_DAC 0 +#define HAS_TRNG 0 +#include "stm32f401xe/periph.h" +#endif + #ifdef STM32F411xE #define HAS_DAC 0 #define HAS_TRNG 0 diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c new file mode 100644 index 0000000000..883c252d51 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c @@ -0,0 +1,61 @@ + +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" + +void stm32f4_peripherals_clocks_init(void) { + //System clock init + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; + RCC_OscInitStruct.PLL.PLLQ = 7; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); +} diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c new file mode 100644 index 0000000000..45dc8fc6fa --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c @@ -0,0 +1,54 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" +#include "stm32f4/gpio.h" +#include "common-hal/microcontroller/Pin.h" + +void stm32f4_peripherals_gpio_init(void) { + //Enable all GPIO for now + GPIO_InitTypeDef GPIO_InitStruct = {0}; + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + + //Never reset pins + never_reset_pin_number(2,13); //PC13 anti tamp + never_reset_pin_number(2,14); //PC14 OSC32_IN + never_reset_pin_number(2,15); //PC15 OSC32_OUT + never_reset_pin_number(0,13); //PA13 SWDIO + never_reset_pin_number(0,14); //PA14 SWCLK +} + +//LEDs are inverted on F411 DISCO +void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { +} + + diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c new file mode 100644 index 0000000000..859e9a1adb --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c @@ -0,0 +1,172 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" +#include "py/mphal.h" +#include "stm32f4/pins.h" +#include "stm32f4/periph.h" + +// I2C + +I2C_TypeDef * mcu_i2c_banks[3] = {I2C1, I2C2, I2C3}; + +const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5] = { + I2C_SDA(1, 4, &pin_PB07), + I2C_SDA(1, 4, &pin_PB09), + I2C_SDA(2, 9, &pin_PB03), + I2C_SDA(3, 4, &pin_PC09), + I2C_SDA(3, 9, &pin_PB04), +}; + +const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { + I2C_SCL(1, 4, &pin_PB06), + I2C_SCL(1, 4, &pin_PB08), + I2C_SCL(2, 4, &pin_PB10), + I2C_SCL(3, 4, &pin_PA08) +}; + +// SPI + +SPI_TypeDef * mcu_spi_banks[4] = {SPI1, SPI2, SPI3, SPI4}; + +const mcu_spi_sck_obj_t mcu_spi_sck_list[9] = { + SPI(1, 5, &pin_PA05), + SPI(1, 5, &pin_PB03), + SPI(2, 5, &pin_PB10), + SPI(2, 5, &pin_PB13), + SPI(2, 5, &pin_PD03), + SPI(3, 6, &pin_PB03), + SPI(3, 6, &pin_PC10), + SPI(4, 5, &pin_PE02), + SPI(4, 5, &pin_PE12), +}; + +const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9] = { + SPI(1, 5, &pin_PA07), + SPI(1, 5, &pin_PB05), + SPI(2, 5, &pin_PB15), + SPI(2, 5, &pin_PC03), + SPI(3, 6, &pin_PB05), + SPI(3, 6, &pin_PC12), + SPI(3, 5, &pin_PD06), + SPI(4, 5, &pin_PE06), + SPI(4, 5, &pin_PE14), +}; + +const mcu_spi_miso_obj_t mcu_spi_miso_list[8] = { + SPI(1, 5, &pin_PA06), + SPI(1, 5, &pin_PB04), + SPI(2, 5, &pin_PB14), + SPI(2, 5, &pin_PC02), + SPI(3, 6, &pin_PB04), + SPI(3, 6, &pin_PC11), + SPI(4, 5, &pin_PE05), + SPI(4, 5, &pin_PE13), +}; + +const mcu_spi_nss_obj_t mcu_spi_nss_list[9] = { + SPI(1, 5, &pin_PA04), + SPI(1, 5, &pin_PA15), + SPI(2, 5, &pin_PB09), + SPI(2, 5, &pin_PB12), + SPI(3, 6, &pin_PA04), + SPI(3, 6, &pin_PA15), + SPI(4, 6, &pin_PB12), + SPI(4, 5, &pin_PE04), + SPI(4, 5, &pin_PE11), +}; + +USART_TypeDef * mcu_uart_banks[MAX_UART] = {USART1, USART2, NULL, NULL, NULL, USART6}; +bool mcu_uart_has_usart[MAX_UART] = {true, true, false, false, false, true}; + +const mcu_uart_tx_obj_t mcu_uart_tx_list[6] = { + UART(2, 7, &pin_PA02), + UART(1, 7, &pin_PA09), + UART(6, 8, &pin_PA11), + UART(1, 7, &pin_PB06), + UART(6, 8, &pin_PC06), + UART(2, 7, &pin_PD05), +}; + +const mcu_uart_rx_obj_t mcu_uart_rx_list[6] = { + UART(2, 7, &pin_PA03), + UART(1, 7, &pin_PA10), + UART(6, 8, &pin_PA12), + UART(1, 7, &pin_PB07), + UART(6, 8, &pin_PC07), + UART(2, 7, &pin_PD06), +}; + +//Timers +//TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins +TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10, + TIM11, NULL, NULL, NULL}; + +const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { + TIM(2,1,1,&pin_PA00), + TIM(5,2,1,&pin_PA00), + TIM(2,1,2,&pin_PA01), + TIM(5,2,2,&pin_PA01), + TIM(2,1,3,&pin_PA02), + TIM(5,2,3,&pin_PA02), + TIM(2,1,4,&pin_PA03), + TIM(5,2,4,&pin_PA03), + TIM(9,3,1,&pin_PA02), + TIM(9,3,2,&pin_PA03), + TIM(3,2,1,&pin_PA06), + TIM(3,2,2,&pin_PA07), + TIM(1,1,1,&pin_PA08), + TIM(1,1,2,&pin_PA09), + TIM(1,1,3,&pin_PA10), + TIM(1,1,4,&pin_PA11), + TIM(2,1,1,&pin_PA15), + TIM(3,2,3,&pin_PB00), + TIM(3,2,4,&pin_PB01), + TIM(2,1,2,&pin_PB03), + TIM(3,2,1,&pin_PB04), + TIM(3,2,2,&pin_PB05), + TIM(4,2,1,&pin_PB06), + TIM(4,2,2,&pin_PB07), + TIM(4,2,3,&pin_PB08), + TIM(10,2,1,&pin_PB08), + TIM(4,2,4,&pin_PB09), + TIM(11,2,1,&pin_PB09), + TIM(2,1,3,&pin_PB10), + TIM(3,2,1,&pin_PC06), + TIM(3,2,2,&pin_PC07), + TIM(3,2,3,&pin_PC08), + TIM(3,2,4,&pin_PC09), + TIM(4,2,1,&pin_PD12), + TIM(4,2,2,&pin_PD13), + TIM(4,2,3,&pin_PD14), + TIM(4,2,4,&pin_PD15), + TIM(9,3,1,&pin_PE05), + TIM(9,3,2,&pin_PE06), + TIM(1,1,1,&pin_PE09), + TIM(1,1,2,&pin_PE11), + TIM(1,1,3,&pin_PE13), + TIM(1,1,4,&pin_PE14), +}; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h new file mode 100644 index 0000000000..7d3f4dca22 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h @@ -0,0 +1,57 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H + +//I2C +extern I2C_TypeDef * mcu_i2c_banks[3]; + +extern const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5]; +extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; + +//SPI +extern SPI_TypeDef * mcu_spi_banks[4]; + +extern const mcu_spi_sck_obj_t mcu_spi_sck_list[9]; +extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9]; +extern const mcu_spi_miso_obj_t mcu_spi_miso_list[8]; +extern const mcu_spi_nss_obj_t mcu_spi_nss_list[9]; + +//UART +extern USART_TypeDef * mcu_uart_banks[MAX_UART]; +extern bool mcu_uart_has_usart[MAX_UART]; + +extern const mcu_uart_tx_obj_t mcu_uart_tx_list[6]; +extern const mcu_uart_rx_obj_t mcu_uart_rx_list[6]; + +//Timers +#define TIM_BANK_ARRAY_LEN 14 +#define TIM_PIN_ARRAY_LEN 44 +TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN]; +const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c new file mode 100644 index 0000000000..7e88c3dcba --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.c @@ -0,0 +1,123 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" +#include "py/mphal.h" +#include "stm32f4/pins.h" + +const mcu_pin_obj_t pin_PE02 = PIN(4, 2, NO_ADC); +const mcu_pin_obj_t pin_PE03 = PIN(4, 3, NO_ADC); +const mcu_pin_obj_t pin_PE04 = PIN(4, 4, NO_ADC); +const mcu_pin_obj_t pin_PE05 = PIN(4, 5, NO_ADC); +const mcu_pin_obj_t pin_PE06 = PIN(4, 6, NO_ADC); + +const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); //anti-tamp +const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); //OSC32_IN +const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); //OSC32_OUT + +const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_1,10)); +const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_1,11)); +const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_1,12)); +const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_1,13)); + +const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1,0)); +const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1,1)); +const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1,2)); +const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1,3)); +const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1,4)); +const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1,5)); +const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1,6)); +const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1,7)); + +const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_1,14)); +const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_1,15)); + +const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1,8)); +const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1,9)); +const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); + +const mcu_pin_obj_t pin_PE07 = PIN(4, 7, NO_ADC); +const mcu_pin_obj_t pin_PE08 = PIN(4, 8, NO_ADC); +const mcu_pin_obj_t pin_PE09 = PIN(4, 9, NO_ADC); +const mcu_pin_obj_t pin_PE10 = PIN(4, 10, NO_ADC); +const mcu_pin_obj_t pin_PE11 = PIN(4, 11, NO_ADC); +const mcu_pin_obj_t pin_PE12 = PIN(4, 12, NO_ADC); +const mcu_pin_obj_t pin_PE13 = PIN(4, 13, NO_ADC); +const mcu_pin_obj_t pin_PE14 = PIN(4, 14, NO_ADC); +const mcu_pin_obj_t pin_PE15 = PIN(4, 15, NO_ADC); + +const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); +const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); +const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); +const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); +const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); + +const mcu_pin_obj_t pin_PD08 = PIN(3, 8, NO_ADC); +const mcu_pin_obj_t pin_PD09 = PIN(3, 9, NO_ADC); +const mcu_pin_obj_t pin_PD10 = PIN(3, 10, NO_ADC); +const mcu_pin_obj_t pin_PD11 = PIN(3, 11, NO_ADC); +const mcu_pin_obj_t pin_PD12 = PIN(3, 12, NO_ADC); +const mcu_pin_obj_t pin_PD13 = PIN(3, 13, NO_ADC); +const mcu_pin_obj_t pin_PD14 = PIN(3, 14, NO_ADC); +const mcu_pin_obj_t pin_PD15 = PIN(3, 15, NO_ADC); + +const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); +const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); +const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); +const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); + +const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); +const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); +const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); +const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); +const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); +const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); //SWDIO +const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); //SWCLK +const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); //JTDI + +const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); +const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); +const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); + +const mcu_pin_obj_t pin_PD00 = PIN(3, 0, NO_ADC); +const mcu_pin_obj_t pin_PD01 = PIN(3, 1, NO_ADC); +const mcu_pin_obj_t pin_PD02 = PIN(3, 2, NO_ADC); +const mcu_pin_obj_t pin_PD03 = PIN(3, 3, NO_ADC); +const mcu_pin_obj_t pin_PD04 = PIN(3, 4, NO_ADC); +const mcu_pin_obj_t pin_PD05 = PIN(3, 5, NO_ADC); +const mcu_pin_obj_t pin_PD06 = PIN(3, 6, NO_ADC); +const mcu_pin_obj_t pin_PD07 = PIN(3, 7, NO_ADC); + +const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); +const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); +const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); +const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); +const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); +const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); +const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); + +const mcu_pin_obj_t pin_PE00 = PIN(4, 0, NO_ADC); +const mcu_pin_obj_t pin_PE01 = PIN(4, 1, NO_ADC); \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h new file mode 100644 index 0000000000..37d3a5cf11 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h @@ -0,0 +1,121 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H + +//Pins in datasheet order: DocID026289 Rev 7 page 38. LQFP100 only +//pg 38 +extern const mcu_pin_obj_t pin_PE02; +extern const mcu_pin_obj_t pin_PE03; +extern const mcu_pin_obj_t pin_PE04; +extern const mcu_pin_obj_t pin_PE05; +//pg 39 +extern const mcu_pin_obj_t pin_PE06; +extern const mcu_pin_obj_t pin_PC13; +extern const mcu_pin_obj_t pin_PC14; +extern const mcu_pin_obj_t pin_PC15; +extern const mcu_pin_obj_t pin_PC00; +extern const mcu_pin_obj_t pin_PC01; +extern const mcu_pin_obj_t pin_PC02; +extern const mcu_pin_obj_t pin_PC03; +//pg 40 +extern const mcu_pin_obj_t pin_PA00; +extern const mcu_pin_obj_t pin_PA01; +extern const mcu_pin_obj_t pin_PA02; +extern const mcu_pin_obj_t pin_PA03; +extern const mcu_pin_obj_t pin_PA04; +extern const mcu_pin_obj_t pin_PA05; +extern const mcu_pin_obj_t pin_PA06; +extern const mcu_pin_obj_t pin_PA07; +//pg 41 +extern const mcu_pin_obj_t pin_PC04; +extern const mcu_pin_obj_t pin_PC05; +extern const mcu_pin_obj_t pin_PB00; +extern const mcu_pin_obj_t pin_PB01; +extern const mcu_pin_obj_t pin_PB02; +extern const mcu_pin_obj_t pin_PE07; +extern const mcu_pin_obj_t pin_PE08; +extern const mcu_pin_obj_t pin_PE09; +extern const mcu_pin_obj_t pin_PE10; +extern const mcu_pin_obj_t pin_PE11; +extern const mcu_pin_obj_t pin_PE12; +extern const mcu_pin_obj_t pin_PE13; +extern const mcu_pin_obj_t pin_PE14; +extern const mcu_pin_obj_t pin_PE15; +//pg 42 +extern const mcu_pin_obj_t pin_PB10; +extern const mcu_pin_obj_t pin_PB12; +extern const mcu_pin_obj_t pin_PB13; +extern const mcu_pin_obj_t pin_PB14; +extern const mcu_pin_obj_t pin_PB15; +extern const mcu_pin_obj_t pin_PD08; +extern const mcu_pin_obj_t pin_PD09; +extern const mcu_pin_obj_t pin_PD10; +extern const mcu_pin_obj_t pin_PD11; +extern const mcu_pin_obj_t pin_PD12; +//pg 43 +extern const mcu_pin_obj_t pin_PD13; +extern const mcu_pin_obj_t pin_PD14; +extern const mcu_pin_obj_t pin_PD15; +extern const mcu_pin_obj_t pin_PC06; +extern const mcu_pin_obj_t pin_PC07; +extern const mcu_pin_obj_t pin_PC08; +extern const mcu_pin_obj_t pin_PC09; +extern const mcu_pin_obj_t pin_PA08; +extern const mcu_pin_obj_t pin_PA09; +//pg 44 +extern const mcu_pin_obj_t pin_PA10; +extern const mcu_pin_obj_t pin_PA11; +extern const mcu_pin_obj_t pin_PA12; +extern const mcu_pin_obj_t pin_PA13; +extern const mcu_pin_obj_t pin_PA14; +extern const mcu_pin_obj_t pin_PA15; +extern const mcu_pin_obj_t pin_PC10; +extern const mcu_pin_obj_t pin_PC11; +extern const mcu_pin_obj_t pin_PC12; +//pg 45 +extern const mcu_pin_obj_t pin_PD00; +extern const mcu_pin_obj_t pin_PD01; +extern const mcu_pin_obj_t pin_PD02; +extern const mcu_pin_obj_t pin_PD03; +extern const mcu_pin_obj_t pin_PD04; +extern const mcu_pin_obj_t pin_PD05; +extern const mcu_pin_obj_t pin_PD06; +extern const mcu_pin_obj_t pin_PD07; +extern const mcu_pin_obj_t pin_PB03; +extern const mcu_pin_obj_t pin_PB04; +extern const mcu_pin_obj_t pin_PB05; +extern const mcu_pin_obj_t pin_PB06; +//pg 46 +extern const mcu_pin_obj_t pin_PB07; +extern const mcu_pin_obj_t pin_PB08; +extern const mcu_pin_obj_t pin_PB09; +extern const mcu_pin_obj_t pin_PE00; +extern const mcu_pin_obj_t pin_PE01; + + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H From 9a3d45e7d0fd942201f4bb2102d9d5489bd7cb86 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 12 Dec 2019 13:46:51 -0800 Subject: [PATCH 190/531] Add extended, connectable and scannable error. Related to https://github.com/adafruit/Adafruit_CircuitPython_BLE/issues/44 --- shared-bindings/_bleio/Adapter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 9772fa830d..5d3211b0c4 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -29,6 +29,7 @@ #include "py/objproperty.h" #include "py/runtime.h" +#include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/Address.h" #include "shared-bindings/_bleio/Adapter.h" @@ -185,7 +186,12 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t ADV_INTERVAL_MIN_STRING, ADV_INTERVAL_MAX_STRING); } - common_hal_bleio_adapter_start_advertising(self, args[ARG_connectable].u_bool, interval, + bool connectable = args[ARG_connectable].u_bool; + if (data_bufinfo.len > 31 && connectable && scan_response_bufinfo.len > 0) { + mp_raise_bleio_BluetoothError(translate("Cannot have scan responses for extended, connectable advertisements.")); + } + + common_hal_bleio_adapter_start_advertising(self, connectable, interval, &data_bufinfo, &scan_response_bufinfo); return mp_const_none; From e4fb414b913c9a5f0cdaa3aa0b715595a88ac3a9 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 17:17:29 -0500 Subject: [PATCH 191/531] clean up definitions post merge --- .../boards/meowbit_v121/mpconfigboard.h | 3 +++ .../common-hal/microcontroller/__init__.c | 2 +- ports/stm32f4/supervisor/usb.c | 20 +++++++++---------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index f2fe3ca804..eb526d0a75 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -35,6 +35,9 @@ #define AUTORESET_DELAY_MS 500 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) +#define BOARD_OSC_DIV 12 +#define BOARD_NO_VBUS + // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) #define SPI_FLASH_MISO_PIN (&pin_PB14) diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c index 16cc056c16..0c680eb055 100644 --- a/ports/stm32f4/common-hal/microcontroller/__init__.c +++ b/ports/stm32f4/common-hal/microcontroller/__init__.c @@ -169,7 +169,7 @@ STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) }, #endif { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, -#if MCU_PACKAGE == 144 +#if MCU_PACKAGE == 144 || defined STM32F405xx { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, #endif { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 6e9b233a47..3ebb74dc74 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -36,6 +36,16 @@ #include "common-hal/microcontroller/Pin.h" +STATIC void disable_usb_vbus(void) { +#ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; +#else + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; +#endif +} + void init_usb_hardware(void) { //TODO: if future chips overload this with options, move to peripherals management. @@ -89,13 +99,3 @@ void init_usb_hardware(void) { /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); } - -STATIC void disable_usb_vbus(void) { -#ifdef USB_OTG_GCCFG_VBDEN - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; -#else - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; -#endif -} From 99c02b5afb9d79fa4e4c31067acca219f73ee4ff Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 12 Dec 2019 17:53:04 -0500 Subject: [PATCH 192/531] usb not working... --- ports/stm32f4/boards/meowbit_v121/pins.c | 11 ++++++++- ports/stm32f4/supervisor/usb.c | 30 +++++++++++++++--------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index dc0003dd15..3a26b232aa 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -2,6 +2,15 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) }, - { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) } + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) }, + + // { MP_ROM_QSTR(MP_QSTR_LED_DISP_SCK), MP_ROM_PTR(&pin_PB13) }, + // { MP_ROM_QSTR(MP_QSTR_LED_DISP_MISO), MP_ROM_PTR(&pin_PB14) }, + // { MP_ROM_QSTR(MP_QSTR_LED_DISP_MOSI), MP_ROM_PTR(&pin_PB15) }, + // { MP_ROM_QSTR(MP_QSTR_LED_DISP_CS), MP_ROM_PTR(&pin_PB12) }, + // { MP_ROM_QSTR(MP_QSTR_LED_DISP_DC), MP_ROM_PTR(&pin_PA08) }, + // { MP_ROM_QSTR(MP_QSTR_LED_DISP_RST), MP_ROM_PTR(&pin_PB10) }, + // { MP_ROM_QSTR(MP_QSTR_LED_DISP_BL), MP_ROM_PTR(&pin_PB03) } + }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 3ebb74dc74..483dddcfc6 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -36,15 +36,15 @@ #include "common-hal/microcontroller/Pin.h" -STATIC void disable_usb_vbus(void) { -#ifdef USB_OTG_GCCFG_VBDEN - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; -#else - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; -#endif -} +// STATIC void disable_usb_vbus(void) { +// #ifdef USB_OTG_GCCFG_VBDEN +// USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; +// #else +// USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; +// USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; +// USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; +// #endif +// } void init_usb_hardware(void) { //TODO: if future chips overload this with options, move to peripherals management. @@ -92,8 +92,16 @@ void init_usb_hardware(void) { never_reset_pin_number(0, 8); #endif -#ifdef BOARD_NO_VBUS - disable_usb_vbus(); +// #ifdef BOARD_NO_VBUS +// disable_usb_vbus(); +// #endif + +#ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; +#else + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; #endif /* Peripheral clock enable */ From 51ba0ed2501ba2467e2b8da708bcc8ba6ab09a7c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 12 Dec 2019 15:33:46 -0800 Subject: [PATCH 193/531] Update translations --- locale/ID.po | 6 +++++- locale/circuitpython.pot | 6 +++++- locale/de_DE.po | 6 +++++- locale/en_US.po | 6 +++++- locale/en_x_pirate.po | 6 +++++- locale/es.po | 6 +++++- locale/fil.po | 6 +++++- locale/fr.po | 6 +++++- locale/it_IT.po | 6 +++++- locale/ko.po | 6 +++++- locale/pl.po | 6 +++++- locale/pt_BR.po | 6 +++++- locale/zh_Latn_pinyin.po | 6 +++++- 13 files changed, 65 insertions(+), 13 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index c147a5f5f9..18773a2027 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -419,6 +419,10 @@ msgstr "Tidak bisa mendapatkan pull pada saat mode output" msgid "Cannot get temperature" msgstr "Tidak bisa mendapatkan temperatur. status: 0x%02x" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index e21541d7e2..f4b67521ce 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -413,6 +413,10 @@ msgstr "" msgid "Cannot get temperature" msgstr "" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index f1158b1b3a..36d2f266d7 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -417,6 +417,10 @@ msgstr "Pull up im Ausgabemodus nicht möglich" msgid "Cannot get temperature" msgstr "Kann Temperatur nicht holen" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "Kann nicht beite Kanäle auf dem gleichen Pin ausgeben" diff --git a/locale/en_US.po b/locale/en_US.po index c6f342186f..7da32614f4 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -413,6 +413,10 @@ msgstr "" msgid "Cannot get temperature" msgstr "" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 54d246e2de..867618bd98 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -417,6 +417,10 @@ msgstr "" msgid "Cannot get temperature" msgstr "" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "" diff --git a/locale/es.po b/locale/es.po index 7ced099be5..285d1d8515 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -419,6 +419,10 @@ msgstr "No puede ser pull mientras este en modo de salida" msgid "Cannot get temperature" msgstr "No se puede obtener la temperatura." +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "No se puede tener ambos canales en el mismo pin" diff --git a/locale/fil.po b/locale/fil.po index 16fac72244..6600ffb9a6 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -421,6 +421,10 @@ msgstr "Hindi makakakuha ng pull habang nasa output mode" msgid "Cannot get temperature" msgstr "Hindi makuha ang temperatura. status 0x%02x" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "Hindi maaaring output ang mga parehong channel sa parehong pin" diff --git a/locale/fr.po b/locale/fr.po index 9762b5e7da..6437b8ba86 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -425,6 +425,10 @@ msgstr "Ne peut être tiré ('pull') en mode 'output'" msgid "Cannot get temperature" msgstr "Impossible de lire la température" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "Les 2 canaux de sortie ne peuvent être sur la même broche" diff --git a/locale/it_IT.po b/locale/it_IT.po index 0a3c30d2bd..a659664a00 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -421,6 +421,10 @@ msgstr "non si può tirare quando nella modalita output" msgid "Cannot get temperature" msgstr "Impossibile leggere la temperatura. status: 0x%02x" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "Impossibile dare in output entrambi i canal sullo stesso pin" diff --git a/locale/ko.po b/locale/ko.po index 78f0c756b1..c47c10a94d 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -417,6 +417,10 @@ msgstr "" msgid "Cannot get temperature" msgstr "온도 데이터를 수신 할 수 없습니다" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 60aac45a3f..8d564c2431 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -416,6 +416,10 @@ msgstr "Nie ma podciągnięcia w trybie wyjścia" msgid "Cannot get temperature" msgstr "Nie można odczytać temperatury" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "Nie można mieć obu kanałów na tej samej nóżce" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 0aa2ac6308..48cf9e77ef 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -418,6 +418,10 @@ msgstr "" msgid "Cannot get temperature" msgstr "Não pode obter a temperatura. status: 0x%02x" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index bd5b80a724..63889a52d6 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 14:51-0500\n" +"POT-Creation-Date: 2019-12-12 15:33-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -417,6 +417,10 @@ msgstr "Zài shūchū móshì xià wúfǎ huòqǔ lādòng" msgid "Cannot get temperature" msgstr "Wúfǎ huòqǔ wēndù" +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" msgstr "Wúfǎ shūchū tóng yīgè yǐn jiǎo shàng de liǎng gè píndào" From 4bee6536c9db82d8ba51c4e1391b99e017d9a7e4 Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Fri, 13 Dec 2019 08:52:03 -0500 Subject: [PATCH 194/531] updates to bluebird --- ports/nrf/boards/pca10056/mpconfigboard.h | 62 +++++++++---------- ports/nrf/boards/pca10056/mpconfigboard.mk | 16 ----- ports/nrf/boards/pca10059/mpconfigboard.h | 2 - ports/nrf/boards/pca10059/mpconfigboard.mk | 17 +---- .../boards/teknikio_bluebird/mpconfigboard.h | 4 +- .../boards/teknikio_bluebird/mpconfigboard.mk | 3 - 6 files changed, 32 insertions(+), 72 deletions(-) diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h index 5b30c7fe83..b34bc83260 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.h +++ b/ports/nrf/boards/pca10056/mpconfigboard.h @@ -24,42 +24,40 @@ * THE SOFTWARE. */ -#include "nrfx/hal/nrf_gpio.h" + #include "nrfx/hal/nrf_gpio.h" -#define MICROPY_HW_BOARD_NAME "PCA10056 nRF52840-DK" -#define MICROPY_HW_MCU_NAME "nRF52840" + #define MICROPY_HW_BOARD_NAME "PCA10056 nRF52840-DK" + #define MICROPY_HW_MCU_NAME "nRF52840" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + #define MICROPY_HW_LED_STATUS (&pin_P0_13) -#define MICROPY_HW_LED_STATUS (&pin_P0_13) + #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) + #define DEFAULT_I2C_BUS_SDA (&pin_P0_26) -#define DEFAULT_I2C_BUS_SCL (&pin_P0_27) -#define DEFAULT_I2C_BUS_SDA (&pin_P0_26) + #define DEFAULT_SPI_BUS_SCK (&pin_P1_15) + #define DEFAULT_SPI_BUS_MOSI (&pin_P1_13) + #define DEFAULT_SPI_BUS_MISO (&pin_P1_14) -#define DEFAULT_SPI_BUS_SCK (&pin_P1_15) -#define DEFAULT_SPI_BUS_MOSI (&pin_P1_13) -#define DEFAULT_SPI_BUS_MISO (&pin_P1_14) + #define DEFAULT_UART_BUS_RX (&pin_P1_01) + #define DEFAULT_UART_BUS_TX (&pin_P1_02) -#define DEFAULT_UART_BUS_RX (&pin_P1_01) -#define DEFAULT_UART_BUS_TX (&pin_P1_02) + // Flash operation mode is determined by MICROPY_QSPI_DATAn pin configuration. + // A pin config is valid if it is defined and its value is not 0xFF. + // Quad mode: If all DATA0 --> DATA3 are valid + // Dual mode: If DATA0 and DATA1 are valid while either DATA2 and/or DATA3 are invalid + // Single mode: If only DATA0 is valid + #if QSPI_FLASH_FILESYSTEM + #define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20) + #define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 21) + #define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 22) + #define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 23) + #define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) + #define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 17) + #endif -// Flash operation mode is determined by MICROPY_QSPI_DATAn pin configuration. -// A pin config is valid if it is defined and its value is not 0xFF. -// Quad mode: If all DATA0 --> DATA3 are valid -// Dual mode: If DATA0 and DATA1 are valid while either DATA2 and/or DATA3 are invalid -// Single mode: If only DATA0 is valid -#if QSPI_FLASH_FILESYSTEM -#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20) -#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 21) -#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 22) -#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 23) -#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) -#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 17) -#endif - -#if SPI_FLASH_FILESYSTEM -#define SPI_FLASH_MOSI_PIN &pin_P0_20 -#define SPI_FLASH_MISO_PIN &pin_P0_21 -#define SPI_FLASH_SCK_PIN &pin_P0_19 -#define SPI_FLASH_CS_PIN &pin_P0_17 -#endif + #if SPI_FLASH_FILESYSTEM + #define SPI_FLASH_MOSI_PIN &pin_P0_20 + #define SPI_FLASH_MISO_PIN &pin_P0_21 + #define SPI_FLASH_SCK_PIN &pin_P0_19 + #define SPI_FLASH_CS_PIN &pin_P0_17 + #endif diff --git a/ports/nrf/boards/pca10056/mpconfigboard.mk b/ports/nrf/boards/pca10056/mpconfigboard.mk index 723e7976e1..8fd1ef08d0 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.mk +++ b/ports/nrf/boards/pca10056/mpconfigboard.mk @@ -3,23 +3,7 @@ USB_PID = 0x802A USB_PRODUCT = "PCA10056" USB_MANUFACTURER = "Nordic Semiconductor" -MCU_SERIES = m4 -MCU_VARIANT = nrf52 -MCU_SUB_VARIANT = nrf52840 MCU_CHIP = nrf52840 -SD ?= s140 -SOFTDEV_VERSION ?= 6.1.0 - -BOOT_SETTING_ADDR = 0xFF000 - -ifeq ($(SD),) - LD_FILE = boards/nrf52840_1M_256k.ld -else - LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld - CIRCUITPY_BLEIO = 1 -endif - -NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 diff --git a/ports/nrf/boards/pca10059/mpconfigboard.h b/ports/nrf/boards/pca10059/mpconfigboard.h index b79d3c88f2..18aa66f16b 100644 --- a/ports/nrf/boards/pca10059/mpconfigboard.h +++ b/ports/nrf/boards/pca10059/mpconfigboard.h @@ -28,5 +28,3 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_HW_LED_STATUS (&pin_P0_06) - -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 diff --git a/ports/nrf/boards/pca10059/mpconfigboard.mk b/ports/nrf/boards/pca10059/mpconfigboard.mk index db9d806685..3f97b08218 100644 --- a/ports/nrf/boards/pca10059/mpconfigboard.mk +++ b/ports/nrf/boards/pca10059/mpconfigboard.mk @@ -3,21 +3,6 @@ USB_PID = 0x802A USB_PRODUCT = "PCA10059" USB_MANUFACTURER = "Nordic Semiconductor" -MCU_SERIES = m4 -MCU_VARIANT = nrf52 -MCU_SUB_VARIANT = nrf52840 MCU_CHIP = nrf52840 -SD ?= s140 -SOFTDEV_VERSION ?= 6.1.0 -BOOT_SETTING_ADDR = 0xFF000 -BOOT_FILE = boards/$(BOARD)/bootloader/$(SOFTDEV_VERSION)/$(BOARD)_bootloader_$(SOFTDEV_VERSION)_s140 - -ifeq ($(SD),) - LD_FILE = boards/nrf52840_1M_256k.ld -else - LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld - CIRCUITPY_BLEIO = 1 -endif - -NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 +INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h index 2b8707ad08..76e772ca9b 100644 --- a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.h @@ -33,8 +33,6 @@ #define MICROPY_HW_BOARD_NAME "Teknikio Bluebird" #define MICROPY_HW_MCU_NAME "nRF52840" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define MICROPY_HW_NEOPIXEL (&pin_P0_26) #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) @@ -47,4 +45,4 @@ #define DEFAULT_UART_BUS_RX (&pin_P1_07) #define DEFAULT_UART_BUS_TX (&pin_P1_08) -#define BOARD_HAS_CRYSTAL 1 // according to the schematic we do \ No newline at end of file +#define BOARD_HAS_CRYSTAL 1 // according to the schematic we do diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk index c2b8b7605a..c99b33f3d6 100644 --- a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk @@ -20,6 +20,3 @@ else endif NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 - -INTERNAL_FLASH_FILESYSTEM = 1 - From 32744a04e1334bfa9cbee0e487a19f52eee44d6f Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Fri, 13 Dec 2019 09:08:21 -0500 Subject: [PATCH 195/531] update bluebird make file --- ports/atmel-samd/peripherals | 2 +- .../boards/teknikio_bluebird/mpconfigboard.mk | 20 +++---------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/ports/atmel-samd/peripherals b/ports/atmel-samd/peripherals index 4c0deecf88..2ba5b20ba7 160000 --- a/ports/atmel-samd/peripherals +++ b/ports/atmel-samd/peripherals @@ -1 +1 @@ -Subproject commit 4c0deecf889da0074c1dbc9a5e2d24cb7c7a31c6 +Subproject commit 2ba5b20ba725e1c91c77875fba3a5e22059cdb92 diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk index c99b33f3d6..3f97b08218 100644 --- a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk @@ -1,22 +1,8 @@ USB_VID = 0x239A USB_PID = 0x802A -USB_PRODUCT = "Bluebird" -USB_MANUFACTURER = "Teknikio" +USB_PRODUCT = "PCA10059" +USB_MANUFACTURER = "Nordic Semiconductor" -MCU_SERIES = m4 -MCU_VARIANT = nrf52 -MCU_SUB_VARIANT = nrf52840 MCU_CHIP = nrf52840 -SD ?= s140 -SOFTDEV_VERSION ?= 6.1.0 -BOOT_SETTING_ADDR = 0xFF000 - -ifeq ($(SD),) - LD_FILE = boards/nrf52840_1M_256k.ld -else - LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld - CIRCUITPY_BLEIO = 1 -endif - -NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 +INTERNAL_FLASH_FILESYSTEM = 1 From cc31f2d10fd6cf0b96110c7b390e514dc0c3dbc1 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 13:46:37 -0500 Subject: [PATCH 196/531] update translations --- locale/circuitpython.pot | 2 +- locale/es.po | 10 +++++----- locale/fr.po | 10 +++++----- locale/pl.po | 8 ++++---- locale/zh_Latn_pinyin.po | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 8b9b240a0e..7adde9ba85 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/es.po b/locale/es.po index 6430ab3fb8..331c1a3edd 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -2673,15 +2673,15 @@ msgstr "paso cero" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" -#, c-format -#~ msgid "Can not use dotstar with %s" -#~ msgstr "No se puede usar dotstar con %s" - #~ msgid "Attempted heap allocation when MicroPython VM not running.\n" #~ msgstr "" #~ "Intento de allocation de heap cuando la VM de MicroPython no estaba " #~ "corriendo.\n" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "No se puede usar dotstar con %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "No se pueden agregar servicio en modo Central" diff --git a/locale/fr.po b/locale/fr.po index 5e355b8798..22e3b5b5bc 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -2724,14 +2724,14 @@ msgstr "'step' nul" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" -#, c-format -#~ msgid "Can not use dotstar with %s" -#~ msgstr "Impossible d'utiliser 'dotstar' avec %s" - #~ msgid "Attempted heap allocation when MicroPython VM not running.\n" #~ msgstr "" #~ "Tentative d'allocation de tas alors que la VM MicroPython ne tourne pas.\n" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Impossible d'utiliser 'dotstar' avec %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Impossible d'ajouter des services en mode Central" diff --git a/locale/pl.po b/locale/pl.po index c9c5bb36a7..9b2208849b 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -2637,13 +2637,13 @@ msgstr "zerowy krok" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Adres nie ma długości %d bajtów lub zły format" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "Próba alokacji pamięci na stercie gdy VM nie działa.\n" + #, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Nie można używać dotstar z %s" -#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" -#~ msgstr "Próba alokacji pamięci na stercie gdy VM nie działa.\n" - #~ msgid "Can't add services in Central mode" #~ msgstr "Nie można dodać serwisów w trybie Central" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 0ab65599d7..5b636ff606 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -2650,13 +2650,13 @@ msgstr "líng bù" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "MicroPython VM wèi yùnxíng shí chángshì duī fēnpèi.\n" + #, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" -#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" -#~ msgstr "MicroPython VM wèi yùnxíng shí chángshì duī fēnpèi.\n" - #~ msgid "Can't add services in Central mode" #~ msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" From 15072c69c9e940fa5cb0239fc821d2c0353f918e Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 13:32:58 -0500 Subject: [PATCH 197/531] push changes --- extmod/modbtree.c | 3 ++- extmod/moductypes.c | 4 ++-- py/objlist.c | 8 +++----- py/objtype.c | 10 ++++++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 97a4de3d5b..939ab813e4 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -248,7 +248,8 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { #pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { // delete DBT key; diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 722f4bb872..145b348874 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -519,8 +519,8 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { - mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { + mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); if (value == MP_OBJ_NULL) { // delete diff --git a/py/objlist.c b/py/objlist.c index c544c27f05..0c0d60aa83 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -160,11 +160,11 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { #pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { // delete #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { mp_raise_NotImplementedError(NULL); @@ -180,12 +180,11 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp return mp_const_none; } #endif - mp_obj_t args[2] = {self_in, index}; + mp_obj_t args[2] = {self, index}; list_pop(2, args); return mp_const_none; } else if (value == MP_OBJ_SENTINEL) { // load - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; @@ -202,7 +201,6 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp } else { #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); size_t value_len; mp_obj_t *value_items; mp_obj_get_array(value, &value_len, &value_items); mp_bound_slice_t slice_out; @@ -231,7 +229,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp return mp_const_none; } #endif - mp_obj_list_store(self_in, index, value); + mp_obj_list_store(self, index, value); return mp_const_none; } } diff --git a/py/objtype.c b/py/objtype.c index 9608a9242d..c7dc2ae78f 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -34,6 +34,7 @@ #include "py/objtype.h" #include "py/runtime.h" +#include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" #if MICROPY_DEBUG_VERBOSE // print debugging info @@ -851,8 +852,13 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value mp_obj_class_lookup(&lookup, self->base.type); meth_args = 3; } - if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr(self->subobj[0], index, value, instance); + if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists + mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]); + // return mp_obj_subscr(self->subobj[0], index, value, instance); + mp_obj_t ret = subobj_type->subscr(self_in, index, value, instance); + // May have called port specific C code. Make sure it didn't mess up the heap. + assert_heap_ok(); + return ret; } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw From dc8dd6df20f4904917169f4ec1172c8f3827e822 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 14:29:15 -0500 Subject: [PATCH 198/531] Revert subscr signature change --- extmod/machine_mem.c | 2 +- extmod/modbtree.c | 2 +- extmod/moductypes.c | 2 +- extmod/modurandom.c | 2 +- extmod/vfs.c | 2 +- ports/unix/modjni.c | 4 ++-- py/obj.c | 6 +++--- py/obj.h | 4 ++-- py/objarray.c | 3 +-- py/objdict.c | 2 +- py/objlist.c | 2 +- py/objrange.c | 2 +- py/objreversed.c | 2 +- py/objstr.c | 2 +- py/objstrunicode.c | 2 +- py/objtuple.c | 2 +- py/objtuple.h | 2 +- py/objtype.c | 4 ++-- py/opmethods.c | 6 +++--- py/vm.c | 4 ++-- shared-bindings/_pixelbuf/PixelBuf.c | 6 +++--- shared-bindings/displayio/Bitmap.c | 2 +- shared-bindings/displayio/Group.c | 2 +- shared-bindings/displayio/Palette.c | 2 +- shared-bindings/displayio/TileGrid.c | 2 +- shared-bindings/nvm/ByteArray.c | 2 +- shared-bindings/pulseio/PulseIn.c | 2 +- shared-bindings/random/__init__.c | 2 +- shared-module/os/__init__.c | 2 +- 29 files changed, 39 insertions(+), 40 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index 826c59d0f0..75496c6b5f 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -61,7 +61,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 939ab813e4..ad845163d6 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -247,7 +247,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 145b348874..bf5f1cef73 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -519,7 +519,7 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value) { mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); if (value == MP_OBJ_NULL) { diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 101c80cf8a..1512a3fd4a 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -150,7 +150,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len > 0) { - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL, seq); + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); } else { nlr_raise(mp_obj_new_exception(&mp_type_IndexError)); } diff --git a/extmod/vfs.c b/extmod/vfs.c index 4d344095a6..2bb4057e7e 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -373,7 +373,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { mp_obj_t dir_list = mp_obj_new_list(0, NULL); mp_obj_t next; while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, next)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); } return dir_list; } diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 8f0eac5a9d..e18a26f3c6 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -242,7 +242,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); char class_name[64]; @@ -311,7 +311,7 @@ STATIC mp_obj_t jobject_unary_op(mp_unary_op_t op, mp_obj_t self_in) { // TODO: subscr_load_adaptor & subscr_getiter convenience functions // should be moved to common location for reuse. STATIC mp_obj_t subscr_load_adaptor(mp_obj_t self_in, mp_obj_t index_in) { - return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL, self_in); + return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL); } MP_DEFINE_CONST_FUN_OBJ_2(subscr_load_adaptor_obj, subscr_load_adaptor); diff --git a/py/obj.c b/py/obj.c index 47aa1aebfc..09e71be4d6 100644 --- a/py/obj.c +++ b/py/obj.c @@ -487,11 +487,11 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } } -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(base); if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(base, index, value, instance); + mp_obj_t ret = type->subscr(base, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); if (ret != MP_OBJ_NULL) { @@ -546,7 +546,7 @@ STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) { mp_obj_type_t *type = mp_obj_get_type(self->obj); mp_obj_t current_length = type->unary_op(MP_UNARY_OP_LEN, self->obj); if (self->cur < MP_OBJ_SMALL_INT_VALUE(current_length)) { - mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL, self->obj); + mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL); self->cur += 1; return o_out; } else { diff --git a/py/obj.h b/py/obj.h index ff97b34d83..cf4216d02f 100644 --- a/py/obj.h +++ b/py/obj.h @@ -444,7 +444,7 @@ typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, cons typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t); typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); -typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance); +typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); // Buffer protocol @@ -707,7 +707,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in); // cell diff --git a/py/objarray.c b/py/objarray.c index 6fffa84125..9114a63c5a 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -396,8 +396,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif -#pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // TODO implement diff --git a/py/objdict.c b/py/objdict.c index 2c07331e7c..5bbe939b1d 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -175,7 +175,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete mp_obj_dict_delete(self_in, index); diff --git a/py/objlist.c b/py/objlist.c index 0c0d60aa83..64381bc706 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -159,7 +159,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { // delete diff --git a/py/objrange.c b/py/objrange.c index 328416303d..6f14bcc9f9 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -159,7 +159,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs #endif #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objreversed.c b/py/objreversed.c index 0b21e69380..4937d08189 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -66,7 +66,7 @@ STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) { // pre-decrement and index sequence self->cur_index -= 1; - return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL, self->seq); + return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL); } const mp_obj_type_t mp_type_reversed = { diff --git a/py/objstr.c b/py/objstr.c index fd802fe852..567e734442 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -440,7 +440,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s // This is used for both bytes and 8-bit strings. This is not used for unicode strings. #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); if (value == MP_OBJ_SENTINEL) { diff --git a/py/objstrunicode.c b/py/objstrunicode.c index dc8c0743d3..2540a1d7b6 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -198,7 +198,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objtuple.c b/py/objtuple.c index b6640def51..7a4c09ab70 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -178,7 +178,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objtuple.h b/py/objtuple.h index 4df3aeded9..7f20ab7b6f 100644 --- a/py/objtuple.h +++ b/py/objtuple.h @@ -45,7 +45,7 @@ extern const mp_obj_type_t mp_type_tuple; void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in); mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs); -mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance); +mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value); mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf); extern const mp_obj_type_t mp_type_attrtuple; diff --git a/py/objtype.c b/py/objtype.c index c7dc2ae78f..a5e733208c 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -826,7 +826,7 @@ STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t member[2] = {MP_OBJ_NULL}; struct class_lookup_data lookup = { @@ -855,7 +855,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]); // return mp_obj_subscr(self->subobj[0], index, value, instance); - mp_obj_t ret = subobj_type->subscr(self_in, index, value, instance); + mp_obj_t ret = subobj_type->subscr(self_in, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); return ret; diff --git a/py/opmethods.c b/py/opmethods.c index d906ddb6a3..247fa5bbc8 100644 --- a/py/opmethods.c +++ b/py/opmethods.c @@ -29,19 +29,19 @@ STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_SENTINEL, self_in); + return type->subscr(self_in, key_in, MP_OBJ_SENTINEL); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem); STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, value_in, self_in); + return type->subscr(self_in, key_in, value_in); } MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem); STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_NULL, self_in); + return type->subscr(self_in, key_in, MP_OBJ_NULL); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); diff --git a/py/vm.c b/py/vm.c index 2fe8d32370..353fc88100 100644 --- a/py/vm.c +++ b/py/vm.c @@ -386,7 +386,7 @@ dispatch_loop: ENTRY(MP_BC_LOAD_SUBSCR): { MARK_EXC_IP_SELECTIVE(); mp_obj_t index = POP(); - SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL, TOP())); + SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL)); DISPATCH(); } @@ -464,7 +464,7 @@ dispatch_loop: ENTRY(MP_BC_STORE_SUBSCR): MARK_EXC_IP_SELECTIVE(); - mp_obj_subscr(sp[-1], sp[0], sp[-2], sp[-1]); + mp_obj_subscr(sp[-1], sp[0], sp[-2]); sp -= 3; DISPATCH(); diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index feda2c573a..a3579c92c0 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -368,7 +368,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_f //| //| Sets the pixel value at the given index. //| -STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // slice deletion @@ -431,7 +431,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(instance); + call_show(self_in); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -451,7 +451,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(instance); + call_show(self_in); return mp_const_none; } } diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 7c77d05eda..ca9484a408 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -134,7 +134,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| bitmap[0,1] = 3 //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { +STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 40f2704c05..f5e3c22634 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -311,7 +311,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| del group[0] //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { displayio_group_t *self = native_group(self_in); if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) { diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 2fa65867aa..903338abb2 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -96,7 +96,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item return MP_OBJ_NULL; // op not supported diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 5acf8496f8..288eb4b236 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -349,7 +349,7 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = { //| //| grid[0,0] = 10 //| -STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { +STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { displayio_tilegrid_t *self = native_tilegrid(self_in); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 5ac46b260c..31bedeacc0 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -70,7 +70,7 @@ STATIC const mp_rom_map_elem_t nvm_bytearray_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict_table); -STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // slice deletion diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 5947329a54..8b69109f04 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -272,7 +272,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| pulses = pulseio.PulseIn(pin) //| print(pulses[0]) //| -STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index fdef914438..83698eac57 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -145,7 +145,7 @@ STATIC mp_obj_t random_choice(mp_obj_t seq) { if (len == 0) { mp_raise_IndexError(translate("empty sequence")); } - return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL, seq); + return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index ad76251c81..8060eec4f3 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -127,7 +127,7 @@ mp_obj_t common_hal_os_listdir(const char* path) { mp_obj_t next; while ((next = mp_iternext(iter_obj)) != MP_OBJ_STOP_ITERATION) { // next[0] is the filename. - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, dir_list)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); RUN_BACKGROUND_TASKS; } return dir_list; From 7f7105d36d5775e6b7842a24f06604a229b2aae3 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 13 Dec 2019 14:52:04 -0800 Subject: [PATCH 199/531] Fix tuple test --- py/objtuple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/objtuple.c b/py/objtuple.c index 7a4c09ab70..cc69f5469c 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -181,7 +181,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_tuple_t *self = mp_instance_cast_to_native_base(self_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; From d8e66a5f32749f29f5274432c616b2bd001dc7b3 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 13 Dec 2019 16:00:04 -0800 Subject: [PATCH 200/531] try 2. make namedtuple types handle subclasses --- py/objnamedtuple.c | 12 +++++++++++- py/objnamedtuple.h | 1 + py/objtuple.c | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index a044fe3ff8..a0a64f9b25 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "py/objstr.h" #include "py/objnamedtuple.h" +#include "py/objtype.h" #include "supervisor/shared/translate.h" @@ -70,6 +71,15 @@ void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t ki mp_obj_attrtuple_print_helper(print, fields, &o->tuple); } +mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + // Check for subclasses of namedtuple and unpack if needed. + if (type->parent != &mp_type_tuple) { + self_in = ((mp_obj_instance_t*) self_in)->subobj[0]; + } + return mp_obj_tuple_subscr(self_in, index, value); +} + void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { if (dest[0] == MP_OBJ_NULL) { // load attribute @@ -167,7 +177,7 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t o->base.unary_op = mp_obj_tuple_unary_op; o->base.binary_op = mp_obj_tuple_binary_op; o->base.attr = namedtuple_attr; - o->base.subscr = mp_obj_tuple_subscr; + o->base.subscr = namedtuple_subscr; o->base.getiter = mp_obj_tuple_getiter; o->base.parent = &mp_type_tuple; return MP_OBJ_FROM_PTR(o); diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h index 0ea0d28622..5a7512e3a6 100644 --- a/py/objnamedtuple.h +++ b/py/objnamedtuple.h @@ -49,6 +49,7 @@ typedef struct _mp_obj_namedtuple_t { void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name); +mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields); mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); diff --git a/py/objtuple.c b/py/objtuple.c index cc69f5469c..b7f50d3b2c 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -179,9 +179,10 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { #pragma GCC diagnostic ignored "-Wunused-parameter" mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == MP_OBJ_SENTINEL) { // load - mp_obj_tuple_t *self = mp_instance_cast_to_native_base(self_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; From a854a76819e4b871f9d0c4e059ca5c03f05dca76 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 13 Dec 2019 14:05:56 -0600 Subject: [PATCH 201/531] audiocore: The arguments to reset_buffer went missing In conversion I missed these arguments were being passed, but noticed it when an implausible value for audio_channel was sent to mp3's reset_buffer method. It's not clear whether there was any negative impact to this, but it should be fixed! --- shared-module/audiocore/__init__.c | 2 +- shared-module/audiocore/__init__.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shared-module/audiocore/__init__.c b/shared-module/audiocore/__init__.c index 1553dbe961..ac9d41b60a 100644 --- a/shared-module/audiocore/__init__.c +++ b/shared-module/audiocore/__init__.c @@ -52,7 +52,7 @@ uint8_t audiosample_channel_count(mp_obj_t sample_obj) { void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel) { const audiosample_p_t *proto = mp_proto_get_or_throw(MP_QSTR_protocol_audiosample, sample_obj); - proto->reset_buffer(MP_OBJ_TO_PTR(sample_obj)); + proto->reset_buffer(MP_OBJ_TO_PTR(sample_obj), single_channel, audio_channel); } audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj, diff --git a/shared-module/audiocore/__init__.h b/shared-module/audiocore/__init__.h index 38c1f5aeb1..7a56454b8a 100644 --- a/shared-module/audiocore/__init__.h +++ b/shared-module/audiocore/__init__.h @@ -42,7 +42,8 @@ typedef enum { typedef uint32_t (*audiosample_sample_rate_fun)(mp_obj_t); typedef uint8_t (*audiosample_bits_per_sample_fun)(mp_obj_t); typedef uint8_t (*audiosample_channel_count_fun)(mp_obj_t); -typedef void (*audiosample_reset_buffer_fun)(mp_obj_t); +typedef void (*audiosample_reset_buffer_fun)(mp_obj_t, + bool single_channel, uint8_t audio_channel); typedef audioio_get_buffer_result_t (*audiosample_get_buffer_fun)(mp_obj_t, bool single_channel, uint8_t channel, uint8_t** buffer, uint32_t* buffer_length); From bf9b7e7ece6186b2fb7716323fba8ef24315cb47 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 13 Dec 2019 14:07:00 -0600 Subject: [PATCH 202/531] MP3: skip ID3V2 metadata This was one reason that the "bartlebeats" mp3s would not play. --- shared-module/audiomp3/MP3File.c | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index f4861da360..789d75e0f7 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -88,6 +88,39 @@ STATIC bool mp3file_update_inbuf(audiomp3_mp3file_obj_t* self) { #define BYTES_LEFT(self) (self->inbuf_length - self->inbuf_offset) #define CONSUME(self, n) (self->inbuf_offset += n) +// http://id3.org/d3v2.3.0 +// http://id3.org/id3v2.3.0 +STATIC void mp3file_skip_id3v2(audiomp3_mp3file_obj_t* self) { + mp3file_update_inbuf(self); + if (BYTES_LEFT(self) < 10) { + return; + } + uint8_t *data = READ_PTR(self); + if (!( + data[0] == 'I' && + data[1] == 'D' && + data[2] == '3' && + data[3] != 0xff && + data[4] != 0xff && + (data[5] & 0x1f) == 0 && + (data[6] & 0x80) == 0 && + (data[7] & 0x80) == 0 && + (data[8] & 0x80) == 0 && + (data[9] & 0x80) == 0)) { + return; + } + uint32_t size = (data[6] << 21) | (data[7] << 14) | (data[8] << 7) | (data[9]); + size += 10; // size excludes the "header" (but not the "extended header") + // First, deduct from size whatever is left in buffer + uint32_t to_consume = MIN(size, BYTES_LEFT(self)); + CONSUME(self, to_consume); + size -= to_consume; + + // Next, seek in the file after the header + f_lseek(&self->file->fp, f_tell(&self->file->fp) + size); + return; +} + /* If a sync word can be found, advance to it and return true. Otherwise, * return false. */ @@ -223,6 +256,7 @@ void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t* self, self->eof = 0; self->other_channel = -1; mp3file_update_inbuf(self); + mp3file_skip_id3v2(self); mp3file_find_sync_word(self); } @@ -253,6 +287,7 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* self->buffer_index = !self->buffer_index; int16_t *buffer = (int16_t *)(void *)self->buffers[self->buffer_index]; + mp3file_skip_id3v2(self); if (!mp3file_find_sync_word(self)) { return self->eof ? GET_BUFFER_DONE : GET_BUFFER_ERROR; } From 91a1706160aa653cb00c7910b0930df679bcdd21 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 13 Dec 2019 15:20:48 -0600 Subject: [PATCH 203/531] MP3: look harder for frame info Apparently sometimes, a proper "frame info" block is not found after a "sync word". Keep looking for one as needed, instead of giving up after one try. This was one reason that the "bartlebeats" mp3s would not play. --- shared-module/audiomp3/MP3File.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index 789d75e0f7..0aa4f24a66 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -139,7 +139,15 @@ STATIC bool mp3file_find_sync_word(audiomp3_mp3file_obj_t* self) { } STATIC bool mp3file_get_next_frame_info(audiomp3_mp3file_obj_t* self, MP3FrameInfo* fi) { - int err = MP3GetNextFrameInfo(self->decoder, fi, READ_PTR(self)); + int err; + do { + err = MP3GetNextFrameInfo(self->decoder, fi, READ_PTR(self)); + if (err == ERR_MP3_NONE) { + break; + } + CONSUME(self, 1); + mp3file_find_sync_word(self); + } while (!self->eof); return err == ERR_MP3_NONE; } From b26f8a781583c41b5f0452b8e22b4d093bf0c9e3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 14 Dec 2019 14:34:26 -0500 Subject: [PATCH 204/531] Add a BUILDING.md - #2370 --- BUILDING.md | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 BUILDING.md diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000000..6594ce4d08 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,83 @@ + +# Building CircuitPython + +Welcome to CircuitPython! + +This document is a quick-start guide only. + +Detailed guides on how to build CircuitPython can be found in the Adafruit Learn system at +https://learn.adafruit.com/building-circuitpython/. + +## Setup + +Please ensure you setup your build environment appropriately, as per the guide. You will need: + +* Linux: https://learn.adafruit.com/building-circuitpython/linux +* MacOS: https://learn.adafruit.com/building-circuitpython/macos +* Windows Subsystem for Linux (WSL): https://learn.adafruit.com/building-circuitpython/windows-subsystem-for-linux + +### Submodules + +This project has a bunch of git submodules. You will need to update them regularly. + + git submodule sync + git submodule update --init --recursive + +### mpy-cross + +As part of the build process, mpy-cross is needed to compile .py files into .mpy files. +To compile (or recompile) mpy-cross: + + make -C mpy-cross + +# Building + +There a number of ports of CircuitPython! To build for your board, change to the appropriate ports directory and build. + +Examples: + + cd ports/atmel-samd + make BOARD=circuitplayground_express + + cd ports/nrf + make BOARD=circuitplayground_bluefruit + +If you aren't sure what boards exist, have a peek in the boards subdirectory of your port. + +Useful make arguments or targets: + + make BOARD=circuitplayground_express clean + +# Testing + +If you are working on changes to the core language, you might find it useful to run the test suite. +The test suite in the top level `tests` directory. It needs the unix port to run. + + cd ports/unix + make axtls + make micropython + +Then you can run the test suite: + + cd ../../tests + ./run-tests + +A successful run will say something like + + 676 tests performed (19129 individual testcases) + 676 tests passed + 30 tests skipped: buffered_writer builtin_help builtin_range_binop class_delattr_setattr cmd_parsetree extra_coverage framebuf1 framebuf16 framebuf2 framebuf4 framebuf8 framebuf_subclass mpy_invalid namedtuple_asdict non_compliant resource_stream schedule sys_getsizeof urandom_extra ure_groups ure_span ure_sub ure_sub_unmatched vfs_basic vfs_fat_fileio1 vfs_fat_fileio2 vfs_fat_more vfs_fat_oldproto vfs_fat_ramdisk vfs_userfs + +# Debugging + +The easiest way to debug CircuitPython on hardware is with a JLink device, JLinkGDBServer, and `gcc-arm-embedded`. +Instructions can be found at https://learn.adafruit.com/debugging-the-samd21-with-gdb + +If using JLink, you'll need both the `JLinkGDBServer` and `arm-non-eabi-gdb-py` running. + +Example: + + JLinkGDBServer -if SWD -device ATSAMD51J19 + arm-none-eabi-gdb-py build-metro_m4_express/firmware.elf -iex "target extended-remote :2331" + + \ No newline at end of file From cca42e94d719c9005d09df543596324fca2af2ae Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 14 Dec 2019 15:00:42 -0500 Subject: [PATCH 205/531] Add to BUILDING to table of contents. --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index a85772fdc9..6dadddfc1a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -43,6 +43,7 @@ Full Table of Contents ../README ../CONTRIBUTING + ../BUILDING ../CODE_OF_CONDUCT ../license.rst From 6f6d6c01abb790d3f6b279f935405835ca8aa95c Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Mon, 16 Dec 2019 12:18:16 +0500 Subject: [PATCH 206/531] Update mpconfigboard.mk --- ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk index 47cd07df21..941d88b459 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk @@ -1,6 +1,6 @@ LD_FILE = boards/samd21x18-bootloader.ld -USB_VID = 0x239A -USB_PID = 0x8014 +USB_VID = 0x04D8 +USB_PID = 0xEC72 USB_PRODUCT = "XinaBox CC03" USB_MANUFACTURER = "XinaBox" @@ -15,16 +15,12 @@ SUPEROPT_GC = 0 # Make room for frozen libs. CIRCUITPY_FREQUENCYIO = 0 -#CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_ANALOGIO=0 CIRCUITPY_NEOPIXEL_WRITE=0 CIRCUITPY_PULSEIO=0 CIRCUITPY_ROTARYIO=0 CIRCUITPY_TOUCHIO_USE_NATIVE=0 CIRCUITPY_TOUCHIO=0 -#CIRCUITPY_USB_MIDI=0 -#CIRCUITPY_RTC=0 -#CIRCUITPY_USB_HID=0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice From 87dc9bee8b33c40aa2e342ee42ced71ed757b142 Mon Sep 17 00:00:00 2001 From: KalbeAbbas Date: Mon, 16 Dec 2019 12:25:51 +0500 Subject: [PATCH 207/531] Update mpconfigboard.mk --- ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk index f4b7a7bfcb..5c418d312c 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk @@ -1,6 +1,6 @@ LD_FILE = boards/samd21x18-bootloader.ld -USB_VID = 0x239A -USB_PID = 0x8014 +USB_VID = 0x04D8 +USB_PID = 0xEC75 USB_PRODUCT = "XinaBox CS11" USB_MANUFACTURER = "XinaBox" @@ -15,7 +15,6 @@ SUPEROPT_GC = 0 # Make room for frozen libs. CIRCUITPY_FREQUENCYIO = 0 -#CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_ANALOGIO=0 CIRCUITPY_NEOPIXEL_WRITE=0 CIRCUITPY_PULSEIO=0 @@ -23,9 +22,8 @@ CIRCUITPY_ROTARYIO=0 CIRCUITPY_TOUCHIO_USE_NATIVE=0 CIRCUITPY_TOUCHIO=0 CIRCUITPY_USB_MIDI=0 -#CIRCUITPY_USB_HID=0 CIRCUITPY_RTC=0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD \ No newline at end of file +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD From 2abccc1745862bf3a5dc13f33a5030e1a877e3a6 Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Mon, 16 Dec 2019 08:58:56 -0500 Subject: [PATCH 208/531] update vid and pid for teknikio_bluebird --- .gitignore | 2 ++ ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3e5bd28300..435ed73a78 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,8 @@ TAGS *~ *.DS_Store +**/*.DS_Store +*.icloud # POEdit mo files #################### diff --git a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk index 3f97b08218..e178a82051 100644 --- a/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk +++ b/ports/nrf/boards/teknikio_bluebird/mpconfigboard.mk @@ -1,7 +1,7 @@ USB_VID = 0x239A -USB_PID = 0x802A -USB_PRODUCT = "PCA10059" -USB_MANUFACTURER = "Nordic Semiconductor" +USB_PID = 0x8070 +USB_PRODUCT = "Bluebird" +USB_MANUFACTURER = "Teknikio" MCU_CHIP = nrf52840 From ef2a8906ddd1b21c37d31fe7098fe6b7d5b5940d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 16 Dec 2019 15:05:09 -0500 Subject: [PATCH 209/531] move call to show outside loop --- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index feda2c573a..1ed6f7baf8 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -352,9 +352,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); - if (self->auto_write) - call_show(self_in); } + if (self->auto_write) + call_show(self_in); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); From a63da7a6c0e0537cbefaafb724d722f9587b82a2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 16 Dec 2019 15:23:41 -0600 Subject: [PATCH 210/531] displayio: make 'rotation' property settable --- shared-bindings/displayio/Display.c | 9 ++++++++- shared-bindings/displayio/Display.h | 1 + shared-module/displayio/Display.c | 17 +++++++++++++++++ shared-module/displayio/display_core.c | 9 +++++++++ shared-module/displayio/display_core.h | 2 ++ supervisor/shared/display.c | 1 + 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 5ce7b3581b..5759e8ad22 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -394,11 +394,18 @@ STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) { return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_rotation(self)); } MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_rotation_obj, displayio_display_obj_get_rotation); +STATIC mp_obj_t displayio_display_obj_set_rotation(mp_obj_t self_in, mp_obj_t value) { + displayio_display_obj_t *self = native_display(self_in); + common_hal_displayio_display_set_rotation(self, mp_obj_get_int(value)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_rotation_obj, displayio_display_obj_set_rotation); + const mp_obj_property_t displayio_display_rotation_obj = { .base.type = &mp_type_property, .proxy = {(mp_obj_t)&displayio_display_get_rotation_obj, - (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&displayio_display_set_rotation_obj, (mp_obj_t)&mp_const_none_obj}, }; diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index ca2b2d4765..b82a68ebe9 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -58,6 +58,7 @@ void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t* self uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t* self); uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self); uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self); +void common_hal_displayio_display_set_rotation(displayio_display_obj_t* self, int rotation); bool common_hal_displayio_display_get_auto_brightness(displayio_display_obj_t* self); void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness); diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 11db0f8ff2..299c8ad359 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -308,10 +308,27 @@ STATIC void _refresh_display(displayio_display_obj_t* self) { displayio_display_core_finish_refresh(&self->core); } +void common_hal_displayio_display_set_rotation(displayio_display_obj_t* self, int rotation){ + bool transposed = (self->core.rotation == 90 || self->core.rotation == 270); + bool will_transposed = (rotation == 90 || rotation == 270); + if(transposed != will_transposed) { + int tmp = self->core.width; + self->core.width = self->core.height; + self->core.height = tmp; + } + displayio_display_core_set_rotation(&self->core, rotation); + supervisor_stop_terminal(); + supervisor_start_terminal(self->core.width, self->core.height); + if (self->core.current_group != NULL) { + displayio_group_update_transform(self->core.current_group, &self->core.transform); + } +} + uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self){ return self->core.rotation; } + bool common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame) { if (!self->auto_refresh && !self->first_manual_refresh) { uint64_t current_time = supervisor_ticks_ms64(); diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 658daa8d69..120b70f76a 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -86,6 +86,15 @@ void displayio_display_core_construct(displayio_display_core_t* self, self->height = height; self->ram_width = ram_width; self->ram_height = ram_height; + + displayio_display_core_set_rotation(self, rotation); +} + +void displayio_display_core_set_rotation( displayio_display_core_t* self, + int rotation) { + int height = self->height; + int width = self->width; + rotation = rotation % 360; self->rotation = rotation; self->transform.x = 0; diff --git a/shared-module/displayio/display_core.h b/shared-module/displayio/display_core.h index 3a69cd40a2..1c3d0f09c6 100644 --- a/shared-module/displayio/display_core.h +++ b/shared-module/displayio/display_core.h @@ -68,6 +68,8 @@ uint16_t displayio_display_core_get_height(displayio_display_core_t* self); void displayio_display_core_set_dither(displayio_display_core_t* self, bool dither); bool displayio_display_core_get_dither(displayio_display_core_t* self); +void displayio_display_core_set_rotation(displayio_display_core_t* self, int rotation); + bool displayio_display_core_bus_free(displayio_display_core_t *self); bool displayio_display_core_begin_transaction(displayio_display_core_t* self); void displayio_display_core_end_transaction(displayio_display_core_t* self); diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index c6fda0f168..855432d645 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -81,6 +81,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { grid->pixel_width = width_in_tiles * grid->tile_width; grid->pixel_height = height_in_tiles * grid->tile_height; grid->tiles = tiles; + grid->full_change = true; common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font); } From 03ea9ff66ee513714c3ba95320d414a9e6c1f088 Mon Sep 17 00:00:00 2001 From: JoeBakalor Date: Mon, 16 Dec 2019 16:31:44 -0500 Subject: [PATCH 211/531] reset atmel-samd submodule to correct commit --- ports/atmel-samd/peripherals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/peripherals b/ports/atmel-samd/peripherals index 2ba5b20ba7..4c0deecf88 160000 --- a/ports/atmel-samd/peripherals +++ b/ports/atmel-samd/peripherals @@ -1 +1 @@ -Subproject commit 2ba5b20ba725e1c91c77875fba3a5e22059cdb92 +Subproject commit 4c0deecf889da0074c1dbc9a5e2d24cb7c7a31c6 From 201f4648c40c13bdbf91f8cc078c1fbecc09256d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 16 Dec 2019 15:33:55 -0600 Subject: [PATCH 212/531] py.mk: Fix race condition building .mo files By having an order-only dependency on the directory itself, the directory is sure to be created before the rule to create a .mo file is. This fixes a low-freqency error on github actions such as > msgfmt: error while opening "build/genhdr/en_US.mo" for writing: No such file or directory --- py/py.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/py.mk b/py/py.mk index 0c68e9af1b..9031c009f6 100644 --- a/py/py.mk +++ b/py/py.mk @@ -317,7 +317,7 @@ SRC_QSTR += $(HEADER_BUILD)/moduledefs.h # overall config, so they need to be caught MPCONFIGPORT_MK = $(wildcard mpconfigport.mk) -$(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po +$(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po | $(HEADER_BUILD) $(Q)msgfmt -o $@ $^ $(HEADER_BUILD)/qstrdefs.preprocessed.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) From 81581b345c4cb4dbf33af3c3bbd48c6baf522283 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 16 Dec 2019 17:17:13 -0500 Subject: [PATCH 213/531] Increase CPX stack size slightly --- .../boards/circuitplayground_express/mpconfigboard.h | 3 +++ .../circuitplayground_express_crickit/mpconfigboard.h | 3 +++ .../mpconfigboard.h | 3 +++ ports/atmel-samd/mpconfigport.h | 11 ++++++++--- tools/build_memory_info.py | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h index 0ed5262ab5..6eb49b02c5 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h @@ -27,6 +27,9 @@ // Explanation of how a user got into safe mode. #define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" +// Increase stack size slightly due to CPX library import nesting +#define CIRCUITPY_DEFAULT_STACK_SIZE (4504) + #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index 2db5129291..e64997c0e4 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -27,6 +27,9 @@ // Explanation of how a user got into safe mode. #define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" +// Increase stack size slightly due to CPX library import nesting +#define CIRCUITPY_DEFAULT_STACK_SIZE (4504) + #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index a1d5b0a671..4486e8a6d3 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -27,6 +27,9 @@ // Explanation of how a user got into safe mode. #define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" +// Increase stack size slightly due to CPX library import nesting. +#define CIRCUITPY_DEFAULT_STACK_SIZE (4504) // divisible by 8 + #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 846e8db707..28a844ffc0 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -42,7 +42,6 @@ #define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" #define SPI_FLASH_MAX_BAUDRATE 8000000 -#define CIRCUITPY_DEFAULT_STACK_SIZE 4096 #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) #define MICROPY_PY_FUNCTION_ATTRS (0) @@ -74,8 +73,6 @@ #define CIRCUITPY_MCU_FAMILY samd51 #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" #define SPI_FLASH_MAX_BAUDRATE 24000000 -// 24kiB stack -#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) #define MICROPY_PY_FUNCTION_ATTRS (1) @@ -108,6 +105,10 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (256) #endif +#ifndef CIRCUITPY_DEFAULT_STACK_SIZE +#define CIRCUITPY_DEFAULT_STACK_SIZE 4096 +#endif + #endif // SAMD21 //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -118,6 +119,10 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (8192) #endif +#ifndef CIRCUITPY_DEFAULT_STACK_SIZE +#define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024) +#endif + // If CIRCUITPY is internal, use half of flash for it. #if INTERNAL_FLASH_FILESYSTEM #ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE diff --git a/tools/build_memory_info.py b/tools/build_memory_info.py index f61b843ced..93b4c1e82f 100644 --- a/tools/build_memory_info.py +++ b/tools/build_memory_info.py @@ -73,7 +73,7 @@ ram_region = regions["RAM"] free_flash = firmware_region - text - data free_ram = ram_region - data - bss print("{} bytes free in flash firmware space out of {} bytes ({}kB).".format(free_flash, firmware_region, firmware_region / 1024)) -print("{} bytes free in ram for heap out of {} bytes ({}kB).".format(free_ram, ram_region, ram_region / 1024)) +print("{} bytes free in ram for stack and heap out of {} bytes ({}kB).".format(free_ram, ram_region, ram_region / 1024)) print() # Check that we have free flash space. GCC doesn't fail when the text + data From a46adb6175d479870960a38b47f9bf27e0e5ccc3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 16 Dec 2019 20:15:53 -0500 Subject: [PATCH 214/531] remove . from end of url --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 6594ce4d08..794d5409aa 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -6,7 +6,7 @@ Welcome to CircuitPython! This document is a quick-start guide only. Detailed guides on how to build CircuitPython can be found in the Adafruit Learn system at -https://learn.adafruit.com/building-circuitpython/. +https://learn.adafruit.com/building-circuitpython/ ## Setup From ebc21144b8dc98dde7daf3f3832bdb33a5d8fc7d Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 17 Dec 2019 10:55:19 +0700 Subject: [PATCH 215/531] stm32 explicitily enable/disable vbus sense, fix warning --- ports/stm32f4/supervisor/usb.c | 37 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 6e9b233a47..23fff1a36b 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -36,6 +36,29 @@ #include "common-hal/microcontroller/Pin.h" +STATIC void init_usb_vbus_sense(void) { + +#ifdef BOARD_NO_VBUS + // Disable VBUS sensing + #ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; + #else + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; + #endif +#else + // Enable VBUS hardware sensing + #ifdef USB_OTG_GCCFG_VBDEN + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN; + #else + USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS; + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; // B Device sense + #endif +#endif +} + + void init_usb_hardware(void) { //TODO: if future chips overload this with options, move to peripherals management. @@ -82,20 +105,8 @@ void init_usb_hardware(void) { never_reset_pin_number(0, 8); #endif -#ifdef BOARD_NO_VBUS - disable_usb_vbus(); -#endif - /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); -} -STATIC void disable_usb_vbus(void) { -#ifdef USB_OTG_GCCFG_VBDEN - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; -#else - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN; - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN; -#endif + init_usb_vbus_sense(); } From 894cad2e177cf1af5258ce07a78acb386c34ef68 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 17 Dec 2019 21:39:52 +0700 Subject: [PATCH 216/531] upgrade nrfx API to v2 --- ports/nrf/Makefile | 2 +- ports/nrf/common-hal/analogio/AnalogIn.c | 51 +++++++++---------- ports/nrf/common-hal/busio/I2C.c | 12 +++-- ports/nrf/common-hal/busio/SPI.c | 3 +- ports/nrf/common-hal/busio/UART.c | 8 +-- .../common-hal/microcontroller/Processor.c | 39 +++++++------- ports/nrf/common-hal/os/__init__.c | 12 ++--- ports/nrf/common-hal/pulseio/PulseIn.c | 2 +- ports/nrf/common-hal/rtc/RTC.c | 4 +- ports/nrf/nrfx | 2 +- ports/nrf/nrfx_config.h | 5 +- ports/nrf/peripherals/nrf/nrf52840/power.c | 4 +- ports/nrf/peripherals/nrf/nvm.c | 6 +-- 13 files changed, 78 insertions(+), 72 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index e6070fc329..f38b9f6846 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -138,6 +138,7 @@ SRC_NRFX = $(addprefix nrfx/,\ drivers/src/nrfx_uarte.c \ drivers/src/nrfx_gpiote.c \ drivers/src/nrfx_rtc.c \ + drivers/src/nrfx_nvmc.c \ ) ifdef EXTERNAL_FLASH_DEVICES @@ -167,7 +168,6 @@ SRC_C += \ lib/utils/pyexec.c \ lib/utils/stdout_helpers.c \ lib/utils/sys_stdio_mphal.c \ - nrfx/hal/nrf_nvmc.c \ nrfx/mdk/system_$(MCU_SUB_VARIANT).c \ peripherals/nrf/cache.c \ peripherals/nrf/clocks.c \ diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c index 44ebe9b4df..3bc097019e 100644 --- a/ports/nrf/common-hal/analogio/AnalogIn.c +++ b/ports/nrf/common-hal/analogio/AnalogIn.c @@ -36,12 +36,12 @@ void analogin_init(void) { // Calibrate the ADC once, on startup. - nrf_saadc_enable(); - nrf_saadc_event_clear(NRF_SAADC_EVENT_CALIBRATEDONE); - nrf_saadc_task_trigger(NRF_SAADC_TASK_CALIBRATEOFFSET); - while (nrf_saadc_event_check(NRF_SAADC_EVENT_CALIBRATEDONE) == 0) { } - nrf_saadc_event_clear(NRF_SAADC_EVENT_CALIBRATEDONE); - nrf_saadc_disable(); + nrf_saadc_enable(NRF_SAADC); + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE); + nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_CALIBRATEOFFSET); + while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE) == 0) { } + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE); + nrf_saadc_disable(NRF_SAADC); } void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin) { @@ -81,34 +81,33 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { .reference = NRF_SAADC_REFERENCE_VDD4, .acq_time = NRF_SAADC_ACQTIME_3US, .mode = NRF_SAADC_MODE_SINGLE_ENDED, - .burst = NRF_SAADC_BURST_DISABLED, - .pin_p = self->pin->adc_channel, - .pin_n = self->pin->adc_channel, + .burst = NRF_SAADC_BURST_DISABLED }; - nrf_saadc_resolution_set(NRF_SAADC_RESOLUTION_14BIT); - nrf_saadc_oversample_set(NRF_SAADC_OVERSAMPLE_DISABLED); - nrf_saadc_enable(); + nrf_saadc_resolution_set(NRF_SAADC, NRF_SAADC_RESOLUTION_14BIT); + nrf_saadc_oversample_set(NRF_SAADC, NRF_SAADC_OVERSAMPLE_DISABLED); + nrf_saadc_enable(NRF_SAADC); - for (uint32_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; i++) - nrf_saadc_channel_input_set(i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED); + for (uint32_t i = 0; i < SAADC_CH_NUM; i++) + nrf_saadc_channel_input_set(NRF_SAADC, i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED); - nrf_saadc_channel_init(CHANNEL_NO, &config); - nrf_saadc_buffer_init(&value, 1); + nrf_saadc_channel_init(NRF_SAADC, CHANNEL_NO, &config); + nrf_saadc_channel_input_set(NRF_SAADC, CHANNEL_NO, self->pin->adc_channel, self->pin->adc_channel); + nrf_saadc_buffer_init(NRF_SAADC, &value, 1); - nrf_saadc_task_trigger(NRF_SAADC_TASK_START); - while (nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED) == 0); - nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED); + nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START); + while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STARTED) == 0); + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED); - nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE); - while (nrf_saadc_event_check(NRF_SAADC_EVENT_END) == 0); - nrf_saadc_event_clear(NRF_SAADC_EVENT_END); + nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE); + while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END) == 0); + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END); - nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP); - while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0); - nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED); + nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP); + while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STOPPED) == 0); + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED); - nrf_saadc_disable(); + nrf_saadc_disable(NRF_SAADC); if (value < 0) value = 0; diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index 8a2ebde3bd..7a079ff7f4 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -133,9 +133,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); } - nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG; - config.scl = scl->number; - config.sda = sda->number; + nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG(scl->number, sda->number); + // change freq. only if it's less than the default 400K if (frequency < 100000) { config.frequency = NRF_TWIM_FREQ_100K; @@ -248,8 +247,10 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const u // break into MAX_XFER_LEN transaction while ( len ) { const size_t xact_len = MIN(len, I2C_MAX_XFER_LEN); + nrfx_twim_xfer_desc_t xfer_desc = NRFX_TWIM_XFER_DESC_TX(addr, (uint8_t*) data, xact_len); + uint32_t const flags = (stopBit ? 0 : NRFX_TWIM_FLAG_TX_NO_STOP); - if ( NRFX_SUCCESS != (err = nrfx_twim_tx(&self->twim_peripheral->twim, addr, data, xact_len, !stopBit)) ) { + if ( NRFX_SUCCESS != (err = nrfx_twim_xfer(&self->twim_peripheral->twim, &xfer_desc, flags)) ) { break; } @@ -274,8 +275,9 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t // break into MAX_XFER_LEN transaction while ( len ) { const size_t xact_len = MIN(len, I2C_MAX_XFER_LEN); + nrfx_twim_xfer_desc_t xfer_desc = NRFX_TWIM_XFER_DESC_RX(addr, data, xact_len); - if ( NRFX_SUCCESS != (err = nrfx_twim_rx(&self->twim_peripheral->twim, addr, data, xact_len)) ) { + if ( NRFX_SUCCESS != (err = nrfx_twim_xfer(&self->twim_peripheral->twim, &xfer_desc, 0)) ) { break; } diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index 5f1aac1934..d2977909e1 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -135,7 +135,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * mp_raise_ValueError(translate("All SPI peripherals are in use")); } - nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG; + nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG(NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED, + NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED); config.frequency = NRF_SPIM_FREQ_8M; config.sck_pin = clock->number; diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 9cdc197e7c..0579db4142 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -163,10 +163,12 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, .pselcts = NRF_UARTE_PSEL_DISCONNECTED, .pselrts = NRF_UARTE_PSEL_DISCONNECTED, .p_context = self, - .hwfc = NRF_UARTE_HWFC_DISABLED, - .parity = (parity == PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED, .baudrate = get_nrf_baud(baudrate), - .interrupt_priority = 7 + .interrupt_priority = 7, + .hal_cfg = { + .hwfc = NRF_UARTE_HWFC_DISABLED, + .parity = (parity == PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED + } }; nrfx_uarte_uninit(self->uarte); diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index abfd5b8656..03d9c4d3f0 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -75,35 +75,34 @@ float common_hal_mcu_processor_get_voltage(void) { .reference = NRF_SAADC_REFERENCE_INTERNAL, .acq_time = NRF_SAADC_ACQTIME_10US, .mode = NRF_SAADC_MODE_SINGLE_ENDED, - .burst = NRF_SAADC_BURST_DISABLED, - .pin_p = NRF_SAADC_INPUT_VDD, - .pin_n = NRF_SAADC_INPUT_VDD, + .burst = NRF_SAADC_BURST_DISABLED }; - nrf_saadc_resolution_set(NRF_SAADC_RESOLUTION_14BIT); - nrf_saadc_oversample_set(NRF_SAADC_OVERSAMPLE_DISABLED); - nrf_saadc_enable(); + nrf_saadc_resolution_set(NRF_SAADC, NRF_SAADC_RESOLUTION_14BIT); + nrf_saadc_oversample_set(NRF_SAADC, NRF_SAADC_OVERSAMPLE_DISABLED); + nrf_saadc_enable(NRF_SAADC); - for (uint32_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; i++) { - nrf_saadc_channel_input_set(i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED); + for (uint32_t i = 0; i < SAADC_CH_NUM; i++) { + nrf_saadc_channel_input_set(NRF_SAADC, i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED); } - nrf_saadc_channel_init(0, &config); - nrf_saadc_buffer_init(&value, 1); + nrf_saadc_channel_init(NRF_SAADC, 0, &config); + nrf_saadc_channel_input_set(NRF_SAADC, 0, NRF_SAADC_INPUT_VDD, NRF_SAADC_INPUT_VDD); + nrf_saadc_buffer_init(NRF_SAADC, &value, 1); - nrf_saadc_task_trigger(NRF_SAADC_TASK_START); - while (nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED) == 0) { } - nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED); + nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START); + while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STARTED) == 0) { } + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED); - nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE); - while (nrf_saadc_event_check(NRF_SAADC_EVENT_END) == 0) { } - nrf_saadc_event_clear(NRF_SAADC_EVENT_END); + nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE); + while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END) == 0) { } + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END); - nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP); - while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0) { } - nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED); + nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP); + while (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STOPPED) == 0) { } + nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED); - nrf_saadc_disable(); + nrf_saadc_disable(NRF_SAADC); if (value < 0) { value = 0; diff --git a/ports/nrf/common-hal/os/__init__.c b/ports/nrf/common-hal/os/__init__.c index 7671cc2a51..e38226f94e 100644 --- a/ports/nrf/common-hal/os/__init__.c +++ b/ports/nrf/common-hal/os/__init__.c @@ -70,17 +70,17 @@ bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { return NRF_SUCCESS == sd_rand_application_vector_get(buffer, length); #endif - nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY); - nrf_rng_task_trigger(NRF_RNG_TASK_START); + nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); + nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_START); for (uint32_t i = 0; i < length; i++) { - while (nrf_rng_event_get(NRF_RNG_EVENT_VALRDY) == 0); - nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY); + while (nrf_rng_event_check(NRF_RNG, NRF_RNG_EVENT_VALRDY) == 0); + nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); - buffer[i] = nrf_rng_random_value_get(); + buffer[i] = nrf_rng_random_value_get(NRF_RNG); } - nrf_rng_task_trigger(NRF_RNG_TASK_STOP); + nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_STOP); return true; } diff --git a/ports/nrf/common-hal/pulseio/PulseIn.c b/ports/nrf/common-hal/pulseio/PulseIn.c index 3839668314..b47cc6273b 100644 --- a/ports/nrf/common-hal/pulseio/PulseIn.c +++ b/ports/nrf/common-hal/pulseio/PulseIn.c @@ -112,7 +112,7 @@ void pulsein_reset(void) { if ( nrfx_gpiote_is_init() ) { nrfx_gpiote_uninit(); } - nrfx_gpiote_init(); + nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY); memset(_objs, 0, sizeof(_objs)); } diff --git a/ports/nrf/common-hal/rtc/RTC.c b/ports/nrf/common-hal/rtc/RTC.c index 57138350c9..a8ea366887 100644 --- a/ports/nrf/common-hal/rtc/RTC.c +++ b/ports/nrf/common-hal/rtc/RTC.c @@ -59,8 +59,8 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { } void rtc_init(void) { - if (!nrf_clock_lf_is_running()) { - nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); + if (!nrf_clock_lf_is_running(NRF_CLOCK)) { + nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART); } nrfx_rtc_counter_clear(&rtc_instance); nrfx_rtc_init(&rtc_instance, &rtc_config, rtc_handler); diff --git a/ports/nrf/nrfx b/ports/nrf/nrfx index 3d268263be..8efb27e97a 160000 --- a/ports/nrf/nrfx +++ b/ports/nrf/nrfx @@ -1 +1 @@ -Subproject commit 3d268263be2390ab760f75a3da72689ef13031a4 +Subproject commit 8efb27e97abe8e2a1d2b63908f510c8dca304a5d diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index cafec6aa1d..82f6514dfa 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -3,7 +3,7 @@ // Power #define NRFX_POWER_ENABLED 1 -#define NRFX_POWER_CONFIG_IRQ_PRIORITY 7 +#define NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY 7 // NOTE: THIS WORKAROUND CAUSES BLE CODE TO CRASH. // It doesn't work with the SoftDevice. @@ -116,4 +116,7 @@ #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 #define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 7 +// NVM controller +#define NRFX_NVMC_ENABLED 1 + #endif // NRFX_CONFIG_H__ diff --git a/ports/nrf/peripherals/nrf/nrf52840/power.c b/ports/nrf/peripherals/nrf/nrf52840/power.c index 9f7a9fa17a..794872c5d9 100644 --- a/ports/nrf/peripherals/nrf/nrf52840/power.c +++ b/ports/nrf/peripherals/nrf/nrf52840/power.c @@ -25,7 +25,7 @@ */ #include "nrfx.h" -#include "nrf_nvmc.h" +#include "nrfx_nvmc.h" void nrf_peripherals_power_init(void) { // Set GPIO reference voltage to 3.3V if it isn't already. REGOUT0 will get reset to 0xfffffff @@ -33,7 +33,7 @@ void nrf_peripherals_power_init(void) { // This matters only when "high voltage mode" is enabled, which is true on the PCA10059, // and might be true on other boards. if (NRF_UICR->REGOUT0 == 0xffffffff) { - nrf_nvmc_write_word((uint32_t) &NRF_UICR->REGOUT0, UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos); + nrfx_nvmc_word_write((uint32_t) &NRF_UICR->REGOUT0, UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos); // Must reset to make enable change. NVIC_SystemReset(); } diff --git a/ports/nrf/peripherals/nrf/nvm.c b/ports/nrf/peripherals/nrf/nvm.c index 7118b9c870..1501ccfc98 100644 --- a/ports/nrf/peripherals/nrf/nvm.c +++ b/ports/nrf/peripherals/nrf/nvm.c @@ -30,7 +30,7 @@ #include #include -#include "nrf_nvmc.h" +#include "nrfx_nvmc.h" #define FLASH_PAGE_SIZE (4096) @@ -90,7 +90,7 @@ bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { } #endif - nrf_nvmc_page_erase(page_addr); - nrf_nvmc_write_bytes(page_addr, data, FLASH_PAGE_SIZE); + nrfx_nvmc_page_erase(page_addr); + nrfx_nvmc_bytes_write(page_addr, data, FLASH_PAGE_SIZE); return true; } From a7f8a0afd7239a51062ebff12d239b80de358cec Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 17 Dec 2019 09:48:55 -0500 Subject: [PATCH 217/531] Address code review feedback. --- BUILDING.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 794d5409aa..9513f71455 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -44,10 +44,6 @@ Examples: If you aren't sure what boards exist, have a peek in the boards subdirectory of your port. -Useful make arguments or targets: - - make BOARD=circuitplayground_express clean - # Testing If you are working on changes to the core language, you might find it useful to run the test suite. @@ -70,14 +66,14 @@ A successful run will say something like # Debugging -The easiest way to debug CircuitPython on hardware is with a JLink device, JLinkGDBServer, and `gcc-arm-embedded`. +The easiest way to debug CircuitPython on hardware is with a JLink device, JLinkGDBServer, and an appropriate GDB. Instructions can be found at https://learn.adafruit.com/debugging-the-samd21-with-gdb -If using JLink, you'll need both the `JLinkGDBServer` and `arm-non-eabi-gdb-py` running. +If using JLink, you'll need both the `JLinkGDBServer` and `arm-none-eabi-gdb` running. Example: JLinkGDBServer -if SWD -device ATSAMD51J19 - arm-none-eabi-gdb-py build-metro_m4_express/firmware.elf -iex "target extended-remote :2331" + arm-none-eabi-gdb build-metro_m4_express/firmware.elf -iex "target extended-remote :2331" \ No newline at end of file From 8137ac4c49257396e6ba513f68418cd72c8b0d8b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 17 Dec 2019 08:59:08 -0600 Subject: [PATCH 218/531] nRF: PWMAudioOut: handle non-looping rawsamples --- ports/nrf/common-hal/audiopwmio/PWMAudioOut.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index b4c626355f..d9226628fa 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -255,16 +255,18 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, self->pwm->LOOP = 1; audiosample_reset_buffer(self->sample, false, 0); activate_audiopwmout_obj(self); + self->stopping = false; + self->pwm->SHORTS = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK; fill_buffers(self, 0); self->pwm->SEQ[1].PTR = self->pwm->SEQ[0].PTR; self->pwm->SEQ[1].CNT = self->pwm->SEQ[0].CNT; self->pwm->EVENTS_SEQSTARTED[0] = 0; self->pwm->EVENTS_SEQSTARTED[1] = 0; + self->pwm->EVENTS_SEQEND[0] = 0; + self->pwm->EVENTS_SEQEND[1] = 0; self->pwm->EVENTS_STOPPED = 0; - self->pwm->SHORTS = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK; self->pwm->TASKS_SEQSTART[0] = 1; self->playing = true; - self->stopping = false; self->paused = false; } From 554373fdd92b1df198b8329be5663c23d4f73f99 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 17 Dec 2019 22:26:08 +0700 Subject: [PATCH 219/531] bump tinyusb lib submodule --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index e413c9efa3..7a05b177a4 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit e413c9efa303d70de019a91aa415384fe80ca78f +Subproject commit 7a05b177a43b368fea1d60ca344fe4ae9902a432 From 6a8efa6ef1b4264daa6e8f1a0623ee6d88a56b9d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 17 Dec 2019 10:01:33 -0600 Subject: [PATCH 220/531] preprocess_frozen_modules: exclude subdirs of examples, docs, tests .. this reclaims several kB on CPX, where we really need it. --- tools/preprocess_frozen_modules.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py index 2199e9d395..7ae20c4d61 100755 --- a/tools/preprocess_frozen_modules.py +++ b/tools/preprocess_frozen_modules.py @@ -35,6 +35,7 @@ def copy_and_process(in_dir, out_dir): # Skip library examples directory and subfolders. relative_path_parts = Path(root).relative_to(in_dir).parts if relative_path_parts and relative_path_parts[0] in ['examples', 'docs', 'tests']: + del subdirs[:] continue for file in files: From f136ef2b9137fa8586ff30e9fe704fccbbdcc198 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 17 Dec 2019 14:00:35 -0500 Subject: [PATCH 221/531] add most remaining pindefs --- ports/stm32f4/boards/meowbit_v121/pins.c | 61 +++++++++++++++++++++--- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 3a26b232aa..8a798dcb48 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -4,13 +4,60 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) }, { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) }, - // { MP_ROM_QSTR(MP_QSTR_LED_DISP_SCK), MP_ROM_PTR(&pin_PB13) }, - // { MP_ROM_QSTR(MP_QSTR_LED_DISP_MISO), MP_ROM_PTR(&pin_PB14) }, - // { MP_ROM_QSTR(MP_QSTR_LED_DISP_MOSI), MP_ROM_PTR(&pin_PB15) }, - // { MP_ROM_QSTR(MP_QSTR_LED_DISP_CS), MP_ROM_PTR(&pin_PB12) }, - // { MP_ROM_QSTR(MP_QSTR_LED_DISP_DC), MP_ROM_PTR(&pin_PA08) }, - // { MP_ROM_QSTR(MP_QSTR_LED_DISP_RST), MP_ROM_PTR(&pin_PB10) }, - // { MP_ROM_QSTR(MP_QSTR_LED_DISP_BL), MP_ROM_PTR(&pin_PB03) } + { MP_ROM_QSTR(MP_QSTR_DISP_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_DISP_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_DISP_MOSI), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_DISP_RST), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) }, //what is this, backlight? + + { MP_ROM_QSTR(MP_QSTR_BUZZ), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_BTNA), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_BTNB), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_RIGHT), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_DOWN), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_LEFT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_TEMP), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_UP), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_MENU), MP_ROM_PTR(&pin_PC15) }, + + { MP_ROM_QSTR(MP_QSTR_JACK_TX), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_JACK_PWREN), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_JACK_SND), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_ACC_INT), MP_ROM_PTR(&pin_PC14) }, + { MP_ROM_QSTR(MP_QSTR_ACC_SCL), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_ACC_SDA), MP_ROM_PTR(&pin_PB07) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + // { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PC06) }, //these are wrong on Meowbit diagram. + // { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA03) }, //they cannot be used together (UART2 vs 6) + { MP_ROM_QSTR(MP_QSTR_NSS), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PC12) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PC11) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PC10) }, + + { MP_ROM_QSTR(MP_QSTR_P20), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_P19), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_P16), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_P15), MP_ROM_PTR(&pin_PC12) }, + { MP_ROM_QSTR(MP_QSTR_P14), MP_ROM_PTR(&pin_PC11) }, + { MP_ROM_QSTR(MP_QSTR_P13), MP_ROM_PTR(&pin_PC10) }, + { MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_P12), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_P11), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_P10), MP_ROM_PTR(&pin_PC00) }, + { MP_ROM_QSTR(MP_QSTR_P9), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_P8), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PC01) }, + { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From c7a2228b1baac4d35efa465a0ea815b0f5d51012 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 17 Dec 2019 14:30:44 -0800 Subject: [PATCH 222/531] Switch to fetching GCC from AWS Fixes #2388 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01335ccfc4..e87190c727 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -174,7 +174,7 @@ jobs: run: | sudo apt-get install -y gettext pip install requests sh click setuptools awscli - wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 + wget https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 - name: Versions run: | From ba19cd9ecb12c4f1771b8b5e56f46d0bb208dcd6 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 17 Dec 2019 17:33:49 -0500 Subject: [PATCH 223/531] Internal filesystem displayIO test --- ports/stm32f4/boards/STM32F401_fs.ld | 107 ++++++++++++++++++ .../boards/meowbit_v121/mpconfigboard.h | 8 +- .../boards/meowbit_v121/mpconfigboard.mk | 13 ++- ports/stm32f4/supervisor/internal_flash.h | 5 + 4 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 ports/stm32f4/boards/STM32F401_fs.ld diff --git a/ports/stm32f4/boards/STM32F401_fs.ld b/ports/stm32f4/boards/STM32F401_fs.ld new file mode 100644 index 0000000000..fd30e16228 --- /dev/null +++ b/ports/stm32f4/boards/STM32F401_fs.ld @@ -0,0 +1,107 @@ +/* + GNU linker script for STM32F401 with bootloader (such as the Meowbit) +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ + FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 2K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +ENTRY(Reset_Handler) + +/* define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + + /* This first flash block is 16K annd 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. */ + + . = ALIGN(4); + } >FLASH_ISR + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + /* *(.glue_7) */ /* glue arm to thumb code */ + /* *(.glue_7t) */ /* glue thumb to arm code */ + + . = ALIGN(4); + _etext = .; /* define a global symbol at end of code */ + } >FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ + } >RAM AT> FLASH_TEXT + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + _sbss = .; /* define a global symbol at bss start; used by startup code */ + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ + } >RAM + + /* this is to define the start of the heap, and make sure we have a minimum size */ + .heap : + { + . = ALIGN(4); + . = . + _minimum_heap_size; + . = ALIGN(4); + } >RAM + + /* this just checks there is enough RAM for the stack */ + .stack : + { + . = ALIGN(4); + . = . + _minimum_stack_size; + . = ALIGN(4); + } >RAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index eb526d0a75..89cdee6d95 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -39,7 +39,7 @@ #define BOARD_NO_VBUS // On-board flash -#define SPI_FLASH_MOSI_PIN (&pin_PB15) -#define SPI_FLASH_MISO_PIN (&pin_PB14) -#define SPI_FLASH_SCK_PIN (&pin_PB13) -#define SPI_FLASH_CS_PIN (&pin_PB01) +// #define SPI_FLASH_MOSI_PIN (&pin_PB15) +// #define SPI_FLASH_MISO_PIN (&pin_PB14) +// #define SPI_FLASH_SCK_PIN (&pin_PB13) +// #define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 8b605975d5..1642120e80 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -4,16 +4,19 @@ USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" USB_DEVICES = "CDC,MSC" -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ -LONGINT_IMPL = MPZ +# SPI_FLASH_FILESYSTEM = 1 +# EXTERNAL_FLASH_DEVICE_COUNT = 1 +# EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ +# LONGINT_IMPL = MPZ + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401.ld +LD_FILE = boards/STM32F401_fs.ld TEXT0_ADDR = 0x08010000 TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/supervisor/internal_flash.h b/ports/stm32f4/supervisor/internal_flash.h index b6d26a07fe..8991fb8aa0 100644 --- a/ports/stm32f4/supervisor/internal_flash.h +++ b/ports/stm32f4/supervisor/internal_flash.h @@ -32,6 +32,11 @@ #include "py/mpconfig.h" +#ifdef STM32F401xE +#define STM32_FLASH_SIZE 0x80000 //512KiB +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB +#endif + #ifdef STM32F411xE #define STM32_FLASH_SIZE 0x80000 //512KiB #define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB From d267dac4ac14d1fa7dcf3fe80b67886cd33a75d3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 17 Dec 2019 18:59:54 -0500 Subject: [PATCH 224/531] Address review feedback. --- BUILDING.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 9513f71455..2e9fb4f30e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -43,6 +43,8 @@ Examples: make BOARD=circuitplayground_bluefruit If you aren't sure what boards exist, have a peek in the boards subdirectory of your port. +If you have a fast computer with many cores, consider adding `-j` to your build flags, such as `-j17` on +a 6-core 12-thread machine. # Testing @@ -75,5 +77,6 @@ Example: JLinkGDBServer -if SWD -device ATSAMD51J19 arm-none-eabi-gdb build-metro_m4_express/firmware.elf -iex "target extended-remote :2331" - - \ No newline at end of file + +If your port/build includes `arm-none-eabi-gdb-py`, consider using it instead, as it can be used for better register +debugging with https://github.com/bnahill/PyCortexMDebug From 7571f9790b233d508b426c8e2faa69514bea89d5 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 17 Dec 2019 19:17:46 -0500 Subject: [PATCH 225/531] remove --recursive --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 2e9fb4f30e..73499d65d5 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -21,7 +21,7 @@ Please ensure you setup your build environment appropriately, as per the guide. This project has a bunch of git submodules. You will need to update them regularly. git submodule sync - git submodule update --init --recursive + git submodule update --init ### mpy-cross From 561fdfb279c45f7a9ff69a2b2e71ac272cb6aaef Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 17 Dec 2019 19:01:03 -0800 Subject: [PATCH 226/531] Improve USB eject by resetting on replug --- supervisor/shared/usb/usb.c | 2 ++ supervisor/shared/usb/usb_msc_flash.c | 41 ++++++++++++++++++++++----- supervisor/usb.h | 4 +++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index c1d70c5b0f..a0178528d8 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -87,10 +87,12 @@ void usb_background(void) { // Invoked when device is mounted void tud_mount_cb(void) { + usb_msc_mount(); } // Invoked when device is unmounted void tud_umount_cb(void) { + usb_msc_umount(); } // Invoked when usb bus is suspended diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index 205cb7b500..0376cfc1df 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -41,6 +41,18 @@ static bool ejected[1]; +void usb_msc_mount(void) { + // Reset the ejection tracking every time we're plugged into USB. This allows for us to battery + // power the device, eject, unplug and plug it back in to get the drive. + for (uint8_t i = 0; i < sizeof(ejected); i++) { + ejected[i] = false; + } +} + +void usb_msc_umount(void) { + +} + // The root FS is always at the end of the list. static fs_user_mount_t* get_vfs(int lun) { // TODO(tannewt): Return the mount which matches the lun where 0 is the end @@ -198,19 +210,34 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) { // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage // - Start = 1 : active mode, if load_eject = 1 : load disk storage bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) { + if (lun > 1) { + return false; + } + fs_user_mount_t* current_mount = get_vfs(lun); + if (current_mount == NULL) { + return false; + } if (load_eject) { - if (lun > 1) { - return false; - } else { - fs_user_mount_t* current_mount = get_vfs(lun); - if (current_mount == NULL) { - return false; - } + if (!start) { + // Eject but first flush. if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) { return false; } else { ejected[lun] = true; } + } else { + // We can only load if it hasn't been ejected. + return !ejected[lun]; + } + } else { + if (!start) { + // Stop the unit but don't eject. + if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) { + return false; + } + } else { + // Start the unit, but only if not ejected. + return !ejected[lun]; } } diff --git a/supervisor/usb.h b/supervisor/usb.h index c87540d408..0cc361619d 100644 --- a/supervisor/usb.h +++ b/supervisor/usb.h @@ -41,4 +41,8 @@ void init_usb_hardware(void); bool usb_enabled(void); void usb_init(void); +// Propagate plug/unplug events to the MSC logic. +void usb_msc_mount(void); +void usb_msc_umount(void); + #endif // MICROPY_INCLUDED_SUPERVISOR_USB_H From dad2663337e3473a8405d2e70164c3bfc0380ca6 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 18 Dec 2019 15:39:11 +0700 Subject: [PATCH 227/531] update nrfx submodule to v2 --- ports/nrf/nrfx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/nrfx b/ports/nrf/nrfx index 8efb27e97a..3f55e49eb1 160000 --- a/ports/nrf/nrfx +++ b/ports/nrf/nrfx @@ -1 +1 @@ -Subproject commit 8efb27e97abe8e2a1d2b63908f510c8dca304a5d +Subproject commit 3f55e49eb11e6db0da1da09e189bb094222702c9 From 3a5de7effd5713ce562ad4a84d81a53fb36bc61f Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 18 Dec 2019 14:46:12 -0500 Subject: [PATCH 228/531] Remove merge overflow --- ....h~parent of 352bd95f5... remove blackpill | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill deleted file mode 100644 index 8a482ce7dc..0000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h~parent of 352bd95f5... remove blackpill +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "stm32f411ce-blackpill" -#define MICROPY_HW_MCU_NAME "STM32F411CE" - -#define FLASH_SIZE (0x80000) -#define FLASH_PAGE_SIZE (0x4000) - -#define BOARD_OSC_DIV 25 - -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) - -#define AUTORESET_DELAY_MS 500 From 5b70fa0a64c076f8c1b894893d02fad49ad6bf5b Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 18 Dec 2019 15:40:08 -0500 Subject: [PATCH 229/531] enable internal SPI intercepts. can brick USB --- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 8 ++++---- ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 14 +++++++------- ports/stm32f4/boards/meowbit_v121/pins.c | 2 ++ supervisor/spi_flash_api.h | 4 ++++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 89cdee6d95..eb526d0a75 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -39,7 +39,7 @@ #define BOARD_NO_VBUS // On-board flash -// #define SPI_FLASH_MOSI_PIN (&pin_PB15) -// #define SPI_FLASH_MISO_PIN (&pin_PB14) -// #define SPI_FLASH_SCK_PIN (&pin_PB13) -// #define SPI_FLASH_CS_PIN (&pin_PB01) +#define SPI_FLASH_MOSI_PIN (&pin_PB15) +#define SPI_FLASH_MISO_PIN (&pin_PB14) +#define SPI_FLASH_SCK_PIN (&pin_PB13) +#define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 1642120e80..20cad80a0c 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -4,19 +4,19 @@ USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" USB_DEVICES = "CDC,MSC" -# SPI_FLASH_FILESYSTEM = 1 -# EXTERNAL_FLASH_DEVICE_COUNT = 1 -# EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ -# LONGINT_IMPL = MPZ +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ +LONGINT_IMPL = MPZ -INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = NONE +# INTERNAL_FLASH_FILESYSTEM = 1 +# LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401_fs.ld +LD_FILE = boards/STM32F401.ld TEXT0_ADDR = 0x08010000 TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 8a798dcb48..2d5f2e8fae 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -1,4 +1,5 @@ #include "shared-bindings/board/__init__.h" +#include "supervisor/spi_flash_api.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) }, @@ -59,5 +60,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/supervisor/spi_flash_api.h b/supervisor/spi_flash_api.h index 28cccb1b1a..b477308bab 100644 --- a/supervisor/spi_flash_api.h +++ b/supervisor/spi_flash_api.h @@ -31,6 +31,10 @@ #include "supervisor/shared/external_flash/devices.h" +#include "shared-bindings/busio/SPI.h" + +extern busio_spi_obj_t spi; //Used to share SPI bus on some boards + // This API is implemented for both normal SPI peripherals and QSPI peripherals. bool spi_flash_command(uint8_t command); From 902e2422376a454ba9e088e86dc81bce8509623d Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 18 Dec 2019 17:17:06 -0500 Subject: [PATCH 230/531] Revert "enable internal SPI intercepts. can brick USB" This reverts commit 5b70fa0a64c076f8c1b894893d02fad49ad6bf5b. --- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 8 ++++---- ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 14 +++++++------- ports/stm32f4/boards/meowbit_v121/pins.c | 2 -- supervisor/spi_flash_api.h | 4 ---- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index eb526d0a75..89cdee6d95 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -39,7 +39,7 @@ #define BOARD_NO_VBUS // On-board flash -#define SPI_FLASH_MOSI_PIN (&pin_PB15) -#define SPI_FLASH_MISO_PIN (&pin_PB14) -#define SPI_FLASH_SCK_PIN (&pin_PB13) -#define SPI_FLASH_CS_PIN (&pin_PB01) +// #define SPI_FLASH_MOSI_PIN (&pin_PB15) +// #define SPI_FLASH_MISO_PIN (&pin_PB14) +// #define SPI_FLASH_SCK_PIN (&pin_PB13) +// #define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 20cad80a0c..1642120e80 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -4,19 +4,19 @@ USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" USB_DEVICES = "CDC,MSC" -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ -LONGINT_IMPL = MPZ +# SPI_FLASH_FILESYSTEM = 1 +# EXTERNAL_FLASH_DEVICE_COUNT = 1 +# EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ +# LONGINT_IMPL = MPZ -# INTERNAL_FLASH_FILESYSTEM = 1 -# LONGINT_IMPL = NONE +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401.ld +LD_FILE = boards/STM32F401_fs.ld TEXT0_ADDR = 0x08010000 TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 2d5f2e8fae..8a798dcb48 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -1,5 +1,4 @@ #include "shared-bindings/board/__init__.h" -#include "supervisor/spi_flash_api.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) }, @@ -60,6 +59,5 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) }, - { MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/supervisor/spi_flash_api.h b/supervisor/spi_flash_api.h index b477308bab..28cccb1b1a 100644 --- a/supervisor/spi_flash_api.h +++ b/supervisor/spi_flash_api.h @@ -31,10 +31,6 @@ #include "supervisor/shared/external_flash/devices.h" -#include "shared-bindings/busio/SPI.h" - -extern busio_spi_obj_t spi; //Used to share SPI bus on some boards - // This API is implemented for both normal SPI peripherals and QSPI peripherals. bool spi_flash_command(uint8_t command); From 5c42ae1e13a786052155e0c4746fb97af4dd019b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 08:13:00 -0600 Subject: [PATCH 231/531] mp3: update to upstream release 1.1.1 --- lib/mp3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mp3 b/lib/mp3 index 2a3cc7873b..c3c664bf4d 160000 --- a/lib/mp3 +++ b/lib/mp3 @@ -1 +1 @@ -Subproject commit 2a3cc7873b5c642d4bb60043dc14d2555e3377a5 +Subproject commit c3c664bf4db6a36d11808dfcbb5dbf7cff1715b8 From 16688180c6be77dc93a5b8603b0d0fb760955f46 Mon Sep 17 00:00:00 2001 From: ndgarage Date: Thu, 19 Dec 2019 07:17:43 -0700 Subject: [PATCH 232/531] add-ndbit6 --- .../atmel-samd/boards/ndbit6/mpconfigboard.h | 36 +++++++-------- .../atmel-samd/boards/ndbit6/mpconfigboard.mk | 8 ++-- ports/atmel-samd/boards/ndbit6/pins.c | 45 +++++++++---------- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/ports/atmel-samd/boards/ndbit6/mpconfigboard.h b/ports/atmel-samd/boards/ndbit6/mpconfigboard.h index 98c64def71..869f207a16 100644 --- a/ports/atmel-samd/boards/ndbit6/mpconfigboard.h +++ b/ports/atmel-samd/boards/ndbit6/mpconfigboard.h @@ -1,36 +1,32 @@ -#define MICROPY_HW_BOARD_NAME "NDBit6" +#define MICROPY_HW_BOARD_NAME "ndGarage[n°]Bit6:FeatherSnow" #define MICROPY_HW_MCU_NAME "samd21e18" -// LED status #define MICROPY_HW_LED_STATUS (&pin_PA23) -// These are pins not to reset. -//#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01) -#define MICROPY_PORT_A (0) +#define SPI_FLASH_MOSI_PIN &pin_PA16 +#define SPI_FLASH_MISO_PIN &pin_PA18 +#define SPI_FLASH_SCK_PIN &pin_PA17 +#define SPI_FLASH_CS_PIN &pin_PA15 + +#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25) #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. #define CIRCUITPY_INTERNAL_NVM_SIZE 256 -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 CIRCUITPY_INTERNAL_NVM_SIZE) -#define DEFAULT_I2C_BUS_SCL (&pin_PA17) -#define DEFAULT_I2C_BUS_SDA (&pin_PA16) +#define DEFAULT_I2C_BUS_SCL (&pin_PA09) +#define DEFAULT_I2C_BUS_SDA (&pin_PA08) -#define DEFAULT_SPI_BUS_SCK (&pin_PA17) -#define DEFAULT_SPI_BUS_MOSI (&pin_PA16) -#define DEFAULT_SPI_BUS_MISO (&pin_PA18) +#define DEFAULT_SPI_BUS_SCK (&pin_PA05) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA04) +#define DEFAULT_SPI_BUS_MISO (&pin_PA06) -#define DEFAULT_UART_BUS_RX (&pin_PA17) -#define DEFAULT_UART_BUS_TX (&pin_PA16) +#define DEFAULT_UART_BUS_RX (&pin_PA09) +#define DEFAULT_UART_BUS_TX (&pin_PA08) -// USB is always used internally so skip the pin objects for it. +// USB is always used. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 -// Not connected -//#define IGNORE_PIN_PA13 1 -//#define IGNORE_PIN_PA28 1 - diff --git a/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk b/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk index 484d61762d..42840ac2a7 100644 --- a/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk @@ -1,7 +1,7 @@ -LD_FILE = boards/samd21x18-bootloader-crystalless.ld +LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8066 -USB_PRODUCT = "ndbit6" +USB_PRODUCT = "ndBit6" USB_MANUFACTURER = "ndGarage" CHIP_VARIANT = SAMD21E18A @@ -12,6 +12,4 @@ LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 SUPEROPT_GC = 0 -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPAD = 0 + diff --git a/ports/atmel-samd/boards/ndbit6/pins.c b/ports/atmel-samd/boards/ndbit6/pins.c index 0bf6866561..6d1fc53b6d 100644 --- a/ports/atmel-samd/boards/ndbit6/pins.c +++ b/ports/atmel-samd/boards/ndbit6/pins.c @@ -1,40 +1,39 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA09) }, - - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA09) }, - - { MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_PA19) }, - { MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA28) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_PA27) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA09) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA08) }, - - { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); - From 51af8aadb7d9b1a22fbff9bbb978878fc959b5a8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 10:27:56 -0600 Subject: [PATCH 233/531] nrf: PWMAudioOut: 62500Hz limitation is not needed .. and it gets in the way of some example programs, due to the way circuitplayground library generates different frequency sine waves --- ports/nrf/common-hal/audiopwmio/PWMAudioOut.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index d9226628fa..cdb57bbe1d 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -225,10 +225,6 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, self->loop = loop; uint32_t sample_rate = audiosample_sample_rate(sample); - uint32_t max_sample_rate = 62500; - if (sample_rate > max_sample_rate) { - mp_raise_ValueError_varg(translate("Sample rate too high. It must be less than %d"), max_sample_rate); - } self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8; uint32_t max_buffer_length; From 4700f7cf23954cd21212fd5a4f7760826237e194 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 10:35:57 -0600 Subject: [PATCH 234/531] frozen: Update Adafruit_CircuitPython_CircuitPlayground submodule --- frozen/Adafruit_CircuitPython_CircuitPlayground | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index d87ea261c4..82ba9e40df 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit d87ea261c40ecbc6d893d72d337beefbea1cf932 +Subproject commit 82ba9e40dfff41fdc0541636afde4936c930d86c From 516d930e6c0aaf718fea258c2b6850fe8f43eaf8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 16:06:17 -0600 Subject: [PATCH 235/531] frozen: Update all submodules to latest tagged release --- frozen/Adafruit_CircuitPython_BusDevice | 2 +- frozen/Adafruit_CircuitPython_CircuitPlayground | 2 +- frozen/Adafruit_CircuitPython_Crickit | 2 +- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- frozen/Adafruit_CircuitPython_Motor | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- frozen/Adafruit_CircuitPython_SD | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 52d87bd7e5..2000ae3a7c 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 52d87bd7e571af66ecb57ee32b5af92531134150 +Subproject commit 2000ae3a7c5d60b850c9546a16425aee279e2a36 diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index d87ea261c4..82ba9e40df 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit d87ea261c40ecbc6d893d72d337beefbea1cf932 +Subproject commit 82ba9e40dfff41fdc0541636afde4936c930d86c diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index a6100fb5d8..5534662902 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit a6100fb5d867c7f4980f071119bfa7e0a76e1d47 +Subproject commit 5534662902a223ac8562e6f999d6359e4c17dab1 diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 409e90902a..01e89a8437 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 409e90902ac49720c4add985e8e1a1660bbe63a0 +Subproject commit 01e89a8437c78b62d4d655c745ded57e26dc747a diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index 89faee0eb0..a23b80569f 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit 89faee0eb08a6855e14f117c514fecf2dd90769d +Subproject commit a23b80569f23ef109667dd8c595d319e8a30d620 diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index ddc7484498..f69fc9b47f 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit ddc74844983b35b027bd45091c7b8bb3c8d7a2d1 +Subproject commit f69fc9b47fa25ba1414eb3d5c82f05013280c0d2 diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index c0bdd8b103..ff99d55115 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit c0bdd8b10383725ee9293f5d88fb8d47eb1272bd +Subproject commit ff99d55115f81899902c2c4a84fdfbea9ae83823 diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD index 5ad33e4ca2..dd0fe8530a 160000 --- a/frozen/Adafruit_CircuitPython_SD +++ b/frozen/Adafruit_CircuitPython_SD @@ -1 +1 @@ -Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c +Subproject commit dd0fe8530a2dcc64ac95bb3e116af2158dcd7cd2 From d31a387ace9488d161534a61f20a31d12cb01a4e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 16:11:29 -0600 Subject: [PATCH 236/531] circuitplayground_express_displayio: reduce inlining to make .ko translation fit --- .../boards/circuitplayground_express_displayio/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index b5a7c2424d..cf3d11d124 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -20,7 +20,7 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 -CFLAGS_INLINE_LIMIT = 55 +CFLAGS_INLINE_LIMIT = 35 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice From 5f0af7788026bdae10224dc6570ff79aba394fb7 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 08:13:00 -0600 Subject: [PATCH 237/531] mp3: update to upstream release 1.1.1 --- lib/mp3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mp3 b/lib/mp3 index 2a3cc7873b..c3c664bf4d 160000 --- a/lib/mp3 +++ b/lib/mp3 @@ -1 +1 @@ -Subproject commit 2a3cc7873b5c642d4bb60043dc14d2555e3377a5 +Subproject commit c3c664bf4db6a36d11808dfcbb5dbf7cff1715b8 From cc3ef2d5e647c9814a3a25c4df23e3764ec5fdb8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 16:06:17 -0600 Subject: [PATCH 238/531] frozen: Update all submodules to latest tagged release --- frozen/Adafruit_CircuitPython_BusDevice | 2 +- frozen/Adafruit_CircuitPython_Crickit | 2 +- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- frozen/Adafruit_CircuitPython_Motor | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- frozen/Adafruit_CircuitPython_SD | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 52d87bd7e5..2000ae3a7c 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 52d87bd7e571af66ecb57ee32b5af92531134150 +Subproject commit 2000ae3a7c5d60b850c9546a16425aee279e2a36 diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index a6100fb5d8..5534662902 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit a6100fb5d867c7f4980f071119bfa7e0a76e1d47 +Subproject commit 5534662902a223ac8562e6f999d6359e4c17dab1 diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 409e90902a..01e89a8437 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 409e90902ac49720c4add985e8e1a1660bbe63a0 +Subproject commit 01e89a8437c78b62d4d655c745ded57e26dc747a diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index 89faee0eb0..a23b80569f 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit 89faee0eb08a6855e14f117c514fecf2dd90769d +Subproject commit a23b80569f23ef109667dd8c595d319e8a30d620 diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index ddc7484498..f69fc9b47f 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit ddc74844983b35b027bd45091c7b8bb3c8d7a2d1 +Subproject commit f69fc9b47fa25ba1414eb3d5c82f05013280c0d2 diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index c0bdd8b103..ff99d55115 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit c0bdd8b10383725ee9293f5d88fb8d47eb1272bd +Subproject commit ff99d55115f81899902c2c4a84fdfbea9ae83823 diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD index 5ad33e4ca2..dd0fe8530a 160000 --- a/frozen/Adafruit_CircuitPython_SD +++ b/frozen/Adafruit_CircuitPython_SD @@ -1 +1 @@ -Subproject commit 5ad33e4ca219f0e216beab439cfa259cde32016c +Subproject commit dd0fe8530a2dcc64ac95bb3e116af2158dcd7cd2 From 8d2a3e94d72298a111dfae7f616d9abbab87cb1b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 16:11:29 -0600 Subject: [PATCH 239/531] circuitplayground_express_displayio: reduce inlining to make .ko translation fit --- .../boards/circuitplayground_express_displayio/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index b5a7c2424d..cf3d11d124 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -20,7 +20,7 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 -CFLAGS_INLINE_LIMIT = 55 +CFLAGS_INLINE_LIMIT = 35 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice From 00c226738d404a0664a73d0ca2dabfcad75798ac Mon Sep 17 00:00:00 2001 From: albang Date: Thu, 19 Dec 2019 23:16:51 +0100 Subject: [PATCH 240/531] Typo in doc --- shared-bindings/random/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index 83698eac57..de4c90910d 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -33,11 +33,11 @@ #include "shared-bindings/random/__init__.h" #include "supervisor/shared/translate.h" -//| :mod:`random` --- psuedo-random numbers and choices +//| :mod:`random` --- pseudo-random numbers and choices //| ======================================================== //| //| .. module:: random -//| :synopsis: psuedo-random numbers and choices +//| :synopsis: pseudo-random numbers and choices //| :platform: SAMD21, ESP8266 //| //| The `random` module is a strict subset of the CPython `cpython:random` From a93475707e18c110afdff23ac965e2e0c393fa40 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Dec 2019 16:26:01 -0600 Subject: [PATCH 241/531] gen_display_resources: speed it up It was intended that the `f.load_glyphs` line was fast and did most of the work. However, it actually didn't, because it's necessary to pass in a code point by number, not by string. Additionally, a little light layer violation is needed to make the check for missing characters fast. This used to be less important, as no fonts had missing characters. However, it would take an appreciable length of time on the Korean translation when failing to find hundreds of different code points. Testing performed: built build-circuitplayground_express_displayio/autogen_display_resources.c with ko translation before and after change. verified the file content was identical. Time went from about 7s on my machine to way under 1 second. --- tools/gen_display_resources.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/gen_display_resources.py b/tools/gen_display_resources.py index 781b5e69b2..c08daf4776 100644 --- a/tools/gen_display_resources.py +++ b/tools/gen_display_resources.py @@ -48,18 +48,19 @@ for c in sample_characters: all_characters += c if args.extra_characters: all_characters.extend(args.extra_characters) +all_characters = "".join(sorted(set(all_characters))) filtered_characters = all_characters # Try to pre-load all of the glyphs. Misses will still be slow later. -f.load_glyphs(set(all_characters)) +f.load_glyphs(set(ord(c) for c in all_characters)) # Get each glyph. -for c in all_characters: - g = f.get_glyph(ord(c)) - if not g: +for c in set(all_characters): + if ord(c) not in f._glyphs: print("Font missing character:", c, ord(c)) filtered_characters = filtered_characters.replace(c, "") continue + g = f.get_glyph(ord(c)) if g["shift"][1] != 0: raise RuntimeError("y shift") From b859e2b71013f603bb91539a62ada4e0eee15d48 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 20 Dec 2019 11:42:32 -0800 Subject: [PATCH 242/531] Remove `re` from CPX Displayio build to make space. --- .../boards/circuitplayground_express_displayio/mpconfigboard.h | 2 ++ .../boards/circuitplayground_express_displayio/mpconfigboard.mk | 2 +- py/circuitpy_mpconfig.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index 4486e8a6d3..c9a7ce0405 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -43,3 +43,5 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 + +#define MICROPY_PY_URE 0 diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index cf3d11d124..b5a7c2424d 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -20,7 +20,7 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 -CFLAGS_INLINE_LIMIT = 35 +CFLAGS_INLINE_LIMIT = 55 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3161938c48..932d4f855f 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -193,7 +193,9 @@ typedef long mp_off_t; #define MICROPY_PY_UERRNO (CIRCUITPY_FULL_BUILD) // Opposite setting is deliberate. #define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD) +#ifndef MICROPY_PY_URE #define MICROPY_PY_URE (CIRCUITPY_FULL_BUILD) +#endif #define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_URE_SUB (CIRCUITPY_FULL_BUILD) From f60b6481e090b2748dc84100502deda660466805 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 20 Dec 2019 12:14:27 -0800 Subject: [PATCH 243/531] Turn off `gamepad` on cpx crickit --- .../boards/circuitplayground_express_crickit/mpconfigboard.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index a6ed28aa71..04b4b7792e 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -13,9 +13,10 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" # Turn off features and optimizations for Crickit build to make room for additional frozen libs. LONGINT_IMPL = NONE CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_PIXELBUF = 0 CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_PIXELBUF = 0 SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 55 From 02154caf24a73ac706505661d487261e70342116 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 23 Dec 2019 09:36:46 -0600 Subject: [PATCH 244/531] MP3File: Add a settable ".file" property This enables jeplayer to allocate just one MP3File at startup, rather than have to make repeated large allocations while the application is running. The buffers have to be allocated their theoretical maximum, but that doesn't matter much as all the real-life MP3 files I checked needed that much allocation anyway. --- shared-bindings/audiomp3/MP3File.c | 32 ++++++++++++++++ shared-bindings/audiomp3/MP3File.h | 1 + shared-module/audiomp3/MP3File.c | 60 +++++++++++++++++------------- 3 files changed, 68 insertions(+), 25 deletions(-) diff --git a/shared-bindings/audiomp3/MP3File.c b/shared-bindings/audiomp3/MP3File.c index f518bae4bb..d867643f91 100644 --- a/shared-bindings/audiomp3/MP3File.c +++ b/shared-bindings/audiomp3/MP3File.c @@ -129,6 +129,37 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__); +//| .. attribute:: file +//| +//| File to play back. +//| +STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return self->file; +} +MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_file_obj, audiomp3_mp3file_obj_get_file); + +STATIC mp_obj_t audiomp3_mp3file_obj_set_file(mp_obj_t self_in, mp_obj_t file) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + if (!MP_OBJ_IS_TYPE(file, &mp_type_fileio)) { + mp_raise_TypeError(translate("file must be a file opened in byte mode")); + } + common_hal_audiomp3_mp3file_set_file(self, file); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_file_obj, audiomp3_mp3file_obj_set_file); + +const mp_obj_property_t audiomp3_mp3file_file_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiomp3_mp3file_get_file_obj, + (mp_obj_t)&audiomp3_mp3file_set_file_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + + //| .. attribute:: sample_rate //| //| 32 bit value that dictates how quickly samples are loaded into the DAC @@ -201,6 +232,7 @@ STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiomp3_mp3file___exit___obj) }, // Properties + { MP_ROM_QSTR(MP_QSTR_file), MP_ROM_PTR(&audiomp3_mp3file_file_obj) }, { MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&audiomp3_mp3file_sample_rate_obj) }, { MP_ROM_QSTR(MP_QSTR_bits_per_sample), MP_ROM_PTR(&audiomp3_mp3file_bits_per_sample_obj) }, { MP_ROM_QSTR(MP_QSTR_channel_count), MP_ROM_PTR(&audiomp3_mp3file_channel_count_obj) }, diff --git a/shared-bindings/audiomp3/MP3File.h b/shared-bindings/audiomp3/MP3File.h index adc13ea2c0..774d839ff5 100644 --- a/shared-bindings/audiomp3/MP3File.h +++ b/shared-bindings/audiomp3/MP3File.h @@ -38,6 +38,7 @@ extern const mp_obj_type_t audiomp3_mp3file_type; void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, pyb_file_obj_t* file, uint8_t *buffer, size_t buffer_size); +void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t* self, pyb_file_obj_t* file); void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self); bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t* self); uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* self); diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index 0aa4f24a66..5896a2561a 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -37,6 +37,8 @@ #include "supervisor/shared/translate.h" #include "lib/mp3/src/mp3common.h" +#define MAX_BUFFER_LEN (MAX_NSAMP * MAX_NGRAN * MAX_NCHAN * sizeof(int16_t)) + /** Fill the input buffer if it is less than half full. * * Returns true if the input buffer contains any useful data, @@ -165,7 +167,6 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, // than the two 4kB output buffers, except that the alignment allows to // never allocate that extra frame buffer. - self->file = file; self->inbuf_length = 2048; self->inbuf_offset = self->inbuf_length; self->inbuf = m_malloc(self->inbuf_length, false); @@ -181,6 +182,38 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, translate("Couldn't allocate decoder")); } + if ((intptr_t)buffer & 1) { + buffer += 1; buffer_size -= 1; + } + if (buffer_size >= 2 * MAX_BUFFER_LEN) { + self->buffers[0] = (int16_t*)(void*)buffer; + self->buffers[1] = (int16_t*)(void*)(buffer + MAX_BUFFER_LEN); + } else { + self->buffers[0] = m_malloc(MAX_BUFFER_LEN, false); + if (self->buffers[0] == NULL) { + common_hal_audiomp3_mp3file_deinit(self); + mp_raise_msg(&mp_type_MemoryError, + translate("Couldn't allocate first buffer")); + } + + self->buffers[1] = m_malloc(MAX_BUFFER_LEN, false); + if (self->buffers[1] == NULL) { + common_hal_audiomp3_mp3file_deinit(self); + mp_raise_msg(&mp_type_MemoryError, + translate("Couldn't allocate second buffer")); + } + } + + common_hal_audiomp3_mp3file_set_file(self, file); +} + +void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t* self, pyb_file_obj_t* file) { + self->file = file; + f_lseek(&self->file->fp, 0); + self->inbuf_offset = self->inbuf_length; + self->eof = 0; + self->other_channel = -1; + mp3file_update_inbuf(self); mp3file_find_sync_word(self); MP3FrameInfo fi; if(!mp3file_get_next_frame_info(self, &fi)) { @@ -191,30 +224,7 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, self->sample_rate = fi.samprate; self->channel_count = fi.nChans; self->frame_buffer_size = fi.outputSamps*sizeof(int16_t); - - if ((intptr_t)buffer & 1) { - buffer += 1; buffer_size -= 1; - } - if (buffer_size >= 2 * self->frame_buffer_size) { - self->len = buffer_size / 2 / self->frame_buffer_size * self->frame_buffer_size; - self->buffers[0] = (int16_t*)(void*)buffer; - self->buffers[1] = (int16_t*)(void*)buffer + self->len; - } else { - self->len = 2 * self->frame_buffer_size; - self->buffers[0] = m_malloc(self->len, false); - if (self->buffers[0] == NULL) { - common_hal_audiomp3_mp3file_deinit(self); - mp_raise_msg(&mp_type_MemoryError, - translate("Couldn't allocate first buffer")); - } - - self->buffers[1] = m_malloc(self->len, false); - if (self->buffers[1] == NULL) { - common_hal_audiomp3_mp3file_deinit(self); - mp_raise_msg(&mp_type_MemoryError, - translate("Couldn't allocate second buffer")); - } - } + self->len = 2 * self->frame_buffer_size; } void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self) { From 00628a7dddad07ead8b085e81de90c2dabe71fcc Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 23 Dec 2019 09:36:50 -0600 Subject: [PATCH 245/531] MP3File: whitespace --- shared-module/audiomp3/MP3File.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index 5896a2561a..549fbcdc09 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -145,7 +145,7 @@ STATIC bool mp3file_get_next_frame_info(audiomp3_mp3file_obj_t* self, MP3FrameIn do { err = MP3GetNextFrameInfo(self->decoder, fi, READ_PTR(self)); if (err == ERR_MP3_NONE) { - break; + break; } CONSUME(self, 1); mp3file_find_sync_word(self); From b06057395baea6987aabfdc4782476f222dc24e8 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Mon, 23 Dec 2019 15:48:11 +0100 Subject: [PATCH 246/531] Update PewPew M4 PewPew M4 now has the pew.py added to its frozen libraries. Some features needed to be disabled to make room for that. --- frozen/circuitpython-stage | 2 +- ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index c1d8e1d645..89850618dc 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit c1d8e1d645cbc83d857e12cf4ba67549b988a4e7 +Subproject commit 89850618dc7b30ee9e2dc11c843dfe4e13d90517 diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 990b26ff3e..1d1891e8e8 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -10,7 +10,6 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 -CIRCUITPY_PS2IO = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 @@ -23,7 +22,17 @@ CIRCUITPY_RTC = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_AUDIOPWMIO = 0 +CIRCUITPY_AUDIOMP3 = 0 +CIRCUITPY_BITBANG_APA102 = 0 +CIRCUITPY_BLEIO = 0 +CIRCUITPY_GAMEPADSHIFT = 0 +CIRCUITPY_NETWORK = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_SAMD = 0 +CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_AUDIOIO = 1 CIRCUITPY_DISPLAYIO = 1 CIRCUITPY_GAMEPAD = 1 @@ -33,6 +42,8 @@ CIRCUITPY_MATH = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pewpew_m4 CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf +USB_DEVICES = "CDC,MSC" + # Tweak inlining depending on language. ifeq ($(TRANSLATION), zh_Latn_pinyin) CFLAGS_INLINE_LIMIT = 45 From b49ecc52b9e41cbcc6943649217d8abea29b30a6 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 23 Dec 2019 14:55:26 -0500 Subject: [PATCH 247/531] text fixes --- ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h | 2 +- ports/stm32f4/supervisor/usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index b8e374f05b..05e2a384a1 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -33,7 +33,7 @@ #define FLASH_PAGE_SIZE (0x4000) #define BOARD_OSC_DIV 25 -#define BOARD_NO_VBUS +#define BOARD_NO_VBUS_SENSE // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 23fff1a36b..0d2d5cce9d 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -38,7 +38,7 @@ STATIC void init_usb_vbus_sense(void) { -#ifdef BOARD_NO_VBUS +#ifdef BOARD_NO_VBUS_SENSE // Disable VBUS sensing #ifdef USB_OTG_GCCFG_VBDEN USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; From 5aa3e3eabb90bb9845204b2287e311d5923d30a5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 24 Dec 2019 09:36:19 -0600 Subject: [PATCH 248/531] samd/peripherals: update --- ports/atmel-samd/peripherals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/peripherals b/ports/atmel-samd/peripherals index 4c0deecf88..28ad937da2 160000 --- a/ports/atmel-samd/peripherals +++ b/ports/atmel-samd/peripherals @@ -1 +1 @@ -Subproject commit 4c0deecf889da0074c1dbc9a5e2d24cb7c7a31c6 +Subproject commit 28ad937da258993359f0e91a4cb19db899a1e46a From 97bb46c0471b5cb9a0323f06183945d4c711207b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 24 Dec 2019 09:43:15 -0600 Subject: [PATCH 249/531] MP3File: tweak buffer handling After adding the ability to change files in an existing MP3File object, it became apparent that at the beginning of a track some part of an existing buffer was playing first. I noticed that in get_buffer, the just-populated buffer wasn't being returned, but the other one was. But still after fixing this, I heard wrong audio at the beginning of a track, so I took the heavy duty approach and zeroed the buffers out. That means there's a remaining bug to chase, which is merely hidden by the memset()s. --- shared-module/audiomp3/MP3File.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index 549fbcdc09..390ba25447 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -215,6 +215,13 @@ void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t* self, pyb_file self->other_channel = -1; mp3file_update_inbuf(self); mp3file_find_sync_word(self); + // It **SHOULD** not be necessary to do this; the buffer should be filled + // with fresh content before it is returned by get_buffer(). The fact that + // this is necessary to avoid a glitch at the start of playback of a second + // track using the same decoder object means there's still a bug in + // get_buffer() that I didn't understand. + memset(self->buffers[0], 0, MAX_BUFFER_LEN); + memset(self->buffers[1], 0, MAX_BUFFER_LEN); MP3FrameInfo fi; if(!mp3file_get_next_frame_info(self, &fi)) { mp_raise_msg(&mp_type_RuntimeError, @@ -290,7 +297,6 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* channel = 0; } - *bufptr = (uint8_t*)(self->buffers[self->buffer_index] + channel); *buffer_length = self->frame_buffer_size; if (channel == self->other_channel) { @@ -299,11 +305,12 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* return GET_BUFFER_MORE_DATA; } - self->other_channel = 1-channel; - self->other_buffer_index = self->buffer_index; self->buffer_index = !self->buffer_index; + self->other_channel = 1-channel; + self->other_buffer_index = self->buffer_index; int16_t *buffer = (int16_t *)(void *)self->buffers[self->buffer_index]; + *bufptr = (uint8_t*)buffer; mp3file_skip_id3v2(self); if (!mp3file_find_sync_word(self)) { From 3492ba33d517e860b275ba04898a25d1b92901c5 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 26 Dec 2019 00:18:04 +0700 Subject: [PATCH 250/531] improve usb dcd samd51 fix race condition with setup packet + scsi status response --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 7a05b177a4..b8cef16b58 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 7a05b177a43b368fea1d60ca344fe4ae9902a432 +Subproject commit b8cef16b58ec04649904c132152665d39862870a From d38a0007f199b3e497a18f4aa52f9d5927f790e1 Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Thu, 26 Dec 2019 08:46:27 -0500 Subject: [PATCH 251/531] define board.VOLTAGE_MONITOR for feather_stm32f405_express --- ports/stm32f4/boards/feather_stm32f405_express/pins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/pins.c b/ports/stm32f4/boards/feather_stm32f405_express/pins.c index 180fdd0937..ebc8fa337e 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/pins.c +++ b/ports/stm32f4/boards/feather_stm32f405_express/pins.c @@ -7,6 +7,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, From 62c4028cdebbf4c607ebbb48e99d1905692bef69 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 26 Dec 2019 23:04:16 +0700 Subject: [PATCH 252/531] sync with https://github.com/hathach/tinyusb/pull/246 should fix slow enumeration --- lib/tinyusb | 2 +- ports/atmel-samd/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tinyusb b/lib/tinyusb index b8cef16b58..76b2c2a001 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit b8cef16b58ec04649904c132152665d39862870a +Subproject commit 76b2c2a0017b49f8f1ef95734aa24a5b8e7d3f59 diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 83fd879aad..f4886f96ef 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -233,7 +233,7 @@ SRC_C = \ lib/oofatfs/ff.c \ lib/oofatfs/option/ccsbcs.c \ lib/timeutils/timeutils.c \ - lib/tinyusb/src/portable/microchip/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c \ + lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \ lib/utils/buffer_helper.c \ lib/utils/context_manager_helpers.c \ lib/utils/interrupt_char.c \ From 6205b55b192991916befc5aba45d1da08d5600ad Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Thu, 26 Dec 2019 22:13:52 +0100 Subject: [PATCH 253/531] Bump circuitpython-stage version to 1.0.8 --- frozen/circuitpython-stage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index 89850618dc..8d5cc38405 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit 89850618dc7b30ee9e2dc11c843dfe4e13d90517 +Subproject commit 8d5cc384058b1cb296aaeab86fb8405042d547ed From adff14c5bca956deedef72afd4696df6ec5d51c0 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 27 Dec 2019 09:55:16 +0700 Subject: [PATCH 254/531] more tinyusb update --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 76b2c2a001..dda4c9a94b 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 76b2c2a0017b49f8f1ef95734aa24a5b8e7d3f59 +Subproject commit dda4c9a94b509238faa7b5ab5b9464c1d2e63ff0 From cfd71d90234c5a2ec757f905b969637d0bcab226 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 27 Dec 2019 20:18:07 -0800 Subject: [PATCH 255/531] Fix nRF UART reset disable only turns off ENABLE but doesn't set the init tracking that nrfx uses. uninit hangs if ENABLE is off and is called because it waits forever for TX to stop. --- ports/nrf/common-hal/busio/UART.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 0579db4142..d79b65ff81 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -124,7 +124,7 @@ static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) void uart_reset(void) { for (size_t i = 0 ; i < MP_ARRAY_SIZE(nrfx_uartes); i++) { - nrf_uarte_disable(nrfx_uartes[i].p_reg); + nrfx_uarte_uninit(&nrfx_uartes[i]); } } @@ -171,7 +171,6 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, } }; - nrfx_uarte_uninit(self->uarte); _VERIFY_ERR(nrfx_uarte_init(self->uarte, &config, uart_callback_irq)); // Init buffer for rx From 01d49eb0a77dfe2fd673281ef3b6a58f0520630b Mon Sep 17 00:00:00 2001 From: David Glaude Date: Mon, 30 Dec 2019 16:54:16 +0100 Subject: [PATCH 256/531] Update Shape.c Make no sense to say this is experimental and will change in 4.0.0 when we are already above 4.0.0. This should be removed, or updated to say it will not be in x.0.0 --- shared-bindings/displayio/Shape.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index faa9472fa6..7c7b105015 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -41,8 +41,6 @@ //| //| Represents any shape made by defining boundaries that may be mirrored. //| -//| .. warning:: This will likely be changed before 4.0.0. Consider it very experimental. -//| //| .. class:: Shape(width, height, *, mirror_x=False, mirror_y=False) //| //| Create a Shape object with the given fixed size. Each pixel is one bit and is stored by the From e9dbc34d803a95ed2ff1cb4d234a855416288dcd Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 30 Dec 2019 11:35:02 -0500 Subject: [PATCH 257/531] add cypthon compat setting --- ports/stm32f4/mpconfigport.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk index 88636a9d89..42f3905723 100644 --- a/ports/stm32f4/mpconfigport.mk +++ b/ports/stm32f4/mpconfigport.mk @@ -65,9 +65,13 @@ ifndef CIRCUITPY_NEOPIXEL_WRITE CIRCUITPY_NEOPIXEL_WRITE = 1 endif -ifndef +ifndef CIRCUITPY_DISPLAYIO CIRCUITPY_DISPLAYIO = 1 endif +ifndef MICROPY_CPYTHON_COMPAT +MICROPY_CPYTHON_COMPAT = 1 +endif + #ifeq ($(MCU_SUB_VARIANT), stm32f412zx) #endif From e1d026f81518eaebbe64b9e4b1ade5123f6fb9e7 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 30 Dec 2019 11:33:04 -0800 Subject: [PATCH 258/531] Update pins.c --- ports/atmel-samd/boards/hallowing_m4_express/pins.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/atmel-samd/boards/hallowing_m4_express/pins.c b/ports/atmel-samd/boards/hallowing_m4_express/pins.c index 89fe3fbcf4..9365ea3caf 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/pins.c @@ -24,10 +24,10 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA22) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB23) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB22) }, - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB12) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB12) }, - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB13) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA12) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA13) }, { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA14) }, From 0223589e6cbd6f7e7e6f98981bbc9b3cf510da8e Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 30 Dec 2019 11:34:51 -0800 Subject: [PATCH 259/531] Fix default UART too --- ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h index a0c726e726..38f78da4d3 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h @@ -23,8 +23,8 @@ #define DEFAULT_SPI_BUS_MOSI (&pin_PB23) #define DEFAULT_SPI_BUS_MISO (&pin_PB22) -#define DEFAULT_UART_BUS_RX (&pin_PB12) -#define DEFAULT_UART_BUS_TX (&pin_PB13) +#define DEFAULT_UART_BUS_RX (&pin_PB13) +#define DEFAULT_UART_BUS_TX (&pin_PB12) // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 From 28b1d718a36e02af4d1a7d68e92da3c942848a47 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 30 Dec 2019 15:15:55 -0500 Subject: [PATCH 260/531] Tests for PWM issues, style changes --- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 2 +- ports/stm32f4/boards/meowbit_v121/pins.c | 2 +- ports/stm32f4/common-hal/pulseio/PWMOut.c | 5 +++++ ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 89cdee6d95..e97d793bed 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -36,7 +36,7 @@ #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) #define BOARD_OSC_DIV 12 -#define BOARD_NO_VBUS +#define BOARD_NO_VBUS_SENSE // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PB15) diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 8a798dcb48..7b896bd70b 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -52,7 +52,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P9), MP_ROM_PTR(&pin_PC06) }, { MP_ROM_QSTR(MP_QSTR_P8), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA01) }, - { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA10) }, //in use by USB { MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PC07) }, { MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PB05) }, { MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PC01) }, diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 16b1b5b896..301f8cd499 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -124,6 +124,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, uint16_t duty, uint32_t frequency, bool variable_frequency) { + mp_printf(&mp_plat_print, "Construct PWM\n"); TIM_TypeDef * TIMx; uint8_t tim_num = sizeof(mcu_tim_pin_list)/sizeof(*mcu_tim_pin_list); bool tim_chan_taken = false; @@ -194,6 +195,8 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, GPIO_InitStruct.Alternate = self->tim->altfn_index; HAL_GPIO_Init(pin_port(pin->port), &GPIO_InitStruct); + mp_printf(&mp_plat_print, "PWM Pin:%d Port:%d\n", pin->number, pin->port); + tim_clock_enable(1<<(self->tim->tim_index - 1)); //translate channel into handle value @@ -203,6 +206,8 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, uint32_t period = 0; //period is 16 bit timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index)); + mp_printf(&mp_plat_print, "Per:%d presc:%d\n", period, prescaler); + //Timer init self->handle.Instance = TIMx; self->handle.Init.Period = period - 1; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c index 859e9a1adb..b120841860 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.c @@ -125,6 +125,7 @@ const mcu_uart_rx_obj_t mcu_uart_rx_list[6] = { TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10, TIM11, NULL, NULL, NULL}; +//#define TIM(index, alt, channel, tim_pin) const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { TIM(2,1,1,&pin_PA00), TIM(5,2,1,&pin_PA00), From 3f9ebd2fedffa431a4eb7ff9f3dd49399e245795 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 30 Dec 2019 17:10:42 -0500 Subject: [PATCH 261/531] initial CLUE board defn --- .github/workflows/build.yml | 1 + .../nrf/boards/clue_nrf52840_express/board.c | 37 +++++++ .../clue_nrf52840_express/mpconfigboard.h | 63 +++++++++++ .../clue_nrf52840_express/mpconfigboard.mk | 10 ++ ports/nrf/boards/clue_nrf52840_express/pins.c | 101 ++++++++++++++++++ 5 files changed, 212 insertions(+) create mode 100644 ports/nrf/boards/clue_nrf52840_express/board.c create mode 100644 ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h create mode 100644 ports/nrf/boards/clue_nrf52840_express/mpconfigboard.mk create mode 100644 ports/nrf/boards/clue_nrf52840_express/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e87190c727..903948657c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,6 +84,7 @@ jobs: - "circuitplayground_express" - "circuitplayground_express_crickit" - "circuitplayground_express_displayio" + - "clue_nrf52840_express" - "cp32-m4" - "datalore_ip_m4" - "datum_distance" diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c new file mode 100644 index 0000000000..92eebf0f48 --- /dev/null +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h new file mode 100644 index 0000000000..a239ca7ce3 --- /dev/null +++ b/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h @@ -0,0 +1,63 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 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. + */ + +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "Adafruit CLUE nRF52840 Express" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_NEOPIXEL (&pin_P0_16) + +#define MICROPY_HW_LED_STATUS (&pin_P1_01) + +#if QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 17) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 23) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 21) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 20) +#endif + +#if SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P0_17 +#define SPI_FLASH_MISO_PIN &pin_P0_22 +#define SPI_FLASH_SCK_PIN &pin_P0_19 +#define SPI_FLASH_CS_PIN &pin_P0_20 +#endif + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_25) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_24) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_08) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_26) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_06) + +#define DEFAULT_UART_BUS_RX (&pin_P0_04) +#define DEFAULT_UART_BUS_TX (&pin_P0_05) diff --git a/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.mk b/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.mk new file mode 100644 index 0000000000..16cb208247 --- /dev/null +++ b/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.mk @@ -0,0 +1,10 @@ +USB_VID = 0x239A +USB_PID = 0x8072 +USB_PRODUCT = "CLUE nRF52840 Express" +USB_MANUFACTURER = "Adafruit Industries LLC" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = "GD25Q16C" diff --git a/ports/nrf/boards/clue_nrf52840_express/pins.c b/ports/nrf/boards/clue_nrf52840_express/pins.c new file mode 100644 index 0000000000..b13d1977fb --- /dev/null +++ b/ports/nrf/boards/clue_nrf52840_express/pins.c @@ -0,0 +1,101 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_04) }, + + { MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_28) }, + + { MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_02) }, + + { MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_P1_02) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_02) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_P1_02) }, + + { MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_P1_09) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P1_09) }, + + { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_07) }, + + { MP_ROM_QSTR(MP_QSTR_P8), MP_ROM_PTR(&pin_P1_07) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P1_07) }, + + { MP_ROM_QSTR(MP_QSTR_P9), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_27) }, + + { MP_ROM_QSTR(MP_QSTR_P10), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_P11), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_P1_10) }, + + { MP_ROM_QSTR(MP_QSTR_P12), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_P13), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_08) }, + + { MP_ROM_QSTR(MP_QSTR_P14), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_06) }, + + { MP_ROM_QSTR(MP_QSTR_P15), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_26) }, + + { MP_ROM_QSTR(MP_QSTR_P16), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_29) }, + + { MP_ROM_QSTR(MP_QSTR_P17), MP_ROM_PTR(&pin_P1_01) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_P1_01) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_01) }, + + { MP_ROM_QSTR(MP_QSTR_P18), MP_ROM_PTR(&pin_P0_16) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_P0_16) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_16) }, + + { MP_ROM_QSTR(MP_QSTR_P19), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_25) }, + + { MP_ROM_QSTR(MP_QSTR_P20), MP_ROM_PTR(&pin_P0_24) }, + { MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_P0_24) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_24) }, + + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P1_08) }, + + { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_P1_03) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_P1_05) }, + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_P0_15) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From f0d34da5560b953f2c6c641a3533e14645528751 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 30 Dec 2019 17:39:39 -0500 Subject: [PATCH 262/531] add display support; rotation 270 --- .../nrf/boards/clue_nrf52840_express/board.c | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index 92eebf0f48..c118fe92f1 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -25,12 +25,74 @@ */ #include "boards/board.h" +#include "mpconfigboard.h" + +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "tick.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + 0x11, 0 | DELAY, 255, // SLPOUT + 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order. + 0x3a, 1, 0x55, // COLMOD - 16bit color + 0x21, 0 | DELAY, 10, // _INVON + 0x13, 0 | DELAY, 10, // _NORON + 0x29, 0 | DELAY, 255, // _DISPON +}; void board_init(void) { + busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL); + 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_P0_13, // TFT_DC Command or data + &pin_P0_12, // TFT_CS Chip select + &pin_P1_03, // TFT_RST Reset + 60000000); + + 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 + 0, // row start + 270, // rotation + 16, // Color depth + false, // Grayscale + false, // Pixels in a byte share a row. Only used for depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + 0x37, // set vertical scroll command + display_init_sequence, + sizeof(display_init_sequence), + &pin_P1_05, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60); // native_frames_per_second } bool board_requests_safe_mode(void) { - return false; + return false; } void reset_board(void) { From ca5b2770cf30f30946991faeaab16263bce435e9 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 16:10:01 -0500 Subject: [PATCH 263/531] try a property with a callable static class --- shared-bindings/_pixelbuf/PixelBuf.c | 64 ++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 7c624a8fdf..75f1b21882 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -346,8 +346,26 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s //| Fills the entire buffer with the given color. //| -STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + +// Pixelbuf Fill callable class + +typedef struct _pixelbuf_fill_t { + mp_obj_base_t base; +} pixelbuf_fill_t; + + +STATIC mp_obj_t pixelbuf_fill_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + pixelbuf_fill_t *o = m_new_obj(pixelbuf_fill_t); + o->base.type = type; + return MP_OBJ_FROM_PTR(o); +} + +// calls show +STATIC mp_obj_t pixelbuf_fill_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num_kw_array(n_args, n_kw, 2, 2, false); + mp_obj_t object = args[0]; + mp_obj_t value = args[1]; + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(object); for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, @@ -357,7 +375,47 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { call_show(self_in); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); + +const mp_obj_type_t pixelbuf_fill_type = { + { &mp_type_type }, + .name = MP_QSTR_PixelBufFill, + .make_new = pixelbuf_fill_make_new, + .call = pixelbuf_fill_call, +}; + +STATIC const pixelbuf_fill_t pixelbuf_fill_singleton = { + .base = { &pixelbuf_fill_type }, +}; + + +// STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { +// pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + +// for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { +// pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, +// self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); +// } +// if (self->auto_write) +// call_show(self_in); +// return mp_const_none; +// } +// STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); + + +STATIC mp_obj_t pixelbuf_pixelbuf_obj_fill_get(mp_obj_t self_in) { + // pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + return MP_OBJ_FROM_PTR(&pixelbuf_fill_singleton); +} +MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_obj_fill_get_obj, pixelbuf_pixelbuf_obj_fill_get); + +const mp_obj_property_t pixelbuf_pixelbuf_fill_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_obj_fill_get_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + //| .. method:: __getitem__(index) From 8129a8503a25bdffd00ce679ee98e940d1b6b04d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 16:10:22 -0500 Subject: [PATCH 264/531] Revert "try a property with a callable static class" This reverts commit ca5b2770cf30f30946991faeaab16263bce435e9. --- shared-bindings/_pixelbuf/PixelBuf.c | 64 ++-------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 75f1b21882..7c624a8fdf 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -346,26 +346,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s //| Fills the entire buffer with the given color. //| - -// Pixelbuf Fill callable class - -typedef struct _pixelbuf_fill_t { - mp_obj_base_t base; -} pixelbuf_fill_t; - - -STATIC mp_obj_t pixelbuf_fill_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - pixelbuf_fill_t *o = m_new_obj(pixelbuf_fill_t); - o->base.type = type; - return MP_OBJ_FROM_PTR(o); -} - -// calls show -STATIC mp_obj_t pixelbuf_fill_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num_kw_array(n_args, n_kw, 2, 2, false); - mp_obj_t object = args[0]; - mp_obj_t value = args[1]; - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(object); +STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, @@ -375,47 +357,7 @@ STATIC mp_obj_t pixelbuf_fill_call(mp_obj_t self_in, size_t n_args, size_t n_kw, call_show(self_in); return mp_const_none; } - -const mp_obj_type_t pixelbuf_fill_type = { - { &mp_type_type }, - .name = MP_QSTR_PixelBufFill, - .make_new = pixelbuf_fill_make_new, - .call = pixelbuf_fill_call, -}; - -STATIC const pixelbuf_fill_t pixelbuf_fill_singleton = { - .base = { &pixelbuf_fill_type }, -}; - - -// STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { -// pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - -// for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { -// pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, -// self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); -// } -// if (self->auto_write) -// call_show(self_in); -// return mp_const_none; -// } -// STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); - - -STATIC mp_obj_t pixelbuf_pixelbuf_obj_fill_get(mp_obj_t self_in) { - // pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return MP_OBJ_FROM_PTR(&pixelbuf_fill_singleton); -} -MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_obj_fill_get_obj, pixelbuf_pixelbuf_obj_fill_get); - -const mp_obj_property_t pixelbuf_pixelbuf_fill_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_obj_fill_get_obj, - (mp_obj_t)&mp_const_none_obj, - (mp_obj_t)&mp_const_none_obj}, -}; - - +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); //| .. method:: __getitem__(index) From 12193913a802e3b9c72079a93cb40c97d95cc683 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 17:30:17 -0500 Subject: [PATCH 265/531] move native fill to a helper to work around being unable to call a subclass show method from the native superclass --- locale/ID.po | 7 +++++-- locale/circuitpython.pot | 7 +++++-- locale/de_DE.po | 7 +++++-- locale/en_US.po | 7 +++++-- locale/en_x_pirate.po | 7 +++++-- locale/es.po | 7 +++++-- locale/fil.po | 7 +++++-- locale/fr.po | 7 +++++-- locale/it_IT.po | 7 +++++-- locale/ko.po | 7 +++++-- locale/pl.po | 7 +++++-- locale/pt_BR.po | 7 +++++-- locale/zh_Latn_pinyin.po | 7 +++++-- shared-bindings/_pixelbuf/PixelBuf.c | 20 -------------------- shared-bindings/_pixelbuf/__init__.c | 24 ++++++++++++++++++++++++ 15 files changed, 89 insertions(+), 46 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 4808727066..20662ae9db 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -600,6 +600,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1078,7 +1082,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 7adde9ba85..5cf44cc356 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -589,6 +589,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1062,7 +1066,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 4a2bc89947..17f2e38280 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -593,6 +593,10 @@ msgstr "Erwartet ein(e) %q" msgid "Expected a Characteristic" msgstr "Characteristic wird erwartet" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Ein Service wird erwartet" @@ -1079,7 +1083,6 @@ msgid "Sample rate must be positive" msgstr "Abtastrate muss positiv sein" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" diff --git a/locale/en_US.po b/locale/en_US.po index 135aeda172..e6fbfc471b 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -589,6 +589,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1062,7 +1066,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 5ac17778af..5635102301 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -593,6 +593,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1066,7 +1070,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/es.po b/locale/es.po index 331c1a3edd..c9688a41b1 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -595,6 +595,10 @@ msgstr "Se espera un %q" msgid "Expected a Characteristic" msgstr "Se esperaba una Característica." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1080,7 +1084,6 @@ msgid "Sample rate must be positive" msgstr "Sample rate debe ser positivo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" diff --git a/locale/fil.po b/locale/fil.po index a867e2a4f8..94f39f4064 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -602,6 +602,10 @@ msgstr "Umasa ng %q" msgid "Expected a Characteristic" msgstr "Hindi mabasa and Characteristic." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1086,7 +1090,6 @@ msgid "Sample rate must be positive" msgstr "Sample rate ay dapat positibo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" diff --git a/locale/fr.po b/locale/fr.po index 22e3b5b5bc..42209a045e 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -605,6 +605,10 @@ msgstr "Attendu un %q" msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1100,7 +1104,6 @@ msgid "Sample rate must be positive" msgstr "Le taux d'échantillonage doit être positif" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taux d'échantillonage trop élevé. Doit être inf. à %d" diff --git a/locale/it_IT.po b/locale/it_IT.po index 575263b4be..684e2a90b9 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -602,6 +602,10 @@ msgstr "Atteso un %q" msgid "Expected a Characteristic" msgstr "Non è possibile aggiungere Characteristic." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1096,7 +1100,6 @@ msgid "Sample rate must be positive" msgstr "STA deve essere attiva" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 51544984ed..7b4240800b 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -593,6 +593,10 @@ msgstr "%q 이 예상되었습니다." msgid "Expected a Characteristic" msgstr "특성(Characteristic)이 예상되었습니다." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1066,7 +1070,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 9b2208849b..1ef686e451 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -592,6 +592,10 @@ msgstr "Oczekiwano %q" msgid "Expected a Characteristic" msgstr "Oczekiwano charakterystyki" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1067,7 +1071,6 @@ msgid "Sample rate must be positive" msgstr "Częstotliwość próbkowania musi być dodatnia" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index a2ccd2625d..9d36696ce7 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -597,6 +597,10 @@ msgstr "Esperado um" msgid "Expected a Characteristic" msgstr "Não é possível adicionar Característica." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1079,7 +1083,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 5b636ff606..cb907e0a1f 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -593,6 +593,10 @@ msgstr "Yùqí %q" msgid "Expected a Characteristic" msgstr "Yùqí de tèdiǎn" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Yùqí fúwù" @@ -1072,7 +1076,6 @@ msgid "Sample rate must be positive" msgstr "Cǎiyàng lǜ bìxū wèi zhèng shù" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 7c624a8fdf..e422818546 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -341,25 +341,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); -//| .. method:: fill(color) -//| -//| Fills the entire buffer with the given color. -//| - -STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - - for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { - pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, - self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); - } - if (self->auto_write) - call_show(self_in); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); - - //| .. method:: __getitem__(index) //| //| Returns the pixel value at the given index. @@ -464,7 +445,6 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, - { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_pixelbuf_fill_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_locals_dict_table); diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 75482cbc26..433f1d97b8 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -82,10 +82,34 @@ const int32_t colorwheel(float pos) { } } + +//| .. function:: fill(pixelbuf, color) +//| +//| Fills the given pixelbuf with the given color. +//| + +STATIC mp_obj_t pixelbuf_fill(mp_obj_t pixelbuf_in, mp_obj_t value) { + mp_obj_t obj = mp_instance_cast_to_native_base(pixelbuf_in, &pixelbuf_pixelbuf_type); + if (obj == MP_OBJ_NULL) + mp_raise_TypeError(translate("Expected a PixelBuf instance")); + pixelbuf_pixelbuf_obj_t *pixelbuf = MP_OBJ_TO_PTR(obj); + + for (size_t offset = 0; offset < pixelbuf->bytes; offset+= pixelbuf->pixel_step) { + pixelbuf_set_pixel(pixelbuf->buf + offset, pixelbuf->two_buffers ? (pixelbuf->rawbuf + offset) : NULL, + pixelbuf->brightness, value, &pixelbuf->byteorder, pixelbuf->byteorder.is_dotstar); + } + if (pixelbuf->auto_write) + call_show(pixelbuf_in); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_fill_obj, pixelbuf_fill); + + STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, + { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_fill_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table); From 4e1996856f15bb1ada52651ce6b9e7571c1d52bc Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 19:25:44 -0500 Subject: [PATCH 266/531] Fix docstring for byteorder --- shared-bindings/_pixelbuf/PixelBuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index e422818546..465b5cbb86 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -66,7 +66,7 @@ extern const int32_t colorwheel(float pos); //| //| :param ~int size: Number of pixelsx //| :param ~bytearray buf: Bytearray in which to store pixel data -//| :param ~str byteorder: Byte order string (such as "BGR" or "DBGR") +//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) //| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) From ec22520992723a89dbc57a5e59bf03815df9f509 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 2 Jan 2020 15:23:42 -0600 Subject: [PATCH 267/531] MP3File: Add rms_level property This lets a music player show it vu-meter style --- shared-bindings/audiomp3/MP3File.c | 19 +++++++++++++++++++ shared-bindings/audiomp3/MP3File.h | 1 + shared-module/audiomp3/MP3File.c | 11 +++++++++++ shared-module/audiomp3/MP3File.h | 2 ++ 4 files changed, 33 insertions(+) diff --git a/shared-bindings/audiomp3/MP3File.c b/shared-bindings/audiomp3/MP3File.c index d867643f91..a02e42364d 100644 --- a/shared-bindings/audiomp3/MP3File.c +++ b/shared-bindings/audiomp3/MP3File.c @@ -224,6 +224,24 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = { (mp_obj_t)&mp_const_none_obj}, }; +//| .. attribute:: rms_level +//| +//| The RMS audio level of a recently played moment of audio. (read only) +//| +STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return mp_obj_new_float(common_hal_audiomp3_mp3file_get_rms_level(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_rms_level_obj, audiomp3_mp3file_obj_get_rms_level); + +const mp_obj_property_t audiomp3_mp3file_rms_level_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiomp3_mp3file_get_rms_level_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { // Methods @@ -236,6 +254,7 @@ STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&audiomp3_mp3file_sample_rate_obj) }, { MP_ROM_QSTR(MP_QSTR_bits_per_sample), MP_ROM_PTR(&audiomp3_mp3file_bits_per_sample_obj) }, { MP_ROM_QSTR(MP_QSTR_channel_count), MP_ROM_PTR(&audiomp3_mp3file_channel_count_obj) }, + { MP_ROM_QSTR(MP_QSTR_rms_level), MP_ROM_PTR(&audiomp3_mp3file_rms_level_obj) }, }; STATIC MP_DEFINE_CONST_DICT(audiomp3_mp3file_locals_dict, audiomp3_mp3file_locals_dict_table); diff --git a/shared-bindings/audiomp3/MP3File.h b/shared-bindings/audiomp3/MP3File.h index 774d839ff5..e6787cb8b3 100644 --- a/shared-bindings/audiomp3/MP3File.h +++ b/shared-bindings/audiomp3/MP3File.h @@ -45,5 +45,6 @@ uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* sel void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t* self, uint32_t sample_rate); uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t* self); uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t* self); +float common_hal_audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t* self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3File.c index 390ba25447..515aa00863 100644 --- a/shared-module/audiomp3/MP3File.c +++ b/shared-module/audiomp3/MP3File.c @@ -29,6 +29,7 @@ #include #include +#include #include "py/mperrno.h" #include "py/runtime.h" @@ -339,3 +340,13 @@ void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t* self, bool si *spacing = 1; } } + +float common_hal_audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t* self) { + float sumsq = 0.f; + // Assumes no DC component to the audio. Is that a safe assumption? + int16_t *buffer = (int16_t *)(void *)self->buffers[self->buffer_index]; + for(size_t i=0; iframe_buffer_size / sizeof(int16_t); i++) { + sumsq += (float)buffer[i] * buffer[i]; + } + return sqrtf(sumsq) / (self->frame_buffer_size / sizeof(int16_t)); +} diff --git a/shared-module/audiomp3/MP3File.h b/shared-module/audiomp3/MP3File.h index 9d99e8d1f0..9ee1d0949b 100644 --- a/shared-module/audiomp3/MP3File.h +++ b/shared-module/audiomp3/MP3File.h @@ -67,4 +67,6 @@ void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t* self, bool si bool* single_buffer, bool* samples_signed, uint32_t* max_buffer_length, uint8_t* spacing); +float audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t* self); + #endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H From fdddb54db41fce45abaa9d4254f44de4dab4b631 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 2 Jan 2020 17:56:04 -0500 Subject: [PATCH 268/531] rename call_show to pixelbuf_call_show --- shared-bindings/_pixelbuf/PixelBuf.c | 8 ++++---- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- shared-bindings/_pixelbuf/__init__.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 465b5cbb86..6eb35c51ad 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -230,7 +230,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_show(self_in); + pixelbuf_call_show(self_in); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -253,7 +253,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } -mp_obj_t call_show(mp_obj_t self_in) { +mp_obj_t pixelbuf_call_show(mp_obj_t self_in) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); return mp_call_method_n_kw(0, 0, dest); @@ -412,7 +412,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(self_in); + pixelbuf_call_show(self_in); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -432,7 +432,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(self_in); + pixelbuf_call_show(self_in); return mp_const_none; } } diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index aa09e92613..691da3cd33 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -48,6 +48,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -mp_obj_t call_show(mp_obj_t self_in); +mp_obj_t pixelbuf_call_show(mp_obj_t self_in); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 433f1d97b8..ed264f3bb4 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -99,7 +99,7 @@ STATIC mp_obj_t pixelbuf_fill(mp_obj_t pixelbuf_in, mp_obj_t value) { pixelbuf->brightness, value, &pixelbuf->byteorder, pixelbuf->byteorder.is_dotstar); } if (pixelbuf->auto_write) - call_show(pixelbuf_in); + pixelbuf_call_show(pixelbuf_in); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_fill_obj, pixelbuf_fill); From ccf158b03009d3de7ec8d70584044cd7f7bc1dd3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 2 Jan 2020 18:00:36 -0500 Subject: [PATCH 269/531] raise mp_raise_NotImplementedError --- extmod/modbtree.c | 2 -- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/extmod/modbtree.c b/extmod/modbtree.c index ad845163d6..7cfa9c6afb 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -246,9 +246,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { // delete diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 6eb35c51ad..3e93190470 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -332,11 +332,11 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| .. method:: show() //| -//| Does nothing unless subclassed. +//| Must be implemented in subclasses. //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { - return mp_const_none; + mp_raise_NotImplementedError(NULL); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); From 767ce1cdf8c56ed00f2b88c4babcd92b91b51755 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 2 Jan 2020 18:03:18 -0500 Subject: [PATCH 270/531] remove unnecessary GCC pragmas --- extmod/machine_mem.c | 1 - extmod/moductypes.c | 1 - ports/unix/modjni.c | 1 - py/objdict.c | 1 - py/objlist.c | 1 - py/objrange.c | 1 - py/objstr.c | 1 - py/objstrunicode.c | 1 - py/objtuple.c | 1 - shared-bindings/displayio/Bitmap.c | 1 - shared-bindings/displayio/Group.c | 1 - shared-bindings/displayio/Palette.c | 1 - 12 files changed, 12 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index 75496c6b5f..e0649290ef 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -60,7 +60,6 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/extmod/moductypes.c b/extmod/moductypes.c index bf5f1cef73..451dc29ed9 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -518,7 +518,6 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value) { mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index e18a26f3c6..8ec5ae54d9 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -241,7 +241,6 @@ STATIC void get_jclass_name(jobject obj, char *buf) { check_exception(); } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); diff --git a/py/objdict.c b/py/objdict.c index 5bbe939b1d..683fcb748e 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -174,7 +174,6 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete diff --git a/py/objlist.c b/py/objlist.c index 64381bc706..b32f82085e 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -158,7 +158,6 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { diff --git a/py/objrange.c b/py/objrange.c index 6f14bcc9f9..30d55c56cd 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -158,7 +158,6 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs } #endif -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load diff --git a/py/objstr.c b/py/objstr.c index 567e734442..fde2646815 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -439,7 +439,6 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s #endif // This is used for both bytes and 8-bit strings. This is not used for unicode strings. -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 2540a1d7b6..30000a51e7 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -197,7 +197,6 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s return s; } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); diff --git a/py/objtuple.c b/py/objtuple.c index b7f50d3b2c..2b483f8b83 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -177,7 +177,6 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index ca9484a408..91c17f2d13 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -133,7 +133,6 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| bitmap[0,1] = 3 //| -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { // delete item diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index f5e3c22634..dd7600eb9c 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -310,7 +310,6 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| //| del group[0] //| -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { displayio_group_t *self = native_group(self_in); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 903338abb2..dda58e3c53 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -95,7 +95,6 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item From bd8650d35be493bfbfef34976784d1d614b09ed1 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 2 Jan 2020 17:55:50 -0600 Subject: [PATCH 271/531] samd/peripherals: take upstream update --- ports/atmel-samd/peripherals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/peripherals b/ports/atmel-samd/peripherals index 28ad937da2..b89811f22a 160000 --- a/ports/atmel-samd/peripherals +++ b/ports/atmel-samd/peripherals @@ -1 +1 @@ -Subproject commit 28ad937da258993359f0e91a4cb19db899a1e46a +Subproject commit b89811f22a24ac350079ceaf0cdf0e62aa03f4f4 From 242d572470b20a06c5b0be5e07a84aefaa4abbe1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 3 Jan 2020 10:24:07 -0500 Subject: [PATCH 272/531] wip --- ports/atmel-samd/common-hal/nvm/ByteArray.c | 4 +- ports/nrf/common-hal/_bleio/Characteristic.c | 23 ++ ports/nrf/common-hal/_bleio/Connection.c | 53 ++-- ports/nrf/common-hal/_bleio/Connection.h | 3 +- ports/nrf/common-hal/_bleio/bonding.c | 240 +++++++++++++++++++ ports/nrf/common-hal/_bleio/bonding.h | 43 ++++ ports/nrf/common-hal/nvm/ByteArray.c | 14 +- ports/nrf/peripherals/nrf/nvm.c | 6 + tools/preprocess_frozen_modules.py | 1 + 9 files changed, 359 insertions(+), 28 deletions(-) create mode 100644 ports/nrf/common-hal/_bleio/bonding.c create mode 100644 ports/nrf/common-hal/_bleio/bonding.h diff --git a/ports/atmel-samd/common-hal/nvm/ByteArray.c b/ports/atmel-samd/common-hal/nvm/ByteArray.c index 12a127f53a..ac896a9d52 100644 --- a/ports/atmel-samd/common-hal/nvm/ByteArray.c +++ b/ports/atmel-samd/common-hal/nvm/ByteArray.c @@ -43,9 +43,9 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, // whenever we need it instead of storing it long term. struct flash_descriptor desc; desc.dev.hw = NVMCTRL; - flash_write(&desc, (uint32_t) self->start_address + start_index, values, len); + bool status = flash_write(&desc, (uint32_t) self->start_address + start_index, values, len) == ERR_NONE; assert_heap_ok(); - return true; + return status; } // NVM memory is memory mapped so reading it is easy. diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index 9f1255e32f..f80c52ae43 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -82,6 +82,27 @@ STATIC void characteristic_gatts_notify_indicate(uint16_t handle, uint16_t conn_ } } +STATIC bool characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) { + bleio_characteristic_obj_t *self = (bleio_characteristic_obj_t *) param; + switch (ble_evt->header.evt_id) { + case BLE_GATTS_EVT_WRITE: { + // A client wrote to this server characteristic. + // If we are bonded, stored the CCCD value. + if (self->service != MP_OBJ_NULL) { + bleio_connection_obj_t *connection = self->service->connection; + uint16_t conn_handle = bleio_connection_get_conn_handle(connection); + if (conn_handle != BLE_CONN_HANDLE_INVALID && + connection->pairing_status == PAIR_PAIRED && + ble_evt->gatts_evt.params.write.handle == self->cccd_handle) { + bonding_save_cccd_later(connection->is_central, conn_handle, connection->ediv); + } + break; + } + } + + return true; +} + void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_service_obj_t *service, uint16_t handle, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo) { self->service = service; self->uuid = uuid; @@ -108,6 +129,8 @@ void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, if (initial_value_bufinfo != NULL) { common_hal_bleio_characteristic_set_value(self, initial_value_bufinfo); } + + ble_drv_add_event_handler(characteristic_on_ble_evt, self); } bleio_descriptor_obj_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self) { diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index e0b50901ad..725a9a11a9 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -171,6 +171,15 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } case BLE_GAP_EVT_SEC_PARAMS_REQUEST: { + // First time pairing. + // 1. Either we or peer initiate the process + // 2. Peer asks for security parameters using BLE_GAP_EVT_SEC_PARAMS_REQUEST. + // 3. Pair Key exchange ("just works" implemented now; TODO key pairing) + // 4. Connection is secured: BLE_GAP_EVT_CONN_SEC_UPDATE + // 5. Long-term Keys exchanged: BLE_GAP_EVT_AUTH_STATUS + + bonding_clear_keys(&self->bonding_keys); + self->ediv = EDIV_INVALID; ble_gap_sec_keyset_t keyset = { .keys_own = { .p_enc_key = &self->bonding_keys.own_enc, @@ -188,7 +197,8 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { }; sd_ble_gap_sec_params_reply(self->conn_handle, BLE_GAP_SEC_STATUS_SUCCESS, - &pairing_sec_params, &keyset); + self->is_central ? NULL : &pairing_sec_params, + &keyset); break; } @@ -202,8 +212,9 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { ble_gap_evt_auth_status_t* status = &ble_evt->evt.gap_evt.params.auth_status; self->sec_status = status->auth_status; if (status->auth_status == BLE_GAP_SEC_STATUS_SUCCESS) { - // TODO _ediv = bonding_keys->own_enc.master_id.ediv; + self->ediv = bonding_keys->own_enc.master_id.ediv; self->pair_status = PAIR_PAIRED; + bonding_save_keys(self->is_central, self->conn_handle, &self->bonding_keys); } else { self->pair_status = PAIR_NOT_PAIRED; } @@ -216,14 +227,17 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // - Else return NULL --> Initiate key exchange ble_gap_evt_sec_info_request_t* sec_info_request = &ble_evt->evt.gap_evt.params.sec_info_request; (void) sec_info_request; - //if ( bond_load_keys(_role, sec_req->master_id.ediv, &bkeys) ) { - //sd_ble_gap_sec_info_reply(_conn_hdl, &bkeys.own_enc.enc_info, &bkeys.peer_id.id_info, NULL); - // - //_ediv = bkeys.own_enc.master_id.ediv; - // } else { + bond_keys bond_keys_t; + if ( bonding_load_keys(self->is_central, sec_info_request->master_id.ediv, &self->bonding_keys) ) { + sd_ble_gap_sec_info_reply(self->conn_handle + &self->bonding_keys.own_enc.enc_info, + &self->bonding_keys.peer_id.id_info, + NULL); + self->ediv = bond_keys.own_enc.master_id.ediv; + } else { sd_ble_gap_sec_info_reply(self->conn_handle, NULL, NULL, NULL); - // } - break; + } + break; } case BLE_GAP_EVT_CONN_SEC_UPDATE: { // 0x1a @@ -235,17 +249,23 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // mode >=1 and/or level >=1 means encryption is set up self->pair_status = PAIR_NOT_PAIRED; } else { - //if ( !bond_load_cccd(_role, _conn_hdl, _ediv) ) { - if (true) { // TODO: no bonding yet - // Initialize system attributes fresh. - sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); - } + uint8_t *sys_attr; + uint16_t sys_attr_len; + if (bonding_load_cccd_info(self->is_central, self->conn_handle, self->ediv, sys_attr, sys_attr_len)) { + sd_ble_gatts_sys_attr_set(self->conn_handle, sys_attr, sys_attr_len, SVC_CONTEXT_FLAG); // Not quite paired yet: wait for BLE_GAP_EVT_AUTH_STATUS SUCCESS. self->ediv = self->bonding_keys.own_enc.master_id.ediv; + } else { + // No matching bonding found, so use fresh system attributes. + sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); + } } break; } + case BLE_GATTS_EVT_WRITE: { + if (self->pair_status == PAIR_PAIRED) && + default: return false; @@ -258,8 +278,7 @@ void bleio_connection_clear(bleio_connection_internal_t *self) { self->conn_handle = BLE_CONN_HANDLE_INVALID; self->pair_status = PAIR_NOT_PAIRED; - - memset(&self->bonding_keys, 0, sizeof(self->bonding_keys)); + bonding_clear_keys(self); } bool common_hal_bleio_connection_get_paired(bleio_connection_obj_t *self) { @@ -480,7 +499,7 @@ STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, bleio default: // TODO: sd_ble_gattc_descriptors_discover() can return things that are not descriptors, // so ignore those. - // https://devzone.nordicsemi.com/f/nordic-q-a/49500/sd_ble_gattc_descriptors_discover-is-returning-attributes-that-are-not-descriptors + // htts:p//devzone.nordicsemi.com/f/nordic-q-a/49500/sd_ble_gattc_descriptors_discover-is-returning-attributes-that-are-not-descriptors break; } diff --git a/ports/nrf/common-hal/_bleio/Connection.h b/ports/nrf/common-hal/_bleio/Connection.h index 1474a0a6c0..daa7f64464 100644 --- a/ports/nrf/common-hal/_bleio/Connection.h +++ b/ports/nrf/common-hal/_bleio/Connection.h @@ -36,6 +36,7 @@ #include "py/objlist.h" #include "common-hal/_bleio/__init__.h" +#include "common-hal/_bleio/bonding.h" #include "shared-module/_bleio/Address.h" #include "common-hal/_bleio/Service.h" @@ -59,7 +60,7 @@ typedef struct { // EDIV: Encrypted Diversifier: Identifies LTK during legacy pairing. bonding_keys_t bonding_keys; uint16_t ediv; - pair_status_t pair_status; + volatile pair_status_t pair_status; uint8_t sec_status; // Internal security status. mp_obj_t connection_obj; ble_drv_evt_handler_entry_t handler_entry; diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c new file mode 100644 index 0000000000..c717d08165 --- /dev/null +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -0,0 +1,240 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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. + */ + +#include +#include +#include + +#include "ble.h" +#include "ble_drv.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/nvm/ByteArray.h" + +#include "bonding.h" + +// Internal flash area reserved for bonding storage. +#define BONDING_PAGES_START_ADDR CIRCUITPY_BLE_CONFIG_START_ADDR +#define BONDING_PAGES_END_ADDR (CIRCUITPY_BLE_CONFIG_START_ADDR + CIRCUITPY_BLE_CONFIG_SIZE) + +// First and last four bytes are magic bytes for id and version. Start data after that. +// 'BD01' +const uint32_t BONDING_START_FLAG ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); +// 'ED01' +const uint32_t BONDING_END_FLAG ('1' | '0' << 8 | 'D' << 16 | 'E' << 24); + +#define BONDING_DATA_START_ADDR (BONDING_DATA_START_ADDR + sizeof(BONDING_START_BYTES)) +#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_END_BYTES)) + +#define BONDING_START_FLAG_ADDR BONDING_DATA_START_ADDR +#define BONDING_END_FLAG_ADDR BONDING_DATA_END_ADDR + +// Bonding data is stored in variable-length blocks consecutively in erased flash. +// The blocks are 32-bit aligned, though the data may be any number of bytes. +// You can hop through the blocks using the size field to find the next block. +// When you hit a word that is all one's, you have reached the end of the blocks. +// You can write a new block there. + +typdef enum { + BLOCK_INVALID = 0, // Ignore this block + BLOCK_KEYS = 1, // Block contains bonding keys. + BLOCK_SYS_ATTR = 2, // Block contains sys_attr values (CCCD settings, etc.). + BLOCK_UNUSED = 0xff, // Initial erased value. +} bonding_block_type_t; + +typedef struct { + uint16_t central:1; // 1 if data is for a central role. + uint16_t reserved: 7; // Not currently used + bonding_block_type_t type: 8; // What kind of data is stored in. + uint16_t ediv; // ediv value; used as a lookup key. + uint32_t data_length; // Length of data in bytes, including ediv, not including padding. + // data_length only needs to be 16 bits, but easier to write a word at a time. + uint8_t data[]; // Rest of data in the block. Needs to be 32-bit aligned. + // Block is padded to 32-bit alignment. +} bonding_block_t; + +STATIC inline size_t bonding_block_size(uint16_t data_length) { + // Round data size up to the nearest 32-bit address. + return sizeof(bonding_block_t) + ((data_length + 3) & 0x3); + + +void bonding_clear_keys(bonding_keys_t *bonding_keys) { + memset(bonding_keys, 0, sizeof(bonding_keys)); +} + +STATIC void bonding_erase_storage(void) { + // Erase all pages in the bonding area. + for(uint32_t page_address = BONDING_PAGES_START_ADDR; + page_address < BONDING_PAGES_END_ADDR; + page_address += FLASH_PAGE) { + nrf_nvmc_page_erase(page_address); + } + // Write marker words at the beginning and the end of the bonding area. + nrf_nvmc_write_word(BONDING_DATA_START_ADDR, BONDING_START_FLAG_ADDR); + nrf_nvmc_write_word(BONDING_DATA_END_ADDR, BONDING_END_FLAG_ADDR); + // First unused block is at the beginning. + bonding_unused_block = BONDING_DATA_START_ADDR; +} + +STATIC bonding_block_t *bonding_unused_block = NULL; + +void bonding_init(void) { + if (BONDING_START_BYTES != *((uint32_t *) BONDING_START_FLAG_ADDR) || + BONDING_END_BYTES != *((uint32_t *) BONDING_END_FLAG_ADDR)) { + bonding_erase_storage(); + } else { + bonding_unused_block = bonding_find_block(BLOCK_UNUSED, EDIV_INVALID); + } +} + +// Given NULL to start or block address, return the address of the next valid block. +// The last block returned is the unused block at the end. +// Return NULL if we have run off the end of the bonding space. +STATIC bonding_block_t *bonding_next_block(bonding_block_t *block) { + while (1) { + // Advance to next block. + if (block == NULL) { + // Return first block (which might be unused if block list is empty). + return BONDING_DATA_START_ADDR; + } else if (block->type == BLOCK_UNUSED) { + // Already at last block (the unused block). + return NULL; + } + + // Advance to next block. + block += (bonding_block_t *) ((uint8_t *) block + bonding_block_word_size(block->data_length)); + + } + if (block >= (bonding_block_t *) BONDING_DATA_END_ADDR) { + // Went past end of bonding space. + return NULL; + } + if (block.valid) { + // Found an empty or a valid block. + return block; + } + // Invalid block (was erased); try again. + } +} + +// Find the block with given type and ediv value. +// If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. +// If not found, return NULL. +STATIC bonding_block_t *bonding_find_block(bonding_block_type_t type, uint16_t ediv) { + bonding_block_t *block = NULL; + while (1) { + block = bonding_next_block(block); + if (block == NULL) { + return NULL; + } + if (block.type == BLOCK_UNUSED) { + return block; + } + if (type == block.type && ediv = block.ediv) { + return block; + } + } +} + +// Set the header word to all 0's, to mark the block as invalid. +// We don't change data_length, so we can still skip over this block. +STATIC void bonding_invalidate_block(bonding_block_t *block) { + nrf_nvmc_write_word((uint32_t) bonding_unused_block, 0x00000000); +} + +// Try to write a new block. If no room, erase everything and start again. +// TODO: could do garbage collection instead. +STATIC bool bonding_write_block(bonding_block_type_t type, uint16_t ediv, uint8_t *data, uint16_t data_length) { + size_t block_size = bonding_block_word_size(data_length); + if (block_size > BONDING_DATA_END_ADDR - BONDING_DATA_START_ADDR) { + // Ridiculous size. + return false; + } + + // No more room. Erase all existing bonding info and start over. + if (bonding_unused_block == NULL || bonding_unused_block + block_size >= BONDING_DATA_END_ADDR) { + bonding_erase_storage(); + } + + bonding_block_t block_without_data; + block_without_data.valid = 1; + block_without_data.type = type; + block_without_data.ediv = ediv; + block_without_data.data_length = data_length; + + // Write header data. + nrf_nvmc_write_words((uint32_t) bonding_unused_block, (uint32_t *) &block_without_data, + sizeof(block_without_data) / 4); + + // Write variable-length data. + // Minimize the number of writes. Datasheet says no more than two writes per word before erasing again. + uint32_t *word_p = (uint32_t) bonding_unused_block + sizeof(block_without_data); + while (1) { + uint32_t word = 0xffffffff; + memcpy(&word, data, data_length >= 4 ? 4 : data_length); + nrf_nvmc_write_word(word_p, word); + if (data_length <= 4) { + break; + } + data_length -= 4; + word_p++; + } + return true; +} + + + +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv, + uint8_t **sys_attr, uint16_t *sys_attr_len) { + bonding_block_t *block = bonding_find_matching_block(BLOCK_SYS_ATTR, ediv); + if (block) { + *sys_attr = block.data; + *sys_attr_len = block.data_length; + return true; + } else { + return false; + } +} + +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { + bonding_block_t *block = bonding_find_matching_block(BLOCK_SYS_ATTR, ediv); + if (block) { + memcpy(bonding_keys, block.data, block.data_length); + return true; + } else { + return false; + } +} + +bool bonding_save_cccd_info_later(bool is_central, uint16_t conn_handle, uint16_t ediv, uint8_t *sys_attr, uint16_t sys_attr_len) { + // save in id role/ediv + // sys_attr + +bool bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys) { + // save in id role/ediv: + // bonding keys + // peer name, or if no name, then human-readable address +} diff --git a/ports/nrf/common-hal/_bleio/bonding.h b/ports/nrf/common-hal/_bleio/bonding.h new file mode 100644 index 0000000000..906d9d1949 --- /dev/null +++ b/ports/nrf/common-hal/_bleio/bonding.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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. + */ + +#include +#include +#include + +#include "ble.h" +#include "ble_drv.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/nvm/ByteArray.h" + +#define EDIV_INVALID (0xffff) + +void bonding_clear_keys(bonding_keys_t *bonding_keys); +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys); +bool bonding_save_cccd_info_later(bool is_central, uint16_t conn_handle, uint16_t ediv, uint8_t *sys_attr, uint16_t sys_attr_len); +bool bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys); diff --git a/ports/nrf/common-hal/nvm/ByteArray.c b/ports/nrf/common-hal/nvm/ByteArray.c index 7d733ce7be..6b2f04a61b 100644 --- a/ports/nrf/common-hal/nvm/ByteArray.c +++ b/ports/nrf/common-hal/nvm/ByteArray.c @@ -36,21 +36,17 @@ uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { return self->len; } -static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) { +static bool write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) { // Write a whole page to flash, buffering it first and then erasing and rewriting // it since we can only clear a whole page at a time. - bool status; if (offset == 0 && len == FLASH_PAGE_SIZE) { - status = nrf_nvm_safe_flash_page_write(page_addr, bytes); + return nrf_nvm_safe_flash_page_write(page_addr, bytes); } else { uint8_t buffer[FLASH_PAGE_SIZE]; memcpy(buffer, (uint8_t *)page_addr, FLASH_PAGE_SIZE); memcpy(buffer + offset, bytes, len); - status = nrf_nvm_safe_flash_page_write(page_addr, buffer); - } - if (!status) { - mp_raise_OSError_msg(translate("Flash write failed")); + return nrf_nvm_safe_flash_page_write(page_addr, buffer); } } @@ -63,7 +59,9 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, while (len) { uint32_t write_len = MIN(len, FLASH_PAGE_SIZE - offset); - write_page(page_addr, offset, write_len, values); + if (!write_page(page_addr, offset, write_len, values)) { + return false; + } len -= write_len; values += write_len; page_addr += FLASH_PAGE_SIZE; diff --git a/ports/nrf/peripherals/nrf/nvm.c b/ports/nrf/peripherals/nrf/nvm.c index 7118b9c870..d13775d4dd 100644 --- a/ports/nrf/peripherals/nrf/nvm.c +++ b/ports/nrf/peripherals/nrf/nvm.c @@ -50,6 +50,12 @@ STATIC sd_flash_operation_status_t sd_flash_operation_wait_until_done(void) { } #endif +// The nRF52840 datasheet specifies a maximum of two writes to a flash +// location before an erase is necessary, even if the write is all +// ones (erased state). So we can't avoid erases even if the page +// appears to be already erased (all ones), unless we keep track of +// writes to a page. + bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { #ifdef BLUETOOTH_SD uint8_t sd_en = 0; diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py index 2199e9d395..90ea49ca43 100755 --- a/tools/preprocess_frozen_modules.py +++ b/tools/preprocess_frozen_modules.py @@ -47,6 +47,7 @@ def copy_and_process(in_dir, out_dir): output_file_path = Path(out_dir, input_file_path.relative_to(in_dir)) if file.endswith(".py"): + print(file) if not output_file_path.parent.exists(): output_file_path.parent.mkdir(parents=True) with input_file_path.open("r") as input, output_file_path.open("w") as output: From 6afb8dadbcc91562deb413638e2ef7e17f3305a6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 3 Jan 2020 15:14:37 -0800 Subject: [PATCH 273/531] Change SPI and I2C in the same way. --- ports/nrf/common-hal/busio/I2C.c | 9 +-------- ports/nrf/common-hal/busio/SPI.c | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index 7a079ff7f4..f6f686cdfe 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -63,7 +63,7 @@ void i2c_reset(void) { if (never_reset[i]) { continue; } - nrf_twim_disable(twim_peripherals[i].twim.p_twim); + nrfx_twim_uninit(&twim_peripherals[i].twim); twim_peripherals[i].in_use = false; } } @@ -150,13 +150,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * // About to init. If we fail after this point, common_hal_busio_i2c_deinit() will set in_use to false. self->twim_peripheral->in_use = true; nrfx_err_t err = nrfx_twim_init(&self->twim_peripheral->twim, &config, NULL, NULL); - - // A soft reset doesn't uninit the driver so we might end up with a invalid state - if (err == NRFX_ERROR_INVALID_STATE) { - nrfx_twim_uninit(&self->twim_peripheral->twim); - err = nrfx_twim_init(&self->twim_peripheral->twim, &config, NULL, NULL); - } - if (err != NRFX_SUCCESS) { common_hal_busio_i2c_deinit(self); mp_raise_OSError(MP_EIO); diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index d2977909e1..639bbcdd05 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -68,7 +68,7 @@ void spi_reset(void) { if (never_reset[i]) { continue; } - nrf_spim_disable(spim_peripherals[i].spim.p_reg); + nrfx_spim_uninit(&spim_peripherals[i].spim); } } @@ -160,13 +160,6 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * } nrfx_err_t err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL); - - // A soft reset doesn't uninit the driver so we might end up with a invalid state - if (err == NRFX_ERROR_INVALID_STATE) { - nrfx_spim_uninit(&self->spim_peripheral->spim); - err = nrfx_spim_init(&self->spim_peripheral->spim, &config, NULL, NULL); - } - if (err != NRFX_SUCCESS) { common_hal_busio_spi_deinit(self); mp_raise_OSError(MP_EIO); From f6ec1ea17284ce6874a79db1998df21b81bc4ebd Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 3 Jan 2020 15:15:36 -0800 Subject: [PATCH 274/531] Throw an error when we cannot allocate PWM pixel buffer --- ports/nrf/common-hal/neopixel_write/__init__.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index 3b67778a62..3052e908dd 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -130,7 +130,17 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout if (pattern_size <= sizeof(one_pixel)) { pixels_pattern = (uint16_t *) one_pixel; } else { - pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false); + uint8_t sd_en = 0; + (void) sd_softdevice_is_enabled(&sd_en); + if (sd_en) { + // If the soft device is enabled then we must use PWM to + // transmit. This takes a bunch of memory to do so raise an + // exception if we can't. + pixels_pattern = (uint16_t *) m_malloc(pattern_size, false); + } else { + pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false); + } + pattern_on_heap = true; } } From 82fb761c0f93152feb7cef0a177a160d370a8b6e Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 6 Dec 2019 12:27:46 -0800 Subject: [PATCH 275/531] Add PacketBuffer and MTU negotiation support. PacketBuffer facilitates packet oriented BLE protocols such as BLE MIDI and the Apple Media Service. This also adds PHY, MTU and connection event extension negotiation to speed up data transfer when possible. --- ports/nrf/bluetooth/ble_drv.c | 2 +- ports/nrf/boards/common.template.ld | 8 +- ports/nrf/common-hal/_bleio/Adapter.c | 60 +++- ports/nrf/common-hal/_bleio/Adapter.h | 2 +- ports/nrf/common-hal/_bleio/Characteristic.c | 2 +- ports/nrf/common-hal/_bleio/Connection.c | 41 ++- ports/nrf/common-hal/_bleio/Connection.h | 1 + ports/nrf/common-hal/_bleio/PacketBuffer.c | 331 +++++++++++++++++++ ports/nrf/common-hal/_bleio/PacketBuffer.h | 49 +++ ports/nrf/common-hal/_bleio/__init__.c | 3 + py/circuitpy_defns.mk | 1 + shared-bindings/_bleio/PacketBuffer.c | 201 +++++++++++ shared-bindings/_bleio/PacketBuffer.h | 43 +++ shared-bindings/_bleio/__init__.c | 5 +- 14 files changed, 726 insertions(+), 23 deletions(-) create mode 100644 ports/nrf/common-hal/_bleio/PacketBuffer.c create mode 100644 ports/nrf/common-hal/_bleio/PacketBuffer.h create mode 100644 shared-bindings/_bleio/PacketBuffer.c create mode 100644 shared-bindings/_bleio/PacketBuffer.h diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index 7dbb315826..28a265b7fe 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.c @@ -46,7 +46,7 @@ nrf_nvic_state_t nrf_nvic_state = { 0 }; volatile sd_flash_operation_status_t sd_flash_operation_status; __attribute__((aligned(4))) -static uint8_t m_ble_evt_buf[sizeof(ble_evt_t) + (BLE_GATT_ATT_MTU_DEFAULT)]; +static uint8_t m_ble_evt_buf[sizeof(ble_evt_t) + (BLE_GATTS_VAR_ATTR_LEN_MAX)]; void ble_drv_reset() { // Linked list items will be gc'd. diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index 931f95ee9e..b110e6052a 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -16,7 +16,13 @@ MEMORY FLASH_FATFS (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE} FLASH_BOOTLOADER (rx) : ORIGIN = ${BOOTLOADER_START_ADDR}, LENGTH = ${BOOTLOADER_SIZE} FLASH_BOOTLOADER_SETTINGS (r) : ORIGIN = ${BOOTLOADER_SETTINGS_START_ADDR}, LENGTH = ${BOOTLOADER_SETTINGS_SIZE} - RAM (xrw) : ORIGIN = 0x20004000, LENGTH = 0x03C000 /* 240 KiB */ + + + /* 0x2000000 - RAM:ORIGIN is reserved for Softdevice */ + /* SoftDevice 6.1.0 takes 0x7b78 bytes (30.86 kb) minimum with high ATT MTU. */ + /* To measure the minimum required amount of memory for given configuration, set this number + high enough to work and then check the mutation of the value done by sd_ble_enable. */ + RAM (xrw) : ORIGIN = 0x20000000 + 32K, LENGTH = 256K - 32K } /* produce a link error if there is not this amount of RAM for these sections */ diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index cee40a5a0c..b9b6d2e88f 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -67,7 +67,7 @@ STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { reset_into_safe_mode(NORDIC_SOFT_DEVICE_ASSERT); } -bleio_connection_internal_t connections[BLEIO_TOTAL_CONNECTION_COUNT]; +bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; // Linker script provided ram start. extern uint32_t _ram_start; @@ -133,6 +133,15 @@ STATIC uint32_t ble_stack_enable(void) { return err_code; } + // Set ATT_MTU so that the maximum MTU we can negotiate is up to the full characteristic size. + memset(&ble_conf, 0, sizeof(ble_conf)); + ble_conf.conn_cfg.conn_cfg_tag = BLE_CONN_CFG_TAG_CUSTOM; + ble_conf.conn_cfg.params.gatt_conn_cfg.att_mtu = BLE_GATTS_VAR_ATTR_LEN_MAX; + err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_conf, app_ram_start); + if (err_code != NRF_SUCCESS) { + return err_code; + } + // Triple the GATT Server attribute size to accomodate both the CircuitPython built-in service // and anything the user does. memset(&ble_conf, 0, sizeof(ble_conf)); @@ -142,7 +151,14 @@ STATIC uint32_t ble_stack_enable(void) { return err_code; } - // TODO set ATT_MTU so that the maximum MTU we can negotiate is higher than the default. + // Increase the number of vendor UUIDs supported. Apple uses a complete random number per + // service and characteristic. + memset(&ble_conf, 0, sizeof(ble_conf)); + ble_conf.common_cfg.vs_uuid_cfg.vs_uuid_count = 32; // Defaults to 10. + err_code = sd_ble_cfg_set(BLE_COMMON_CFG_VS_UUID, &ble_conf, app_ram_start); + if (err_code != NRF_SUCCESS) { + return err_code; + } // This sets app_ram_start to the minimum value needed for the settings set above. err_code = sd_ble_enable(&app_ram_start); @@ -150,6 +166,14 @@ STATIC uint32_t ble_stack_enable(void) { return err_code; } + // Turn on connection event extension so we can transmit for a longer period of time as needed. + ble_opt_t opt; + opt.common_opt.conn_evt_ext.enable = true; + err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt); + if (err_code != NRF_SUCCESS) { + return err_code; + } + ble_gap_conn_params_t gap_conn_params = { .min_conn_interval = BLE_MIN_CONN_INTERVAL, .max_conn_interval = BLE_MAX_CONN_INTERVAL, @@ -177,7 +201,7 @@ STATIC bool adapter_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // total connection limit. bleio_connection_internal_t *connection; for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - connection = &connections[i]; + connection = &bleio_connections[i]; if (connection->conn_handle == BLE_CONN_HANDLE_INVALID) { break; } @@ -189,6 +213,7 @@ STATIC bool adapter_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { connection->conn_handle = ble_evt->evt.gap_evt.conn_handle; connection->connection_obj = mp_const_none; connection->pair_status = PAIR_NOT_PAIRED; + connection->mtu = 0; ble_drv_add_event_handler_entry(&connection->handler_entry, connection_on_ble_evt, connection); self->connection_objs = NULL; @@ -216,7 +241,7 @@ STATIC bool adapter_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // Find the connection that was disconnected. bleio_connection_internal_t *connection; for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - connection = &connections[i]; + connection = &bleio_connections[i]; if (connection->conn_handle == ble_evt->evt.gap_evt.conn_handle) { break; } @@ -293,7 +318,7 @@ void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enable // Add a handler for incoming peripheral connections. if (enabled) { for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - bleio_connection_internal_t *connection = &connections[i]; + bleio_connection_internal_t *connection = &bleio_connections[i]; connection->conn_handle = BLE_CONN_HANDLE_INVALID; } bleio_adapter_reset_name(self); @@ -497,14 +522,25 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre ble_drv_remove_event_handler(connect_on_ble_evt, &event_info); - if (event_info.conn_handle == BLE_CONN_HANDLE_INVALID) { + uint16_t conn_handle = event_info.conn_handle; + if (conn_handle == BLE_CONN_HANDLE_INVALID) { mp_raise_bleio_BluetoothError(translate("Failed to connect: timeout")); } + // Negotiate for better PHY, larger MTU and data lengths since we are the central. These are + // nice-to-haves so ignore any errors. + ble_gap_phys_t const phys = { + .rx_phys = BLE_GAP_PHY_AUTO, + .tx_phys = BLE_GAP_PHY_AUTO, + }; + sd_ble_gap_phy_update(conn_handle, &phys); + sd_ble_gattc_exchange_mtu_request(conn_handle, BLE_GATTS_VAR_ATTR_LEN_MAX); + sd_ble_gap_data_length_update(conn_handle, NULL, NULL); + // Make the connection object and return it. for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - bleio_connection_internal_t *connection = &connections[i]; - if (connection->conn_handle == event_info.conn_handle) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle == conn_handle) { return bleio_connection_new_from_internal(connection); } } @@ -628,7 +664,7 @@ void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) { bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self) { for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - bleio_connection_internal_t *connection = &connections[i]; + bleio_connection_internal_t *connection = &bleio_connections[i]; if (connection->conn_handle != BLE_CONN_HANDLE_INVALID) { return true; } @@ -643,7 +679,7 @@ mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self) { size_t total_connected = 0; mp_obj_t items[BLEIO_TOTAL_CONNECTION_COUNT]; for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - bleio_connection_internal_t *connection = &connections[i]; + bleio_connection_internal_t *connection = &bleio_connections[i]; if (connection->conn_handle != BLE_CONN_HANDLE_INVALID) { if (connection->connection_obj == mp_const_none) { connection->connection_obj = bleio_connection_new_from_internal(connection); @@ -658,7 +694,7 @@ mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self) { void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter) { gc_collect_root((void**)adapter, sizeof(bleio_adapter_obj_t) / sizeof(size_t)); - gc_collect_root((void**)connections, sizeof(connections) / sizeof(size_t)); + gc_collect_root((void**)bleio_connections, sizeof(bleio_connections) / sizeof(size_t)); } void bleio_adapter_reset(bleio_adapter_obj_t* adapter) { @@ -666,7 +702,7 @@ void bleio_adapter_reset(bleio_adapter_obj_t* adapter) { common_hal_bleio_adapter_stop_advertising(adapter); adapter->connection_objs = NULL; for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - bleio_connection_internal_t *connection = &connections[i]; + bleio_connection_internal_t *connection = &bleio_connections[i]; connection->connection_obj = mp_const_none; } } diff --git a/ports/nrf/common-hal/_bleio/Adapter.h b/ports/nrf/common-hal/_bleio/Adapter.h index dca4439908..2ac568d661 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.h +++ b/ports/nrf/common-hal/_bleio/Adapter.h @@ -37,7 +37,7 @@ #define BLEIO_TOTAL_CONNECTION_COUNT 2 -extern bleio_connection_internal_t connections[BLEIO_TOTAL_CONNECTION_COUNT]; +extern bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; typedef struct { mp_obj_base_t base; diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index 9f1255e32f..c7eec94c0d 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -154,7 +154,7 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, common_hal_bleio_gatts_write(self->handle, BLE_CONN_HANDLE_INVALID, bufinfo); // Check to see if we need to notify or indicate any active connections. for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { - bleio_connection_internal_t *connection = &connections[i]; + bleio_connection_internal_t *connection = &bleio_connections[i]; uint16_t conn_handle = connection->conn_handle; if (connection->conn_handle == BLE_CONN_HANDLE_INVALID) { continue; diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index e0b50901ad..daf5b937b8 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -85,6 +85,7 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { switch (ble_evt->header.evt_id) { case BLE_GAP_EVT_DISCONNECTED: break; + case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { ble_gap_phys_t const phys = { .rx_phys = BLE_GAP_PHY_AUTO, @@ -94,20 +95,45 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } - case BLE_GAP_EVT_PHY_UPDATE: // 0x22 + case BLE_GAP_EVT_PHY_UPDATE: { // 0x22 break; + } case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: // SoftDevice will respond to a length update request. sd_ble_gap_data_length_update(self->conn_handle, NULL, NULL); break; - case BLE_GAP_EVT_DATA_LENGTH_UPDATE: // 0x24 + case BLE_GAP_EVT_DATA_LENGTH_UPDATE: { // 0x24 break; + } case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: { - // We only handle MTU of size BLE_GATT_ATT_MTU_DEFAULT. - sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); + ble_gatts_evt_exchange_mtu_request_t *request = + &ble_evt->evt.gatts_evt.params.exchange_mtu_request; + + uint16_t new_mtu = BLE_GATTS_VAR_ATTR_LEN_MAX; + if (request->client_rx_mtu < new_mtu) { + new_mtu = request->client_rx_mtu; + } + if (new_mtu < BLE_GATT_ATT_MTU_DEFAULT) { + new_mtu = BLE_GATT_ATT_MTU_DEFAULT; + } + if (self->mtu > 0) { + new_mtu = self->mtu; + } + + self->mtu = new_mtu; + sd_ble_gatts_exchange_mtu_reply(self->conn_handle, new_mtu); + break; + } + + + case BLE_GATTC_EVT_EXCHANGE_MTU_RSP: { + ble_gattc_evt_exchange_mtu_rsp_t *response = + &ble_evt->evt.gattc_evt.params.exchange_mtu_rsp; + + self->mtu = response->server_rx_mtu; break; } @@ -319,8 +345,11 @@ STATIC bool discover_next_services(bleio_connection_internal_t* connection, uint m_discovery_successful = false; m_discovery_in_process = true; - check_nrf_error(sd_ble_gattc_primary_services_discover(connection->conn_handle, - start_handle, service_uuid)); + uint32_t nrf_err = NRF_ERROR_BUSY; + while (nrf_err == NRF_ERROR_BUSY) { + nrf_err = sd_ble_gattc_primary_services_discover(connection->conn_handle, start_handle, service_uuid); + } + check_nrf_error(nrf_err); // Wait for a discovery event. while (m_discovery_in_process) { diff --git a/ports/nrf/common-hal/_bleio/Connection.h b/ports/nrf/common-hal/_bleio/Connection.h index 1474a0a6c0..61bbea4a1b 100644 --- a/ports/nrf/common-hal/_bleio/Connection.h +++ b/ports/nrf/common-hal/_bleio/Connection.h @@ -65,6 +65,7 @@ typedef struct { ble_drv_evt_handler_entry_t handler_entry; ble_gap_conn_params_t conn_params; volatile bool conn_params_updating; + uint16_t mtu; } bleio_connection_internal_t; typedef struct { diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c new file mode 100644 index 0000000000..fbcc72a6aa --- /dev/null +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c @@ -0,0 +1,331 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-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 +#include + +#include "ble_drv.h" +#include "ble_gatts.h" +#include "nrf_nvic.h" + +#include "lib/utils/interrupt_char.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "tick.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/PacketBuffer.h" +#include "supervisor/shared/tick.h" + +STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, uint8_t *data, uint16_t len) { + if (len + sizeof(uint16_t) > self->ringbuf.size) { + // This shouldn't happen. + return; + } + // Push all the data onto the ring buffer. + uint8_t is_nested_critical_region; + sd_nvic_critical_region_enter(&is_nested_critical_region); + // Make room for the new value by dropping the oldest packets first. + while (self->ringbuf.size - ringbuf_count(&self->ringbuf) < (int) (len + sizeof(uint16_t))) { + uint16_t packet_length; + ringbuf_get_n(&self->ringbuf, (uint8_t*) &packet_length, sizeof(uint16_t)); + for (uint16_t i = 0; i < packet_length; i++) { + ringbuf_get(&self->ringbuf); + } + // set an overflow flag? + } + ringbuf_put_n(&self->ringbuf, (uint8_t*) &len, sizeof(uint16_t)); + ringbuf_put_n(&self->ringbuf, data, len); + sd_nvic_critical_region_exit(is_nested_critical_region); +} + +STATIC uint32_t queue_next_write(bleio_packet_buffer_obj_t *self) { + self->packet_queued = false; + if (self->pending_size > 0) { + uint16_t conn_handle = self->conn_handle; + uint32_t err_code; + if (self->client) { + ble_gattc_write_params_t write_params = { + .write_op = self->write_type, + .handle = self->characteristic->handle, + .p_value = self->outgoing[self->pending_index], + .len = self->pending_size, + }; + + err_code = sd_ble_gattc_write(conn_handle, &write_params); + } else { + uint16_t hvx_len = self->pending_size; + + ble_gatts_hvx_params_t hvx_params = { + .handle = self->characteristic->handle, + .type = self->write_type, + .offset = 0, + .p_len = &hvx_len, + .p_data = self->outgoing[self->pending_index], + }; + err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params); + } + if (err_code != NRF_SUCCESS) { + // On error, simply skip updating the pending buffers so that the next HVC or WRITE + // complete event triggers another attempt. + return err_code; + } + self->pending_size = 0; + self->pending_index = (self->pending_index + 1) % 2; + self->packet_queued = true; + } + return NRF_SUCCESS; +} + +STATIC bool packet_buffer_on_ble_client_evt(ble_evt_t *ble_evt, void *param) { + bleio_packet_buffer_obj_t *self = (bleio_packet_buffer_obj_t *) param; + uint16_t conn_handle = ble_evt->evt.gattc_evt.conn_handle; + if (conn_handle != self->conn_handle) { + return false; + } + switch (ble_evt->header.evt_id) { + case BLE_GATTC_EVT_HVX: { + // A remote service wrote to this characteristic. + ble_gattc_evt_hvx_t* evt_hvx = &ble_evt->evt.gattc_evt.params.hvx; + // Must be a notification, and event handle must match the handle for my characteristic. + if (evt_hvx->handle == self->characteristic->handle) { + write_to_ringbuf(self, evt_hvx->data, evt_hvx->len); + if (evt_hvx->type == BLE_GATT_HVX_INDICATION) { + sd_ble_gattc_hv_confirm(conn_handle, evt_hvx->handle); + } + } + break; + } + case BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE: { + queue_next_write(self); + break; + } + case BLE_GATTC_EVT_WRITE_RSP: { + queue_next_write(self); + break; + } + default: + return false; + break; + } + return true; +} + +STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) { + bleio_packet_buffer_obj_t *self = (bleio_packet_buffer_obj_t *) param; + uint16_t conn_handle = ble_evt->evt.gatts_evt.conn_handle; + switch (ble_evt->header.evt_id) { + case BLE_GATTS_EVT_WRITE: { + // A client wrote to this server characteristic. + + ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write; + // Event handle must match the handle for my characteristic. + if (evt_write->handle == self->characteristic->handle) { + if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { + self->conn_handle = conn_handle; + } else if (self->conn_handle != conn_handle) { + return false; + } + write_to_ringbuf(self, evt_write->data, evt_write->len); + } else if (evt_write->handle == self->characteristic->cccd_handle && + self->conn_handle == BLE_CONN_HANDLE_INVALID) { + uint16_t cccd = *((uint16_t*) evt_write->data); + if (cccd & BLE_GATT_HVX_NOTIFICATION) { + self->conn_handle = conn_handle; + } else { + self->conn_handle = BLE_CONN_HANDLE_INVALID; + } + } + break; + } + case BLE_GATTS_EVT_HVN_TX_COMPLETE: { + queue_next_write(self); + } + default: + return false; + break; + } + return true; +} + +void common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + size_t buffer_size) { + + self->characteristic = characteristic; + self->client = self->characteristic->service->is_remote; + bleio_characteristic_properties_t incoming = self->characteristic->props & (CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE); + bleio_characteristic_properties_t outgoing = self->characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE); + + if (self->client) { + // Swap if we're the client. + bleio_characteristic_properties_t temp = incoming; + incoming = outgoing; + outgoing = temp; + self->conn_handle = bleio_connection_get_conn_handle(MP_OBJ_TO_PTR(self->characteristic->service->connection)); + } + + if (incoming) { + // This is a macro. + ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + characteristic->max_length), false); + + if (self->ringbuf.buf == NULL) { + mp_raise_ValueError(translate("Buffer too large and unable to allocate")); + } + } + + if (outgoing) { + self->packet_queued = false; + self->pending_index = 0; + self->pending_size = 0; + self->outgoing[0] = m_malloc(characteristic->max_length, false); + self->outgoing[1] = m_malloc(characteristic->max_length, false); + } else { + self->outgoing[0] = NULL; + self->outgoing[1] = NULL; + } + + if (self->client) { + ble_drv_add_event_handler(packet_buffer_on_ble_client_evt, self); + if (incoming) { + // Prefer notify if both are available. + if (incoming & CHAR_PROP_NOTIFY) { + self->write_type = BLE_GATT_HVX_NOTIFICATION; + common_hal_bleio_characteristic_set_cccd(self->characteristic, true, false); + } else { + common_hal_bleio_characteristic_set_cccd(self->characteristic, false, true); + } + } + if (outgoing) { + self->write_type = BLE_GATT_OP_WRITE_REQ; + if (outgoing & CHAR_PROP_WRITE_NO_RESPONSE) { + self->write_type = BLE_GATT_OP_WRITE_CMD; + } + } + } else { + ble_drv_add_event_handler(packet_buffer_on_ble_server_evt, self); + if (outgoing) { + self->write_type = BLE_GATT_HVX_INDICATION; + if (outgoing & CHAR_PROP_NOTIFY) { + self->write_type = BLE_GATT_HVX_NOTIFICATION; + } + } + } +} + +int common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len) { + if (ringbuf_count(&self->ringbuf) < 2) { + return 0; + } + + uint16_t packet_length; + ringbuf_get_n(&self->ringbuf, (uint8_t*) &packet_length, sizeof(uint16_t)); + + // Copy received data. Lock out write interrupt handler while copying. + uint8_t is_nested_critical_region; + sd_nvic_critical_region_enter(&is_nested_critical_region); + + if (packet_length > len) { + // TODO: raise an exception. + packet_length = len; + } + + ringbuf_get_n(&self->ringbuf, data, packet_length); + + // Writes now OK. + sd_nvic_critical_region_exit(is_nested_critical_region); + + return packet_length; +} + +void common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len, uint8_t* header, size_t header_len) { + if (self->outgoing[0] == NULL) { + mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic")); + } + if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { + return; + } + uint16_t packet_size = common_hal_bleio_packet_buffer_get_packet_size(self); + uint16_t max_size = packet_size - len; + while (max_size < self->pending_size && self->conn_handle != BLE_CONN_HANDLE_INVALID) { + RUN_BACKGROUND_TASKS; + } + if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { + return; + } + uint8_t is_nested_critical_region; + sd_nvic_critical_region_enter(&is_nested_critical_region); + + uint8_t* pending = self->outgoing[self->pending_index]; + + if (self->pending_size == 0) { + memcpy(pending, header, header_len); + self->pending_size += header_len; + } + memcpy(pending + self->pending_size, data, len); + self->pending_size += len; + + sd_nvic_critical_region_exit(is_nested_critical_region); + + // If no writes are queued then sneak in this data. + if (!self->packet_queued) { + queue_next_write(self); + } +} + +uint16_t common_hal_bleio_packet_buffer_get_packet_size(bleio_packet_buffer_obj_t *self) { + uint16_t mtu; + if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { + return 0; + } + bleio_connection_internal_t *connection; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + connection = &bleio_connections[i]; + if (connection->conn_handle == self->conn_handle) { + break; + } + } + if (connection->mtu == 0) { + mtu = 23; + } + if (self->characteristic->max_length > mtu) { + mtu = self->characteristic->max_length; + } + uint16_t att_overhead = 3; + return mtu - att_overhead; +} + +bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { + return self->characteristic == NULL; +} + +void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self) { + if (!common_hal_bleio_packet_buffer_deinited(self)) { + ble_drv_remove_event_handler(packet_buffer_on_ble_client_evt, self); + } +} diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.h b/ports/nrf/common-hal/_bleio/PacketBuffer.h new file mode 100644 index 0000000000..7a090f539c --- /dev/null +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-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. + */ + +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PACKETBUFFER_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PACKETBUFFER_H + +#include "nrf_soc.h" + +#include "py/ringbuf.h" +#include "shared-bindings/_bleio/Characteristic.h" + +typedef struct { + mp_obj_base_t base; + bleio_characteristic_obj_t *characteristic; + // Ring buffer storing consecutive incoming values. + ringbuf_t ringbuf; + uint8_t* outgoing[2]; + uint16_t pending_size; + uint16_t conn_handle; + uint8_t pending_index; + uint8_t write_type; + bool client; + bool packet_queued; +} bleio_packet_buffer_obj_t; + +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PACKETBUFFER_H diff --git a/ports/nrf/common-hal/_bleio/__init__.c b/ports/nrf/common-hal/_bleio/__init__.c index 4b2780dedc..8606c89ec1 100644 --- a/ports/nrf/common-hal/_bleio/__init__.c +++ b/ports/nrf/common-hal/_bleio/__init__.c @@ -48,6 +48,9 @@ void check_nrf_error(uint32_t err_code) { case NRF_ERROR_TIMEOUT: mp_raise_msg(&mp_type_TimeoutError, NULL); return; + case BLE_ERROR_INVALID_CONN_HANDLE: + mp_raise_bleio_ConnectionError(translate("Not connected")); + return; default: mp_raise_bleio_BluetoothError(translate("Unknown soft device error: %04x"), err_code); break; diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 8dd4fc6b16..35a9779464 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -236,6 +236,7 @@ SRC_COMMON_HAL_ALL = \ _bleio/CharacteristicBuffer.c \ _bleio/Connection.c \ _bleio/Descriptor.c \ + _bleio/PacketBuffer.c \ _bleio/Service.c \ _bleio/UUID.c \ analogio/AnalogIn.c \ diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c new file mode 100644 index 0000000000..f9f171870b --- /dev/null +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -0,0 +1,201 @@ +/* + * 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. + */ + +#include "py/mperrno.h" +#include "py/ioctl.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/PacketBuffer.h" +#include "shared-bindings/_bleio/UUID.h" +#include "shared-bindings/util.h" + +//| .. currentmodule:: _bleio +//| +//| :class:`PacketBuffer` -- Packet-oriented characteristic usage. +//| ===================================================================== +//| +//| Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware +//| outgoing writes. A packet's size is either the characteristic length or the maximum transmission +//| unit (MTU), whichever is smaller. The MTU can change so check `packet_size` before creating a +//| buffer to store data. +//| +//| When we're the server, we ignore all connections besides the first to subscribe to +//| notifications. +//| +//| .. class:: PacketBuffer(characteristic, *, buffer_size) +//| +//| Monitor the given Characteristic. Each time a new value is written to the Characteristic +//| add the newly-written bytes to a FIFO buffer. +//| +//| :param Characteristic characteristic: The Characteristic to monitor. +//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic +//| in a remote Service that a Central has connected to. +//| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum +//| length) that stores incoming packets coming from the peer. +//| +STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_characteristic, ARG_buffer_size }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_buffer_size, MP_ARG_KW_ONLY | 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); + + const mp_obj_t characteristic = args[ARG_characteristic].u_obj; + + const int buffer_size = args[ARG_buffer_size].u_int; + if (buffer_size < 1) { + mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_buffer_size); + } + + if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) { + mp_raise_TypeError(translate("Expected a Characteristic")); + } + + bleio_packet_buffer_obj_t *self = m_new_obj(bleio_packet_buffer_obj_t); + self->base.type = &bleio_packet_buffer_type; + + common_hal_bleio_packet_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), buffer_size); + + return MP_OBJ_FROM_PTR(self); +} + +STATIC void check_for_deinit(bleio_packet_buffer_obj_t *self) { + if (common_hal_bleio_packet_buffer_deinited(self)) { + raise_deinited_error(); + } +} + +//| .. method:: readinto(buf) +//| +//| Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer +//| than the given buffer. Use `packet_size` to read the maximum length of a single packet. +//| +//| :return: number of bytes read and stored into ``buf`` +//| :rtype: int +//| +STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_obj) { + bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer_obj, &bufinfo, MP_BUFFER_WRITE); + + return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_packet_buffer_readinto(self, bufinfo.buf, bufinfo.len)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_buffer_readinto); + +//| .. method:: write(data, *, header=None) +//| +//| Writes all bytes from data into the same outgoing packet. The bytes from header are included +//| before data when the pending packet is currently empty. +//| +//| This does not block until the data is sent. It only blocks until the data is pending. +//| +// TODO: Add a kwarg `merge=False` to dictate whether subsequent writes are merged into a pending +// one. +STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_data, ARG_header }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_header, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + }; + + 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); + + bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + check_for_deinit(self); + + mp_buffer_info_t data_bufinfo; + mp_get_buffer_raise(args[ARG_data].u_obj, &data_bufinfo, MP_BUFFER_READ); + + mp_buffer_info_t header_bufinfo; + header_bufinfo.len = 0; + if (args[ARG_header].u_obj != MP_OBJ_NULL) { + mp_get_buffer_raise(args[ARG_header].u_obj, &header_bufinfo, MP_BUFFER_READ); + } + + common_hal_bleio_packet_buffer_write(self, data_bufinfo.buf, data_bufinfo.len, + header_bufinfo.buf, header_bufinfo.len); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet_buffer_write); + +//| .. method:: deinit() +//| +//| Disable permanently. +//| +STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { + bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_bleio_packet_buffer_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_buffer_deinit); + +//| .. attribute:: packet_size +//| +//| Maximum size of each packet in bytes. This is the minimum of the Characterstic length and +//| the negotiated Maximum Transfer Unit (MTU). +//| +STATIC mp_obj_t bleio_packet_buffer_get_packet_size(mp_obj_t self_in) { + bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_bool(common_hal_bleio_packet_buffer_get_packet_size(self)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_get_packet_size_obj, bleio_packet_buffer_get_packet_size); + +const mp_obj_property_t bleio_packet_buffer_packet_size_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_packet_buffer_get_packet_size_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC const mp_rom_map_elem_t bleio_packet_buffer_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bleio_packet_buffer_deinit_obj) }, + + // Standard stream methods. + { MP_OBJ_NEW_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&bleio_packet_buffer_readinto_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_write), MP_ROM_PTR(&bleio_packet_buffer_write_obj) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_packet_size), MP_ROM_PTR(&bleio_packet_buffer_packet_size_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(bleio_packet_buffer_locals_dict, bleio_packet_buffer_locals_dict_table); + + +const mp_obj_type_t bleio_packet_buffer_type = { + { &mp_type_type }, + .name = MP_QSTR_PacketBuffer, + .make_new = bleio_packet_buffer_make_new, + .locals_dict = (mp_obj_dict_t*)&bleio_packet_buffer_locals_dict +}; diff --git a/shared-bindings/_bleio/PacketBuffer.h b/shared-bindings/_bleio/PacketBuffer.h new file mode 100644 index 0000000000..990a2f8bb0 --- /dev/null +++ b/shared-bindings/_bleio/PacketBuffer.h @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PACKETBUFFER_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PACKETBUFFER_H + +#include "common-hal/_bleio/PacketBuffer.h" + +extern const mp_obj_type_t bleio_packet_buffer_type; + +extern void common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + size_t buffer_size); +void common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len, uint8_t* header, size_t header_len); +int common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len); +uint16_t common_hal_bleio_packet_buffer_get_packet_size(bleio_packet_buffer_obj_t *self); +bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self); +void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PACKETBUFFER_H diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index ba2454da45..5d26862a64 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -35,6 +35,7 @@ #include "shared-bindings/_bleio/CharacteristicBuffer.h" #include "shared-bindings/_bleio/Connection.h" #include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/PacketBuffer.h" #include "shared-bindings/_bleio/ScanEntry.h" #include "shared-bindings/_bleio/ScanResults.h" #include "shared-bindings/_bleio/Service.h" @@ -69,6 +70,7 @@ //| CharacteristicBuffer //| Connection //| Descriptor +//| PacketBuffer //| ScanEntry //| ScanResults //| Service @@ -140,8 +142,9 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) }, { MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) }, { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, + { MP_ROM_QSTR(MP_QSTR_PacketBuffer), MP_ROM_PTR(&bleio_packet_buffer_type) }, { MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&bleio_scanentry_type) }, - { MP_ROM_QSTR(MP_QSTR_ScanResults), MP_ROM_PTR(&bleio_scanresults_type) }, + { MP_ROM_QSTR(MP_QSTR_ScanResults), MP_ROM_PTR(&bleio_scanresults_type) }, { MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&bleio_service_type) }, { MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&bleio_uuid_type) }, From d2b2cf0addd3476256d34cde4df2f53f6a2868a9 Mon Sep 17 00:00:00 2001 From: Marius-450 Date: Sat, 4 Jan 2020 12:20:32 -0500 Subject: [PATCH 276/531] CIRCUITPY_DISPLAY_LIMIT = 2 --- py/circuitpy_mpconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 932d4f855f..95f1056dbb 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -328,7 +328,7 @@ extern const struct _mp_obj_module_t terminalio_module; #define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module }, #define FONTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_fontio), (mp_obj_t)&fontio_module }, #define TERMINALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_terminalio), (mp_obj_t)&terminalio_module }, -#define CIRCUITPY_DISPLAY_LIMIT (1) +#define CIRCUITPY_DISPLAY_LIMIT (2) #else #define DISPLAYIO_MODULE #define FONTIO_MODULE From 3ad3d49959271b4b33950d9d68daf1b9a722c95f Mon Sep 17 00:00:00 2001 From: Marius-450 Date: Sat, 4 Jan 2020 12:32:49 -0500 Subject: [PATCH 277/531] changes only for monster m4sk --- ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h | 7 +++++++ py/circuitpy_mpconfig.h | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h index 42fb4548e0..4bd01706df 100644 --- a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h +++ b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h @@ -19,3 +19,10 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 + +// Enable the use of 2 displays + +#define CIRCUITPY_DISPLAY_LIMIT (2) + + + diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 95f1056dbb..8c7454cf26 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -328,7 +328,9 @@ extern const struct _mp_obj_module_t terminalio_module; #define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module }, #define FONTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_fontio), (mp_obj_t)&fontio_module }, #define TERMINALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_terminalio), (mp_obj_t)&terminalio_module }, -#define CIRCUITPY_DISPLAY_LIMIT (2) +#ifndef CIRCUITPY_DISPLAY_LIMIT +#define CIRCUITPY_DISPLAY_LIMIT (1) +#endif #else #define DISPLAYIO_MODULE #define FONTIO_MODULE From 36088becc953fe1a417833dd6d243622d6f95de0 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Sat, 4 Jan 2020 13:35:53 -0500 Subject: [PATCH 278/531] PWM Fix, plus debugging --- ports/stm32f4/Makefile | 5 + ports/stm32f4/boards/meowbit_v121/pins.c | 6 +- ports/stm32f4/common-hal/pulseio/PWMOut.c | 201 +++++++++++++++--- .../peripherals/stm32f4/stm32f401xe/periph.h | 6 +- .../peripherals/stm32f4/stm32f401xe/pins.h | 6 +- ports/stm32f4/supervisor/port.c | 11 - 6 files changed, 186 insertions(+), 49 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 3943944ccb..cb2cdd8d37 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -85,6 +85,11 @@ ifeq ($(DEBUG), 1) CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -Os -DNDEBUG + CFLAGS += -ggdb +# CFLAGS += -fno-inline -fno-ipa-sra + + + #CFLAGS += -Os -DNDEBUG # TODO: Test with -flto ### CFLAGS += -flto endif diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 7b896bd70b..1216f4a80e 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -10,7 +10,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_PA08) }, { MP_ROM_QSTR(MP_QSTR_DISP_RST), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) }, //what is this, backlight? + { MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) }, //what is this, backlight? { MP_ROM_QSTR(MP_QSTR_BUZZ), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_BTNA), MP_ROM_PTR(&pin_PB09) }, @@ -32,8 +32,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, - // { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PC06) }, //these are wrong on Meowbit diagram. - // { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA03) }, //they cannot be used together (UART2 vs 6) + // { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PC06) }, //these are wrong on Meowbit diagram. + // { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA03) }, //they cannot be used together (UART2 vs 6) { MP_ROM_QSTR(MP_QSTR_NSS), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PC12) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PC11) }, diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 301f8cd499..5bb34b7c0e 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -26,6 +26,7 @@ */ #include +#include //add #include "py/runtime.h" #include "common-hal/pulseio/PWMOut.h" #include "shared-bindings/pulseio/PWMOut.h" @@ -88,6 +89,7 @@ STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, } void pwmout_reset(void) { + mp_printf(&mp_plat_print, "reset\n"); uint16_t never_reset_mask = 0x00; for(int i=0;inumber); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -194,63 +200,195 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = self->tim->altfn_index; HAL_GPIO_Init(pin_port(pin->port), &GPIO_InitStruct); + mp_printf(&mp_plat_print, "Good GPIO init\n"); + + // __HAL_RCC_GPIOA_CLK_ENABLE(); + // /**TIM2 GPIO Configuration + // PA1 ------> TIM2_CH2 + // */ + // GPIO_InitTypeDef GPIO_InitStruct = {0}; + // GPIO_InitStruct.Pin = GPIO_PIN_1; + // GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + // GPIO_InitStruct.Pull = GPIO_NOPULL; + // GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + // GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + // HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + + mp_printf(&mp_plat_print, "PWM Pin:%d Port:%d\n", pin->number, pin->port); + + + + +//OG tim_clock_enable(1<<(self->tim->tim_index - 1)); - //translate channel into handle value + //__HAL_RCC_TIM2_CLK_ENABLE(); + + mp_printf(&mp_plat_print, "Good clock init\n"); + + + +//OG + // //translate channel into handle value self->channel = 4 * (self->tim->channel_index - 1); - uint32_t prescaler = 0; //prescaler is 15 bit - uint32_t period = 0; //period is 16 bit - timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index)); - - mp_printf(&mp_plat_print, "Per:%d presc:%d\n", period, prescaler); - - //Timer init - self->handle.Instance = TIMx; - self->handle.Init.Period = period - 1; - self->handle.Init.Prescaler = prescaler - 1; + // uint32_t prescaler = 0; //prescaler is 15 bit + // uint32_t period = 0; //period is 16 bit + // timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index)); + // //Timer init + self->handle.Instance = TIM2; //TIMx; + self->handle.Init.Period = 8749;//period - 1; + self->handle.Init.Prescaler = 0;//prescaler - 1; self->handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; self->handle.Init.CounterMode = TIM_COUNTERMODE_UP; - self->handle.Init.RepetitionCounter = 0; - + self->handle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + //self->handle.Init.RepetitionCounter = 0; //only run init if this is the first instance of this timer - if (first_time_setup) { + // if (first_time_setup) { if (HAL_TIM_PWM_Init(&self->handle) != HAL_OK) { mp_raise_ValueError(translate("Could not initialize timer")); } + // } + + /* USER CODE END TIM2_Init 1 */ + // TIM_HandleTypeDef htim2; + // htim2.Instance = TIM2; + // htim2.Init.Prescaler = 0; + // htim2.Init.CounterMode = TIM_COUNTERMODE_UP; + // htim2.Init.Period = 8749; + // htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + // htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + // if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) + // { + // mp_raise_ValueError(translate("Could not start PWM1")); + // } + +//OG not needed + TIM_MasterConfigTypeDef sMasterConfig = {0}; + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&self->handle, &sMasterConfig) != HAL_OK) + { + mp_raise_ValueError(translate("Internal Error")); } - //Channel/PWM init +//OG + // //Channel/PWM init + //memset(&(self->chan_handle), 0, sizeof(TIM_OC_InitTypeDef)); //doesn't seem to affect it + self->chan_handle.OCNPolarity = 0; + self->chan_handle.OCIdleState = 0; + self->chan_handle.OCNIdleState = 0; self->chan_handle.OCMode = TIM_OCMODE_PWM1; - self->chan_handle.Pulse = timer_get_internal_duty(duty, period); - self->chan_handle.OCPolarity = TIM_OCPOLARITY_LOW; + self->chan_handle.Pulse = 7000; + self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH; self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE; - self->chan_handle.OCNPolarity = TIM_OCNPOLARITY_LOW; // needed for TIM1 and TIM8 - self->chan_handle.OCIdleState = TIM_OCIDLESTATE_SET; // needed for TIM1 and TIM8 - self->chan_handle.OCNIdleState = TIM_OCNIDLESTATE_SET; // needed for TIM1 and TIM8 - if (HAL_TIM_PWM_ConfigChannel(&self->handle, &self->chan_handle, self->channel) != HAL_OK) { + //TIM_OC_InitTypeDef sConfigOC = self->chan_handle; + mp_printf(&mp_plat_print, "Complete"); + if (HAL_TIM_PWM_ConfigChannel(&self->handle, &(self->chan_handle), (uint32_t)self->channel) != HAL_OK) + { mp_raise_ValueError(translate("Could not initialize channel")); } - if (HAL_TIM_PWM_Start(&self->handle, self->channel) != HAL_OK) { - mp_raise_ValueError(translate("Could not start PWM")); - } - self->variable_frequency = variable_frequency; - self->frequency = frequency; - self->duty_cycle = duty; - self->period = period; + // TIM_OC_InitTypeDef sConfigOC = {0}; + // sConfigOC.OCNPolarity = 0; + // sConfigOC.OCIdleState = 0; + // sConfigOC.OCNIdleState = 0; + // sConfigOC.OCMode = TIM_OCMODE_PWM1; + // sConfigOC.Pulse = 7000; + // sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + // sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + // if (HAL_TIM_PWM_ConfigChannel(&self->handle, &sConfigOC, self->channel) != HAL_OK) + // { + // mp_raise_ValueError(translate("Could not initialize channel")); + // } + + +//OG + // if (HAL_TIM_PWM_Start(&self->handle, self->channel) != HAL_OK) { + // mp_raise_ValueError(translate("Could not start PWM")); + // } +//HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); +HAL_TIM_PWM_Start(&self->handle, self->channel); + + +mp_printf(&mp_plat_print, "Complete"); + // period, prescaler, timer_get_internal_duty(duty, period)); + // mp_printf(&mp_plat_print, "SrcFreq: %d Per:%d presc:%d, doot:%d \n",timer_get_source_freq(self->tim->tim_index), + // period, prescaler, timer_get_internal_duty(duty, period)); + + // self->variable_frequency = variable_frequency; + // self->frequency = frequency; + // self->duty_cycle = duty; + // self->period = period; + + + //FULL REPLACE + + // __HAL_RCC_TIM2_CLK_ENABLE(); + + // TIM_MasterConfigTypeDef sMasterConfig = {0}; + // TIM_OC_InitTypeDef sConfigOC = {0}; + // TIM_HandleTypeDef htim2; + + // /* USER CODE BEGIN TIM2_Init 1 */ + + // /* USER CODE END TIM2_Init 1 */ + // htim2.Instance = TIM2; + // htim2.Init.Prescaler = 0; + // htim2.Init.CounterMode = TIM_COUNTERMODE_UP; + // htim2.Init.Period = 8749; + // htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + // htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + // if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) + // { + // mp_raise_ValueError(translate("Could not start PWM1")); + // } + // sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + // sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + // if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) + // { + // mp_raise_ValueError(translate("Could not start PWM2")); + // } + // sConfigOC.OCMode = TIM_OCMODE_PWM1; + // sConfigOC.Pulse = 7000; + // sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + // sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + // if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + // { + // mp_raise_ValueError(translate("Could not start PWM3")); + // } + + // /* USER CODE BEGIN TIM2_Init 2 */ + + // /* USER CODE END TIM2_Init 2 */ + // __HAL_RCC_GPIOA_CLK_ENABLE(); + // /**TIM2 GPIO Configuration + // PA1 ------> TIM2_CH2 + // */ + // GPIO_InitTypeDef GPIO_InitStruct = {0}; + // GPIO_InitStruct.Pin = GPIO_PIN_1; + // GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + // GPIO_InitStruct.Pull = GPIO_NOPULL; + // GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + // GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + // HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + // HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); return PWMOUT_OK; } bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) { + mp_printf(&mp_plat_print, "Deinited\n"); return self->tim == mp_const_none; } void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { + mp_printf(&mp_plat_print, "Deinit\n"); if (common_hal_pulseio_pwmout_deinited(self)) { return; } @@ -272,16 +410,19 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { } void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) { + mp_printf(&mp_plat_print, "setduty\n"); uint32_t internal_duty_cycle = timer_get_internal_duty(duty, self->period); __HAL_TIM_SET_COMPARE(&self->handle, self->channel, internal_duty_cycle); self->duty_cycle = duty; } uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) { + mp_printf(&mp_plat_print, "getduty\n"); return self->duty_cycle; } void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) { + mp_printf(&mp_plat_print, "setfreq\n"); //don't halt setup for the same frequency if (frequency == self->frequency) return; @@ -316,10 +457,12 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_ } uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) { + mp_printf(&mp_plat_print, "getfreq\n"); return self->frequency; } bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) { + mp_printf(&mp_plat_print, "getvarfreq\n"); return self->variable_frequency; } diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h index 7d3f4dca22..6085f1ff2b 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/periph.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H -#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F401XE_PERIPH_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F401XE_PERIPH_H //I2C extern I2C_TypeDef * mcu_i2c_banks[3]; @@ -54,4 +54,4 @@ extern const mcu_uart_rx_obj_t mcu_uart_rx_list[6]; TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN]; const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; -#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H \ No newline at end of file +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F401XE_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h index 37d3a5cf11..09bc8f13e3 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/pins.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H -#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F401XE_PINS_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F401XE_PINS_H //Pins in datasheet order: DocID026289 Rev 7 page 38. LQFP100 only //pg 38 @@ -118,4 +118,4 @@ extern const mcu_pin_obj_t pin_PE00; extern const mcu_pin_obj_t pin_PE01; -#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PINS_H +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F401XE_PINS_H diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c index 3962f6fa62..df5a70cd12 100644 --- a/ports/stm32f4/supervisor/port.c +++ b/ports/stm32f4/supervisor/port.c @@ -52,17 +52,6 @@ safe_mode_t port_init(void) { tick_init(); board_init(); - //Configure LED pins - GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); - return NO_SAFE_MODE; } From d0fab1c728b9620e6acef45e08b650fd2ba43cae Mon Sep 17 00:00:00 2001 From: Hierophect Date: Sat, 4 Jan 2020 13:53:31 -0500 Subject: [PATCH 279/531] Clean up debugging edits --- ports/stm32f4/Makefile | 7 +- ports/stm32f4/common-hal/pulseio/PWMOut.c | 199 +++------------------- 2 files changed, 27 insertions(+), 179 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index cb2cdd8d37..2727ea954f 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -22,7 +22,7 @@ # 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. -#DEBUG = 1 +DEBUG = 1 # Select the board to build for. ifeq ($(BOARD),) @@ -85,11 +85,6 @@ ifeq ($(DEBUG), 1) CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -Os -DNDEBUG - CFLAGS += -ggdb -# CFLAGS += -fno-inline -fno-ipa-sra - - - #CFLAGS += -Os -DNDEBUG # TODO: Test with -flto ### CFLAGS += -flto endif diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 5bb34b7c0e..7bff8de761 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -26,7 +26,6 @@ */ #include -#include //add #include "py/runtime.h" #include "common-hal/pulseio/PWMOut.h" #include "shared-bindings/pulseio/PWMOut.h" @@ -89,7 +88,6 @@ STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, } void pwmout_reset(void) { - mp_printf(&mp_plat_print, "reset\n"); uint16_t never_reset_mask = 0x00; for(int i=0;inumber); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -200,195 +194,59 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = self->tim->altfn_index; HAL_GPIO_Init(pin_port(pin->port), &GPIO_InitStruct); - mp_printf(&mp_plat_print, "Good GPIO init\n"); - // __HAL_RCC_GPIOA_CLK_ENABLE(); - // /**TIM2 GPIO Configuration - // PA1 ------> TIM2_CH2 - // */ - // GPIO_InitTypeDef GPIO_InitStruct = {0}; - // GPIO_InitStruct.Pin = GPIO_PIN_1; - // GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - // GPIO_InitStruct.Pull = GPIO_NOPULL; - // GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - // GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; - // HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - - - - mp_printf(&mp_plat_print, "PWM Pin:%d Port:%d\n", pin->number, pin->port); - - - - - -//OG tim_clock_enable(1<<(self->tim->tim_index - 1)); - //__HAL_RCC_TIM2_CLK_ENABLE(); - - mp_printf(&mp_plat_print, "Good clock init\n"); - - - -//OG - // //translate channel into handle value + //translate channel into handle value self->channel = 4 * (self->tim->channel_index - 1); - // uint32_t prescaler = 0; //prescaler is 15 bit - // uint32_t period = 0; //period is 16 bit - // timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index)); - // //Timer init - self->handle.Instance = TIM2; //TIMx; - self->handle.Init.Period = 8749;//period - 1; - self->handle.Init.Prescaler = 0;//prescaler - 1; + uint32_t prescaler = 0; //prescaler is 15 bit + uint32_t period = 0; //period is 16 bit + timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index)); + + //Timer init + self->handle.Instance = TIMx; + self->handle.Init.Period = period - 1; + self->handle.Init.Prescaler = prescaler - 1; self->handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; self->handle.Init.CounterMode = TIM_COUNTERMODE_UP; - self->handle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - //self->handle.Init.RepetitionCounter = 0; + self->handle.Init.RepetitionCounter = 0; + //only run init if this is the first instance of this timer - // if (first_time_setup) { + if (first_time_setup) { if (HAL_TIM_PWM_Init(&self->handle) != HAL_OK) { mp_raise_ValueError(translate("Could not initialize timer")); } - // } - - /* USER CODE END TIM2_Init 1 */ - // TIM_HandleTypeDef htim2; - // htim2.Instance = TIM2; - // htim2.Init.Prescaler = 0; - // htim2.Init.CounterMode = TIM_COUNTERMODE_UP; - // htim2.Init.Period = 8749; - // htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - // htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - // if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) - // { - // mp_raise_ValueError(translate("Could not start PWM1")); - // } - -//OG not needed - TIM_MasterConfigTypeDef sMasterConfig = {0}; - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - if (HAL_TIMEx_MasterConfigSynchronization(&self->handle, &sMasterConfig) != HAL_OK) - { - mp_raise_ValueError(translate("Internal Error")); } -//OG - // //Channel/PWM init - //memset(&(self->chan_handle), 0, sizeof(TIM_OC_InitTypeDef)); //doesn't seem to affect it - self->chan_handle.OCNPolarity = 0; - self->chan_handle.OCIdleState = 0; - self->chan_handle.OCNIdleState = 0; + //Channel/PWM init self->chan_handle.OCMode = TIM_OCMODE_PWM1; - self->chan_handle.Pulse = 7000; - self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH; + self->chan_handle.Pulse = timer_get_internal_duty(duty, period); + self->chan_handle.OCPolarity = TIM_OCPOLARITY_LOW; self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE; - //TIM_OC_InitTypeDef sConfigOC = self->chan_handle; - mp_printf(&mp_plat_print, "Complete"); - if (HAL_TIM_PWM_ConfigChannel(&self->handle, &(self->chan_handle), (uint32_t)self->channel) != HAL_OK) - { + self->chan_handle.OCNPolarity = TIM_OCNPOLARITY_LOW; // needed for TIM1 and TIM8 + self->chan_handle.OCIdleState = TIM_OCIDLESTATE_SET; // needed for TIM1 and TIM8 + self->chan_handle.OCNIdleState = TIM_OCNIDLESTATE_SET; // needed for TIM1 and TIM8 + if (HAL_TIM_PWM_ConfigChannel(&self->handle, &self->chan_handle, self->channel) != HAL_OK) { mp_raise_ValueError(translate("Could not initialize channel")); } + if (HAL_TIM_PWM_Start(&self->handle, self->channel) != HAL_OK) { + mp_raise_ValueError(translate("Could not start PWM")); + } - // TIM_OC_InitTypeDef sConfigOC = {0}; - // sConfigOC.OCNPolarity = 0; - // sConfigOC.OCIdleState = 0; - // sConfigOC.OCNIdleState = 0; - // sConfigOC.OCMode = TIM_OCMODE_PWM1; - // sConfigOC.Pulse = 7000; - // sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; - // sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; - // if (HAL_TIM_PWM_ConfigChannel(&self->handle, &sConfigOC, self->channel) != HAL_OK) - // { - // mp_raise_ValueError(translate("Could not initialize channel")); - // } - - -//OG - // if (HAL_TIM_PWM_Start(&self->handle, self->channel) != HAL_OK) { - // mp_raise_ValueError(translate("Could not start PWM")); - // } -//HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); -HAL_TIM_PWM_Start(&self->handle, self->channel); - - -mp_printf(&mp_plat_print, "Complete"); - // period, prescaler, timer_get_internal_duty(duty, period)); - // mp_printf(&mp_plat_print, "SrcFreq: %d Per:%d presc:%d, doot:%d \n",timer_get_source_freq(self->tim->tim_index), - // period, prescaler, timer_get_internal_duty(duty, period)); - - // self->variable_frequency = variable_frequency; - // self->frequency = frequency; - // self->duty_cycle = duty; - // self->period = period; - - - //FULL REPLACE - - // __HAL_RCC_TIM2_CLK_ENABLE(); - - // TIM_MasterConfigTypeDef sMasterConfig = {0}; - // TIM_OC_InitTypeDef sConfigOC = {0}; - // TIM_HandleTypeDef htim2; - - // /* USER CODE BEGIN TIM2_Init 1 */ - - // /* USER CODE END TIM2_Init 1 */ - // htim2.Instance = TIM2; - // htim2.Init.Prescaler = 0; - // htim2.Init.CounterMode = TIM_COUNTERMODE_UP; - // htim2.Init.Period = 8749; - // htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - // htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - // if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) - // { - // mp_raise_ValueError(translate("Could not start PWM1")); - // } - // sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - // sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - // if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) - // { - // mp_raise_ValueError(translate("Could not start PWM2")); - // } - // sConfigOC.OCMode = TIM_OCMODE_PWM1; - // sConfigOC.Pulse = 7000; - // sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; - // sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; - // if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) - // { - // mp_raise_ValueError(translate("Could not start PWM3")); - // } - - // /* USER CODE BEGIN TIM2_Init 2 */ - - // /* USER CODE END TIM2_Init 2 */ - // __HAL_RCC_GPIOA_CLK_ENABLE(); - // /**TIM2 GPIO Configuration - // PA1 ------> TIM2_CH2 - // */ - // GPIO_InitTypeDef GPIO_InitStruct = {0}; - // GPIO_InitStruct.Pin = GPIO_PIN_1; - // GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - // GPIO_InitStruct.Pull = GPIO_NOPULL; - // GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - // GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; - // HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - // HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); + self->variable_frequency = variable_frequency; + self->frequency = frequency; + self->duty_cycle = duty; + self->period = period; return PWMOUT_OK; } bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) { - mp_printf(&mp_plat_print, "Deinited\n"); return self->tim == mp_const_none; } void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { - mp_printf(&mp_plat_print, "Deinit\n"); if (common_hal_pulseio_pwmout_deinited(self)) { return; } @@ -410,19 +268,16 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { } void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) { - mp_printf(&mp_plat_print, "setduty\n"); uint32_t internal_duty_cycle = timer_get_internal_duty(duty, self->period); __HAL_TIM_SET_COMPARE(&self->handle, self->channel, internal_duty_cycle); self->duty_cycle = duty; } uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) { - mp_printf(&mp_plat_print, "getduty\n"); return self->duty_cycle; } void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) { - mp_printf(&mp_plat_print, "setfreq\n"); //don't halt setup for the same frequency if (frequency == self->frequency) return; @@ -457,12 +312,10 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_ } uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) { - mp_printf(&mp_plat_print, "getfreq\n"); return self->frequency; } bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) { - mp_printf(&mp_plat_print, "getvarfreq\n"); return self->variable_frequency; } From 53238ad9b2b106fc58bc901257060fc2e97ab724 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Sat, 4 Jan 2020 13:57:38 -0500 Subject: [PATCH 280/531] yaml changes --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e87190c727..33c271d6e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -114,6 +114,7 @@ jobs: - "kicksat-sprite" - "makerdiary_nrf52840_mdk" - "makerdiary_nrf52840_mdk_usb_dongle" + - "meowbit_v121" - "meowmeow" - "metro_m0_express" - "metro_m4_airlift_lite" From f355642eabf3b408f25a3b098d0eec84ad915988 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Sat, 4 Jan 2020 16:23:36 -0500 Subject: [PATCH 281/531] Boot linker edits --- ports/stm32f4/boards/STM32F401.ld | 65 ++++++++++++++++++++------ ports/stm32f4/boards/STM32F401_boot.ld | 6 +-- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/ports/stm32f4/boards/STM32F401.ld b/ports/stm32f4/boards/STM32F401.ld index b3d772a784..be72ecc091 100644 --- a/ports/stm32f4/boards/STM32F401.ld +++ b/ports/stm32f4/boards/STM32F401.ld @@ -1,28 +1,52 @@ /* - GNU linker script for STM32F401 with bootloader (such as the Meowbit) + GNU linker script for STM32F401 with bootloader (from Meowbit Micropython) + Doesn't work: + + Traceback (most recent call last): + File "../../tools/build_memory_info.py", line 64, in + regions[region] = int(eval(space)) + File "", line 1, in +NameError: name 'FLASH_ISR' is not defined */ /* Specify the memory areas */ +/* FLASH_FS (rx) : ORIGIN = 0x08020000, LENGTH = 128K */ +/* sectors 5 128K */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K - 64K /* entire flash, sans bootloader */ - FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 64K /* sector 4, 0-3 used by bootloader*/ - FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */ - RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 /* more bootloader schnenaigans */ + FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4, sec 0~3 reserved for booloader */ + FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5, 6,7 are 128K */ + RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 } /* produce a link error if there is not this amount of RAM for these sections */ _minimum_stack_size = 2K; _minimum_heap_size = 16K; -/* Define tho top end of the stack. The stack is full descending so begins just - above last byte of RAM. Note that EABI requires the stack to be 8-byte - aligned for a call. */ -_estack = ORIGIN(RAM) + LENGTH(RAM); +/* Define the stack. The stack is full descending so begins just above last byte + of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve; +_sstack = _estack - 16K; /* tunable */ /* RAM extents for the garbage collector */ _ram_start = ORIGIN(RAM); _ram_end = ORIGIN(RAM) + LENGTH(RAM); +_heap_start = _ebss; /* heap starts just after statically allocated memory */ +_heap_end = _sstack; + +/* Memory layout for internal flash storage configuration: + + FLASH_ISR .isr_vector + + FLASH_TEXT .text + FLASH_TEXT .data + + RAM .data + RAM .bss + RAM .heap + RAM .stack +*/ ENTRY(Reset_Handler) @@ -36,8 +60,25 @@ SECTIONS KEEP(*(.isr_vector)) /* Startup code */ /* This first flash block is 16K annd 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. */ + about 400 bytes. So we pull in a couple of object files to pad it + out. */ + + . = ALIGN(4); + + /* NOTE: If you update the list of files contained in .isr_vector, + then be sure to also update smhal/Makefile where it forcibly + builds each of these files with -Os */ + + */ff.o(.text*) + */vfs_fat_*.o(.text*) + */py/formatfloat.o(.text*) + */py/parsenum.o(.text*) + */py/mpprint.o(.text*) + + */py/compile.o(.text*) + */py/objset.o(.text*) + */py/mpz.o(.text*) + */py/vm.o(.text*) . = ALIGN(4); } >FLASH_ISR @@ -102,5 +143,3 @@ SECTIONS .ARM.attributes 0 : { *(.ARM.attributes) } } - - diff --git a/ports/stm32f4/boards/STM32F401_boot.ld b/ports/stm32f4/boards/STM32F401_boot.ld index 7f582fdf9f..64f78451ad 100644 --- a/ports/stm32f4/boards/STM32F401_boot.ld +++ b/ports/stm32f4/boards/STM32F401_boot.ld @@ -5,10 +5,10 @@ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash, sans bootloader */ - FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4, 0-3 used by bootloader*/ + FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */ - RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 /* more bootloader schnenaigans */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K } /* produce a link error if there is not this amount of RAM for these sections */ From 390337b9a518eaa4416458bce9f4a39b60b23372 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 5 Jan 2020 23:33:42 -0500 Subject: [PATCH 282/531] wip; compiles --- ports/nrf/Makefile | 3 +- ports/nrf/background.c | 2 + ports/nrf/common-hal/_bleio/Adapter.c | 2 + ports/nrf/common-hal/_bleio/Characteristic.c | 9 +- ports/nrf/common-hal/_bleio/Connection.c | 25 +- ports/nrf/common-hal/_bleio/__init__.h | 6 +- ports/nrf/common-hal/_bleio/bonding.c | 295 +++++++++++++------ ports/nrf/common-hal/_bleio/bonding.h | 54 +++- ports/nrf/mpconfigport.h | 5 +- 9 files changed, 273 insertions(+), 128 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index e6070fc329..92985e4e9e 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -73,8 +73,6 @@ INC += -I$(BUILD) INC += -I$(BUILD)/genhdr INC += -I./../../lib/cmsis/inc INC += -I./boards/$(BOARD) -INC += -I./modules/ubluepy -INC += -I./modules/ble INC += -I./nrfx INC += -I./nrfx/hal INC += -I./nrfx/mdk @@ -156,6 +154,7 @@ SRC_C += \ boards/$(BOARD)/pins.c \ device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \ bluetooth/ble_drv.c \ + common-hal/_bleio/bonding.c \ lib/libc/string0.c \ lib/mp-readline/readline.c \ lib/oofatfs/ff.c \ diff --git a/ports/nrf/background.c b/ports/nrf/background.c index 629967b3d0..966c56e0b7 100644 --- a/ports/nrf/background.c +++ b/ports/nrf/background.c @@ -43,6 +43,7 @@ #if CIRCUITPY_BLEIO #include "supervisor/shared/bluetooth.h" +#include "common-hal/_bleio/bonding.h" #endif static bool running_background_tasks = false; @@ -68,6 +69,7 @@ void run_background_tasks(void) { #if CIRCUITPY_BLEIO supervisor_bluetooth_background(); + bonding_background(); #endif #if CIRCUITPY_DISPLAYIO diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index cee40a5a0c..12d5090737 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -32,6 +32,7 @@ #include "ble.h" #include "ble_drv.h" +#include "bonding.h" #include "nrfx_power.h" #include "nrf_nvic.h" #include "nrf_sdm.h" @@ -669,4 +670,5 @@ void bleio_adapter_reset(bleio_adapter_obj_t* adapter) { bleio_connection_internal_t *connection = &connections[i]; connection->connection_obj = mp_const_none; } + bonding_reset(); } diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index f80c52ae43..81639898fc 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -33,6 +33,7 @@ #include "shared-bindings/_bleio/Service.h" #include "common-hal/_bleio/Adapter.h" +#include "common-hal/_bleio/bonding.h" STATIC uint16_t characteristic_get_cccd(uint16_t cccd_handle, uint16_t conn_handle) { uint16_t cccd; @@ -92,9 +93,11 @@ STATIC bool characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) { bleio_connection_obj_t *connection = self->service->connection; uint16_t conn_handle = bleio_connection_get_conn_handle(connection); if (conn_handle != BLE_CONN_HANDLE_INVALID && - connection->pairing_status == PAIR_PAIRED && - ble_evt->gatts_evt.params.write.handle == self->cccd_handle) { - bonding_save_cccd_later(connection->is_central, conn_handle, connection->ediv); + common_hal_bleio_connection_get_paired(connection) && + ble_evt->evt.gatts_evt.params.write.handle == self->cccd_handle) { + bonding_save_cccd_info( + connection->connection->is_central, conn_handle, connection->connection->ediv); + } } break; } diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 725a9a11a9..6c49823c2b 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -47,6 +47,8 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" +#include "common-hal/_bleio/bonding.h" + #define BLE_ADV_LENGTH_FIELD_SIZE 1 #define BLE_ADV_AD_TYPE_FIELD_SIZE 1 #define BLE_AD_TYPE_FLAGS_DATA_SIZE 1 @@ -212,7 +214,7 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { ble_gap_evt_auth_status_t* status = &ble_evt->evt.gap_evt.params.auth_status; self->sec_status = status->auth_status; if (status->auth_status == BLE_GAP_SEC_STATUS_SUCCESS) { - self->ediv = bonding_keys->own_enc.master_id.ediv; + self->ediv = self->bonding_keys.own_enc.master_id.ediv; self->pair_status = PAIR_PAIRED; bonding_save_keys(self->is_central, self->conn_handle, &self->bonding_keys); } else { @@ -227,13 +229,12 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // - Else return NULL --> Initiate key exchange ble_gap_evt_sec_info_request_t* sec_info_request = &ble_evt->evt.gap_evt.params.sec_info_request; (void) sec_info_request; - bond_keys bond_keys_t; if ( bonding_load_keys(self->is_central, sec_info_request->master_id.ediv, &self->bonding_keys) ) { - sd_ble_gap_sec_info_reply(self->conn_handle + sd_ble_gap_sec_info_reply(self->conn_handle, &self->bonding_keys.own_enc.enc_info, &self->bonding_keys.peer_id.id_info, NULL); - self->ediv = bond_keys.own_enc.master_id.ediv; + self->ediv = self->bonding_keys.own_enc.master_id.ediv; } else { sd_ble_gap_sec_info_reply(self->conn_handle, NULL, NULL, NULL); } @@ -249,12 +250,10 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // mode >=1 and/or level >=1 means encryption is set up self->pair_status = PAIR_NOT_PAIRED; } else { - uint8_t *sys_attr; - uint16_t sys_attr_len; - if (bonding_load_cccd_info(self->is_central, self->conn_handle, self->ediv, sys_attr, sys_attr_len)) { - sd_ble_gatts_sys_attr_set(self->conn_handle, sys_attr, sys_attr_len, SVC_CONTEXT_FLAG); - // Not quite paired yet: wait for BLE_GAP_EVT_AUTH_STATUS SUCCESS. - self->ediv = self->bonding_keys.own_enc.master_id.ediv; + // Does an sd_ble_gatts_sys_attr_set() with the stored values. + if (bonding_load_cccd_info(self->is_central, self->conn_handle, self->ediv)) { + // Not quite paired yet: wait for BLE_GAP_EVT_AUTH_STATUS SUCCESS. + self->ediv = self->bonding_keys.own_enc.master_id.ediv; } else { // No matching bonding found, so use fresh system attributes. sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); @@ -263,10 +262,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } - case BLE_GATTS_EVT_WRITE: { - if (self->pair_status == PAIR_PAIRED) && - - default: return false; } @@ -278,7 +273,7 @@ void bleio_connection_clear(bleio_connection_internal_t *self) { self->conn_handle = BLE_CONN_HANDLE_INVALID; self->pair_status = PAIR_NOT_PAIRED; - bonding_clear_keys(self); + bonding_clear_keys(&self->bonding_keys); } bool common_hal_bleio_connection_get_paired(bleio_connection_obj_t *self) { diff --git a/ports/nrf/common-hal/_bleio/__init__.h b/ports/nrf/common-hal/_bleio/__init__.h index ecacf7c85d..e216795fcd 100644 --- a/ports/nrf/common-hal/_bleio/__init__.h +++ b/ports/nrf/common-hal/_bleio/__init__.h @@ -30,9 +30,9 @@ void bleio_reset(void); typedef struct { - ble_gap_enc_key_t own_enc; - ble_gap_enc_key_t peer_enc; - ble_gap_id_key_t peer_id; + ble_gap_enc_key_t own_enc; + ble_gap_enc_key_t peer_enc; + ble_gap_id_key_t peer_id; } bonding_keys_t; // We assume variable length data. diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c index c717d08165..1675ade43d 100644 --- a/ports/nrf/common-hal/_bleio/bonding.c +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -34,6 +34,9 @@ #include "shared-bindings/_bleio/Adapter.h" #include "shared-bindings/nvm/ByteArray.h" +#include "nrf_nvmc.h" +#include "sd_mutex.h" + #include "bonding.h" // Internal flash area reserved for bonding storage. @@ -42,97 +45,64 @@ // First and last four bytes are magic bytes for id and version. Start data after that. // 'BD01' -const uint32_t BONDING_START_FLAG ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); +const uint32_t BONDING_START_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); // 'ED01' -const uint32_t BONDING_END_FLAG ('1' | '0' << 8 | 'D' << 16 | 'E' << 24); +const uint32_t BONDING_END_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'E' << 24); -#define BONDING_DATA_START_ADDR (BONDING_DATA_START_ADDR + sizeof(BONDING_START_BYTES)) -#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_END_BYTES)) +#define BONDING_DATA_START_ADDR (BONDING_PAGES_START_ADDR + sizeof(BONDING_START_FLAG)) +#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_END_FLAG)) -#define BONDING_START_FLAG_ADDR BONDING_DATA_START_ADDR +#define BONDING_START_FLAG_ADDR BONDING_PAGES_START_ADDR #define BONDING_END_FLAG_ADDR BONDING_DATA_END_ADDR -// Bonding data is stored in variable-length blocks consecutively in erased flash. -// The blocks are 32-bit aligned, though the data may be any number of bytes. -// You can hop through the blocks using the size field to find the next block. -// When you hit a word that is all one's, you have reached the end of the blocks. -// You can write a new block there. +// Save both system and user service info. +#define SYS_ATTR_FLAGS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS) -typdef enum { - BLOCK_INVALID = 0, // Ignore this block - BLOCK_KEYS = 1, // Block contains bonding keys. - BLOCK_SYS_ATTR = 2, // Block contains sys_attr values (CCCD settings, etc.). - BLOCK_UNUSED = 0xff, // Initial erased value. -} bonding_block_type_t; +STATIC bonding_block_t *bonding_unused_block = NULL; +nrf_mutex_t queued_bonding_block_list_mutex; -typedef struct { - uint16_t central:1; // 1 if data is for a central role. - uint16_t reserved: 7; // Not currently used - bonding_block_type_t type: 8; // What kind of data is stored in. - uint16_t ediv; // ediv value; used as a lookup key. - uint32_t data_length; // Length of data in bytes, including ediv, not including padding. - // data_length only needs to be 16 bits, but easier to write a word at a time. - uint8_t data[]; // Rest of data in the block. Needs to be 32-bit aligned. - // Block is padded to 32-bit alignment. -} bonding_block_t; - -STATIC inline size_t bonding_block_size(uint16_t data_length) { +STATIC inline size_t compute_block_size(uint16_t data_length) { // Round data size up to the nearest 32-bit address. return sizeof(bonding_block_t) + ((data_length + 3) & 0x3); - - -void bonding_clear_keys(bonding_keys_t *bonding_keys) { - memset(bonding_keys, 0, sizeof(bonding_keys)); } -STATIC void bonding_erase_storage(void) { +STATIC void erase_bonding_storage(void) { // Erase all pages in the bonding area. + BONDING_DEBUG_PRINTF("erase_bonding_storage()\n"); for(uint32_t page_address = BONDING_PAGES_START_ADDR; page_address < BONDING_PAGES_END_ADDR; - page_address += FLASH_PAGE) { + page_address += FLASH_PAGE_SIZE) { nrf_nvmc_page_erase(page_address); } // Write marker words at the beginning and the end of the bonding area. nrf_nvmc_write_word(BONDING_DATA_START_ADDR, BONDING_START_FLAG_ADDR); nrf_nvmc_write_word(BONDING_DATA_END_ADDR, BONDING_END_FLAG_ADDR); // First unused block is at the beginning. - bonding_unused_block = BONDING_DATA_START_ADDR; -} - -STATIC bonding_block_t *bonding_unused_block = NULL; - -void bonding_init(void) { - if (BONDING_START_BYTES != *((uint32_t *) BONDING_START_FLAG_ADDR) || - BONDING_END_BYTES != *((uint32_t *) BONDING_END_FLAG_ADDR)) { - bonding_erase_storage(); - } else { - bonding_unused_block = bonding_find_block(BLOCK_UNUSED, EDIV_INVALID); - } + bonding_unused_block = (bonding_block_t *) BONDING_DATA_START_ADDR; } // Given NULL to start or block address, return the address of the next valid block. // The last block returned is the unused block at the end. // Return NULL if we have run off the end of the bonding space. -STATIC bonding_block_t *bonding_next_block(bonding_block_t *block) { +STATIC bonding_block_t *next_block(bonding_block_t *block) { while (1) { // Advance to next block. if (block == NULL) { // Return first block (which might be unused if block list is empty). - return BONDING_DATA_START_ADDR; + return (bonding_block_t *) BONDING_DATA_START_ADDR; } else if (block->type == BLOCK_UNUSED) { // Already at last block (the unused block). return NULL; } // Advance to next block. - block += (bonding_block_t *) ((uint8_t *) block + bonding_block_word_size(block->data_length)); + block = (bonding_block_t *) ((uint8_t *) block + compute_block_size(block->data_length)); - } if (block >= (bonding_block_t *) BONDING_DATA_END_ADDR) { // Went past end of bonding space. return NULL; } - if (block.valid) { + if (block->type != BLOCK_INVALID) { // Found an empty or a valid block. return block; } @@ -143,17 +113,19 @@ STATIC bonding_block_t *bonding_next_block(bonding_block_t *block) { // Find the block with given type and ediv value. // If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. // If not found, return NULL. -STATIC bonding_block_t *bonding_find_block(bonding_block_type_t type, uint16_t ediv) { +STATIC bonding_block_t *find_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { bonding_block_t *block = NULL; while (1) { - block = bonding_next_block(block); + block = next_block(block); if (block == NULL) { return NULL; } - if (block.type == BLOCK_UNUSED) { + if (block->type == BLOCK_UNUSED) { return block; } - if (type == block.type && ediv = block.ediv) { + if (is_central == block->is_central && + type == block->type && + ediv == block->ediv) { return block; } } @@ -161,80 +133,207 @@ STATIC bonding_block_t *bonding_find_block(bonding_block_type_t type, uint16_t e // Set the header word to all 0's, to mark the block as invalid. // We don't change data_length, so we can still skip over this block. -STATIC void bonding_invalidate_block(bonding_block_t *block) { - nrf_nvmc_write_word((uint32_t) bonding_unused_block, 0x00000000); +STATIC void invalidate_block(bonding_block_t *block) { + BONDING_DEBUG_PRINTF("invalidate_block()\n"); + nrf_nvmc_write_word((uint32_t) block, 0x00000000); } -// Try to write a new block. If no room, erase everything and start again. -// TODO: could do garbage collection instead. -STATIC bool bonding_write_block(bonding_block_type_t type, uint16_t ediv, uint8_t *data, uint16_t data_length) { - size_t block_size = bonding_block_word_size(data_length); - if (block_size > BONDING_DATA_END_ADDR - BONDING_DATA_START_ADDR) { +STATIC void queue_write_block(bool is_central, bonding_block_type_t type, uint16_t ediv, uint16_t conn_handle, uint8_t *data, uint16_t data_length) { + if (compute_block_size(data_length) > BONDING_DATA_END_ADDR - BONDING_DATA_START_ADDR) { // Ridiculous size. - return false; + return; } - // No more room. Erase all existing bonding info and start over. - if (bonding_unused_block == NULL || bonding_unused_block + block_size >= BONDING_DATA_END_ADDR) { - bonding_erase_storage(); + queued_bonding_block_list_elt_t* queued_elt = + m_malloc_maybe(sizeof(queued_bonding_block_list_elt_t) + data_length, false); + + if (!queued_elt) { + // Failed to allocate. Not much we can do, since this might be during an evt handler. + return; } - bonding_block_t block_without_data; - block_without_data.valid = 1; - block_without_data.type = type; - block_without_data.ediv = ediv; - block_without_data.data_length = data_length; + // Add this new element to the front of the list. + sd_mutex_acquire_wait(&queued_bonding_block_list_mutex); + queued_elt->next_queued_block = MP_STATE_VM(queued_bonding_block_list); + MP_STATE_VM(queued_bonding_block_list) = queued_elt; + sd_mutex_release(&queued_bonding_block_list_mutex); - // Write header data. - nrf_nvmc_write_words((uint32_t) bonding_unused_block, (uint32_t *) &block_without_data, - sizeof(block_without_data) / 4); + // + queued_elt->bonding_block.is_central = is_central; + queued_elt->bonding_block.type = type; + queued_elt->bonding_block.ediv = ediv; + queued_elt->bonding_block.conn_handle = conn_handle; + queued_elt->bonding_block.data_length = data_length; + if (data && data_length != 0) { + memcpy(&queued_elt->bonding_block.data, data, data_length); + } +} - // Write variable-length data. +// Write bonding block header. +STATIC void write_block_header(bonding_block_t *block) { + // If no more room, erase all existing blocks and start over. + if (bonding_unused_block == NULL || + (uint8_t *) bonding_unused_block + compute_block_size(block->data_length) >= + (uint8_t *)BONDING_DATA_END_ADDR) { + erase_bonding_storage(); + } + + nrf_nvmc_write_words((uint32_t) bonding_unused_block, (uint32_t *) block, sizeof(bonding_block_t) / 4); +} + +// Write variable-length data at end of bonding block. +STATIC void write_block_data(uint8_t *data, uint16_t data_length) { // Minimize the number of writes. Datasheet says no more than two writes per word before erasing again. - uint32_t *word_p = (uint32_t) bonding_unused_block + sizeof(block_without_data); + + // Start writing after the current header. + uint32_t *flash_word_p = (uint32_t *) ((uint8_t *) bonding_unused_block + sizeof(bonding_block_t)); while (1) { uint32_t word = 0xffffffff; memcpy(&word, data, data_length >= 4 ? 4 : data_length); - nrf_nvmc_write_word(word_p, word); + nrf_nvmc_write_word((uint32_t) flash_word_p, word); if (data_length <= 4) { break; } data_length -= 4; - word_p++; + // Increment by word size. + flash_word_p++; } + bonding_unused_block = (bonding_block_t *) flash_word_p; +} + +STATIC bool write_sys_attr_block(bonding_block_t *block) { + BONDING_DEBUG_PRINTF("write_sys_attr_block()\n"); + uint16_t length = 0; + // First find out how big a buffer we need, then fetch the data. + if(sd_ble_gatts_sys_attr_get(block->conn_handle, NULL, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return false; + } + + uint8_t sys_attr[length]; + if(sd_ble_gatts_sys_attr_get(block->conn_handle, sys_attr, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return false; + } + + // Now we know the data size. + block->data_length = length; + write_block_header(block); + write_block_data(sys_attr, length); + return true; +} + +STATIC bool write_keys_block(bonding_block_t *block) { + BONDING_DEBUG_PRINTF("write_keys_block()\n"); + if (block->data_length != sizeof(bonding_keys_t)) { + return false; + } + + bonding_keys_t *bonding_keys = (bonding_keys_t *) block->data; + block->ediv = block->is_central + ? bonding_keys->peer_enc.master_id.ediv + : bonding_keys->own_enc.master_id.ediv; + + write_block_header(block); + write_block_data((uint8_t *) bonding_keys, sizeof(bonding_keys_t)); return true; } +void bonding_clear_keys(bonding_keys_t *bonding_keys) { + memset((uint8_t*) bonding_keys, 0, sizeof(bonding_keys_t)); +} -bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv, - uint8_t **sys_attr, uint16_t *sys_attr_len) { - bonding_block_t *block = bonding_find_matching_block(BLOCK_SYS_ATTR, ediv); - if (block) { - *sys_attr = block.data; - *sys_attr_len = block.data_length; - return true; +void bonding_reset(void) { + BONDING_DEBUG_PRINTF("bonding_reset()\n"); + sd_mutex_new(&queued_bonding_block_list_mutex); + if (BONDING_START_FLAG != *((uint32_t *) BONDING_START_FLAG_ADDR) || + BONDING_END_FLAG != *((uint32_t *) BONDING_END_FLAG_ADDR)) { + erase_bonding_storage(); } else { + bonding_unused_block = find_block(true, BLOCK_UNUSED, EDIV_INVALID); + } +} + +// Write bonding blocks to flash. These have been queued during event handlers. +// We do one at a time, on each background call. +void bonding_background(void) { + + // Get block at front of list. + sd_mutex_acquire_wait(&queued_bonding_block_list_mutex); + bonding_block_t *block = &(MP_STATE_VM(queued_bonding_block_list)->bonding_block); + if (block) { + // Remove written block from front of list. + MP_STATE_VM(queued_bonding_block_list) = MP_STATE_VM(queued_bonding_block_list)->next_queued_block; + } + sd_mutex_release(&queued_bonding_block_list_mutex); + + if (!block) { + // No blocks in queue. + return; + } + + // Is there an existing block whose keys match? + bonding_block_t *matching_block = find_block(block->is_central, block->type, block->ediv); + if (matching_block) { + if (block->data_length == matching_block->data_length && + memcmp(block->data, matching_block->data, block->data_length) == 0) { + // Identical block found. No need to store again. + BONDING_DEBUG_PRINTF("bonding_background(): identical block found\n"); + return; + } + // Block keys match but data doesn't. Invalidate block and store a new one. + BONDING_DEBUG_PRINTF("bonding_background(): invalidating block\n"); + invalidate_block(matching_block); + } + + switch (block->type) { + case BLOCK_SYS_ATTR: + write_sys_attr_block(block); + break; + + case BLOCK_KEYS: + write_keys_block(block); + break; + + default: + break; + } +} + +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { + bonding_block_t *block = find_block(is_central, BLOCK_SYS_ATTR, ediv); + if (block == NULL) { + BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block not found\n"); return false; } + + BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block found\n"); + return NRF_SUCCESS == + sd_ble_gatts_sys_attr_set(conn_handle, block->data, block->data_length, SYS_ATTR_FLAGS); } bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { - bonding_block_t *block = bonding_find_matching_block(BLOCK_SYS_ATTR, ediv); - if (block) { - memcpy(bonding_keys, block.data, block.data_length); - return true; - } else { + bonding_block_t *block = find_block(is_central, BLOCK_SYS_ATTR, ediv); + if (block == NULL) { + BONDING_DEBUG_PRINTF("bonding_load_keys(): block not found\n"); return false; } + if (sizeof(bonding_keys_t) != block->data_length) { + // bonding_keys_t is a fixed length, so lengths should match. + return false; + } + + BONDING_DEBUG_PRINTF("bonding_load_keys(): block found\n"); + memcpy(bonding_keys, block->data, block->data_length); + return true; } -bool bonding_save_cccd_info_later(bool is_central, uint16_t conn_handle, uint16_t ediv, uint8_t *sys_attr, uint16_t sys_attr_len) { - // save in id role/ediv - // sys_attr - -bool bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys) { - // save in id role/ediv: - // bonding keys - // peer name, or if no name, then human-readable address +void bonding_save_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { + queue_write_block(is_central, ediv, conn_handle, BLOCK_SYS_ATTR, NULL, 0); +} + +void bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys) { + uint16_t const ediv = is_central + ? bonding_keys->peer_enc.master_id.ediv + : bonding_keys->own_enc.master_id.ediv; + queue_write_block(is_central, BLOCK_KEYS, ediv, conn_handle, (uint8_t *) bonding_keys, sizeof(bonding_keys_t)); } diff --git a/ports/nrf/common-hal/_bleio/bonding.h b/ports/nrf/common-hal/_bleio/bonding.h index 906d9d1949..1b0083865f 100644 --- a/ports/nrf/common-hal/_bleio/bonding.h +++ b/ports/nrf/common-hal/_bleio/bonding.h @@ -24,20 +24,64 @@ * THE SOFTWARE. */ +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BONDING_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BONDING_H + #include #include #include #include "ble.h" #include "ble_drv.h" -#include "shared-bindings/_bleio/__init__.h" -#include "shared-bindings/_bleio/Adapter.h" -#include "shared-bindings/nvm/ByteArray.h" +#include "common-hal/_bleio/__init__.h" #define EDIV_INVALID (0xffff) +#define BONDING_DEBUG (1) +#if BONDING_DEBUG + #define BONDING_DEBUG_PRINTF(...) printf(__VA_ARGS__) +#else + #define BONDING_DEBUG_PRINTF(...) +#endif + +// Bonding data is stored in variable-length blocks consecutively in erased flash. +// The blocks are 32-bit aligned, though the data may be any number of bytes. +// You can hop through the blocks using the size field to find the next block. +// When you hit a word that is all one's, you have reached the end of the blocks. +// You can write a new block there. + +typedef enum { + BLOCK_INVALID = 0, // Ignore this block + BLOCK_KEYS = 1, // Block contains bonding keys. + BLOCK_SYS_ATTR = 2, // Block contains sys_attr values (CCCD settings, etc.). + BLOCK_UNUSED = 0xff, // Initial erased value. +} bonding_block_type_t; + +typedef struct { + bool is_central: 1; // 1 if data is for a central role. + uint16_t reserved: 7; // Not currently used + bonding_block_type_t type: 8; // What kind of data is stored in. + uint16_t ediv; // ediv value; used as a lookup key. + uint16_t conn_handle; // Connection handle: used when a BLOCK_SYS_ATTR is queued to write. + // Not used as a key, etc. + uint16_t data_length; // Length of data in bytes, including ediv, not including padding. + // 32-bit boundary here. + uint8_t data[]; // Rest of data in the block. Needs to be 32-bit aligned. + // Block is padded to 32-bit alignment. +} bonding_block_t; + +// Bonding blocks that need to be written are stored in a linked list. +typedef struct _queued_bonding_block_list_elt_t { + struct _queued_bonding_block_list_elt_t *next_queued_block; + bonding_block_t bonding_block; // variable length, based on data_length. +} queued_bonding_block_list_elt_t; + +void bonding_background(void); +void bonding_reset(void); void bonding_clear_keys(bonding_keys_t *bonding_keys); bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys); -bool bonding_save_cccd_info_later(bool is_central, uint16_t conn_handle, uint16_t ediv, uint8_t *sys_attr, uint16_t sys_attr_len); -bool bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys); +void bonding_save_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); +void bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys); + +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BONDING_H diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index cb25870dc0..14f7632fd1 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -29,6 +29,7 @@ #define NRF5_MPCONFIGPORT_H__ #include "ble_drv.h" +#include "common-hal/_bleio/bonding.h" #include "nrf_mbr.h" // for MBR_SIZE #include "nrf_sdm.h" // for SD_FLASH_SIZE @@ -152,10 +153,10 @@ #endif - - #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS \ ble_drv_evt_handler_entry_t* ble_drv_evt_handler_entries; \ + queued_bonding_block_list_elt_t* queued_bonding_block_list; \ + #endif // NRF5_MPCONFIGPORT_H__ From 59ded1131f5d247ffb64b86d99f3297e75fe6fe5 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Mon, 6 Jan 2020 14:06:42 +0100 Subject: [PATCH 283/531] Take display offsets for PewPew M4 from the bootloader config The PewPew M4 devices come with different displays, which require different offsets. Since the information about offsets is saved in the bootloader, we can take it from there. --- ports/atmel-samd/boards/pewpew_m4/board.c | 37 ++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index b684f56016..5f5a01e48e 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -35,8 +35,36 @@ displayio_fourwire_obj_t board_display_obj; +typedef struct { + const uint32_t *config_data; + void *handoverHID; + void *handoverMSC; + const char *info_uf2; +} UF2_BInfo; + +#define APP_START_ADDRESS 0x00004000 +#define UF2_BINFO ((UF2_BInfo *)(APP_START_ADDRESS - sizeof(UF2_BInfo))) + +#define CFG_DISPLAY_CFG0 39 +#define CFG_MAGIC0 0x1e9e10f1 + #define DELAY 0x80 +uint32_t lookupCfg(uint32_t key, uint32_t defl) { + const uint32_t *ptr = UF2_BINFO->config_data; + if (!ptr || (((uint32_t)ptr) & 3) || *ptr != CFG_MAGIC0) { + // no config data! + } else { + ptr += 4; + while (*ptr) { + if (*ptr == key) + return ptr[1]; + ptr += 2; + } + } + return defl; +} + uint8_t display_init_sequence[] = { 0x01, 0 | DELAY, 150, // SWRESET 0x11, 0 | DELAY, 255, // SLPOUT @@ -63,8 +91,6 @@ uint8_t display_init_sequence[] = { 0x2E, 0x2C, 0x29, 0x2D, 0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10, - 0x2a, 3, 0x02, 0x00, 0x81, // _CASET XSTART = 2, XEND = 129 - 0x2b, 3, 0x02, 0x00, 0x81, // _RASET XSTART = 2, XEND = 129 0x13, 0 | DELAY, 10, // _NORON 0x29, 0 | DELAY, 100, // _DISPON }; @@ -83,14 +109,17 @@ void board_init(void) { &pin_PA17, // TFT_RST Reset 60000000); + uint32_t cfg0 = lookupCfg(CFG_DISPLAY_CFG0, 0x000000); + uint32_t offX = (cfg0 >> 8) & 0xff; + uint32_t offY = (cfg0 >> 16) & 0xff; 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) 128, // Height (after rotation) - 0, // column start - 0, // row start + offX, // column start + offY, // row start 0, // rotation 16, // Color depth false, // grayscale From dc729718eb2980e3b92a54e4cc60c7d6b0720e8a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 6 Jan 2020 07:51:41 -0600 Subject: [PATCH 284/531] audiomp3: rename to MP3Decoder --- shared-bindings/audiomp3/{MP3File.c => MP3Decoder.c} | 12 +++++------- shared-bindings/audiomp3/{MP3File.h => MP3Decoder.h} | 2 +- shared-bindings/audiomp3/__init__.c | 6 +++--- shared-module/audiomp3/{MP3File.c => MP3Decoder.c} | 0 shared-module/audiomp3/{MP3File.h => MP3Decoder.h} | 0 5 files changed, 9 insertions(+), 11 deletions(-) rename shared-bindings/audiomp3/{MP3File.c => MP3Decoder.c} (96%) rename shared-bindings/audiomp3/{MP3File.h => MP3Decoder.h} (98%) rename shared-module/audiomp3/{MP3File.c => MP3Decoder.c} (100%) rename shared-module/audiomp3/{MP3File.h => MP3Decoder.h} (100%) diff --git a/shared-bindings/audiomp3/MP3File.c b/shared-bindings/audiomp3/MP3Decoder.c similarity index 96% rename from shared-bindings/audiomp3/MP3File.c rename to shared-bindings/audiomp3/MP3Decoder.c index a02e42364d..a93206e15e 100644 --- a/shared-bindings/audiomp3/MP3File.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -30,18 +30,16 @@ #include "lib/utils/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/audiomp3/MP3File.h" +#include "shared-bindings/audiomp3/MP3Decoder.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" //| .. currentmodule:: audiomp3 //| -//| :class:`MP3` -- Load a mp3 file for audio playback +//| :class:`MP3Decoder` -- Load a mp3 file for audio playback //| ======================================================== //| -//| A .mp3 file prepped for audio playback. Only mono and stereo files are supported. Samples must -//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating -//| an internal buffer. +//| An object that decodes MP3 files for playback on an audio device. //| //| .. class:: MP3(file[, buffer]) //| @@ -63,7 +61,7 @@ //| speaker_enable.switch_to_output(value=True) //| //| data = open("cplay-16bit-16khz-64kbps.mp3", "rb") -//| mp3 = audiomp3.MP3File(data) +//| mp3 = audiomp3.MP3Decoder(data) //| a = audioio.AudioOut(board.A0) //| //| print("playing") @@ -270,7 +268,7 @@ STATIC const audiosample_p_t audiomp3_mp3file_proto = { const mp_obj_type_t audiomp3_mp3file_type = { { &mp_type_type }, - .name = MP_QSTR_MP3File, + .name = MP_QSTR_MP3Decoder, .make_new = audiomp3_mp3file_make_new, .locals_dict = (mp_obj_dict_t*)&audiomp3_mp3file_locals_dict, .protocol = &audiomp3_mp3file_proto, diff --git a/shared-bindings/audiomp3/MP3File.h b/shared-bindings/audiomp3/MP3Decoder.h similarity index 98% rename from shared-bindings/audiomp3/MP3File.h rename to shared-bindings/audiomp3/MP3Decoder.h index e6787cb8b3..36d525e938 100644 --- a/shared-bindings/audiomp3/MP3File.h +++ b/shared-bindings/audiomp3/MP3Decoder.h @@ -31,7 +31,7 @@ #include "py/obj.h" #include "extmod/vfs_fat.h" -#include "shared-module/audiomp3/MP3File.h" +#include "shared-module/audiomp3/MP3Decoder.h" extern const mp_obj_type_t audiomp3_mp3file_type; diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c index 06f852ff1c..fb2187669c 100644 --- a/shared-bindings/audiomp3/__init__.c +++ b/shared-bindings/audiomp3/__init__.c @@ -29,7 +29,7 @@ #include "py/obj.h" #include "py/runtime.h" -#include "shared-bindings/audiomp3/MP3File.h" +#include "shared-bindings/audiomp3/MP3Decoder.h" //| :mod:`audiomp3` --- Support for MP3-compressed audio files //| ========================================================== @@ -44,12 +44,12 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| MP3File +//| MP3Decoder //| STATIC const mp_rom_map_elem_t audiomp3_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiomp3) }, - { MP_ROM_QSTR(MP_QSTR_MP3File), MP_ROM_PTR(&audiomp3_mp3file_type) }, + { MP_ROM_QSTR(MP_QSTR_MP3Decoder), MP_ROM_PTR(&audiomp3_mp3file_type) }, }; STATIC MP_DEFINE_CONST_DICT(audiomp3_module_globals, audiomp3_module_globals_table); diff --git a/shared-module/audiomp3/MP3File.c b/shared-module/audiomp3/MP3Decoder.c similarity index 100% rename from shared-module/audiomp3/MP3File.c rename to shared-module/audiomp3/MP3Decoder.c diff --git a/shared-module/audiomp3/MP3File.h b/shared-module/audiomp3/MP3Decoder.h similarity index 100% rename from shared-module/audiomp3/MP3File.h rename to shared-module/audiomp3/MP3Decoder.h From b1b4a9e8428fba462211ab1ec39d52cbf0fb6c5a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 6 Jan 2020 09:26:32 -0600 Subject: [PATCH 285/531] fix doc build error --- shared-bindings/audiomp3/MP3Decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index a93206e15e..2240422127 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -37,7 +37,7 @@ //| .. currentmodule:: audiomp3 //| //| :class:`MP3Decoder` -- Load a mp3 file for audio playback -//| ======================================================== +//| ========================================================= //| //| An object that decodes MP3 files for playback on an audio device. //| From 7198cc8ed6d079aa54fa975b6c781c865271c136 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 6 Jan 2020 11:30:10 -0500 Subject: [PATCH 286/531] Changes to UF2 settings, reboot working, no usb --- ports/stm32f4/Makefile | 4 ++-- ports/stm32f4/boards/STM32F401_boot.ld | 2 +- .../boards/meowbit_v121/mpconfigboard.h | 8 ++++---- .../boards/meowbit_v121/mpconfigboard.mk | 18 +++++++++--------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 2727ea954f..6c5190668f 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -22,7 +22,7 @@ # 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. -DEBUG = 1 +#DEBUG = 1 # Select the board to build for. ifeq ($(BOARD),) @@ -256,7 +256,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(ECHO) "Create $@" - $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/firmware.uf2" $^ + $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b 0x08010000 -c -o "$(BUILD)/firmware.uf2" $^ include $(TOP)/py/mkrules.mk diff --git a/ports/stm32f4/boards/STM32F401_boot.ld b/ports/stm32f4/boards/STM32F401_boot.ld index 64f78451ad..ffdd7097cb 100644 --- a/ports/stm32f4/boards/STM32F401_boot.ld +++ b/ports/stm32f4/boards/STM32F401_boot.ld @@ -8,7 +8,7 @@ MEMORY FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */ FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K + RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 } /* produce a link error if there is not this amount of RAM for these sections */ diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index e97d793bed..0371685d8b 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -39,7 +39,7 @@ #define BOARD_NO_VBUS_SENSE // On-board flash -// #define SPI_FLASH_MOSI_PIN (&pin_PB15) -// #define SPI_FLASH_MISO_PIN (&pin_PB14) -// #define SPI_FLASH_SCK_PIN (&pin_PB13) -// #define SPI_FLASH_CS_PIN (&pin_PB01) +#define SPI_FLASH_MOSI_PIN (&pin_PB15) +#define SPI_FLASH_MISO_PIN (&pin_PB14) +#define SPI_FLASH_SCK_PIN (&pin_PB13) +#define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 1642120e80..e40f9d80ca 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -2,21 +2,21 @@ USB_VID = 0x239A USB_PID = 0x805A USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" -USB_DEVICES = "CDC,MSC" +USB_DEVICES = "CDC" -# SPI_FLASH_FILESYSTEM = 1 -# EXTERNAL_FLASH_DEVICE_COUNT = 1 -# EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ -# LONGINT_IMPL = MPZ +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ +LONGINT_IMPL = MPZ -INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = NONE +# INTERNAL_FLASH_FILESYSTEM = 1 +# LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401_fs.ld +LD_FILE = boards/STM32F401_boot.ld #STM32F401_fs.ld TEXT0_ADDR = 0x08010000 -TEXT1_ADDR = 0x08020000 \ No newline at end of file +TEXT1_ADDR = 0x08040000 \ No newline at end of file From dd6010a17ef8e12e1cb3f36721b205cc1cb8eee9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 6 Jan 2020 13:35:43 -0600 Subject: [PATCH 287/531] Fix more build problems --- py/circuitpy_defns.mk | 2 +- shared-module/audiomp3/MP3Decoder.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 8dd4fc6b16..38b41c619b 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -322,7 +322,7 @@ SRC_SHARED_MODULE_ALL = \ audiomixer/Mixer.c \ audiomixer/MixerVoice.c \ audiomp3/__init__.c \ - audiomp3/MP3File.c \ + audiomp3/MP3Decoder.c \ bitbangio/I2C.c \ bitbangio/OneWire.c \ bitbangio/SPI.c \ diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index 515aa00863..30357c6161 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/audiomp3/MP3File.h" +#include "shared-bindings/audiomp3/MP3Decoder.h" #include #include @@ -34,7 +34,7 @@ #include "py/mperrno.h" #include "py/runtime.h" -#include "shared-module/audiomp3/MP3File.h" +#include "shared-module/audiomp3/MP3Decoder.h" #include "supervisor/shared/translate.h" #include "lib/mp3/src/mp3common.h" From 13e0cba6f18c1b569cf014fb4e3f0156ba63622e Mon Sep 17 00:00:00 2001 From: arturo182 Date: Sat, 2 Nov 2019 16:52:26 +0100 Subject: [PATCH 288/531] Add initial MIMXRT10XX port --- .github/workflows/build.yml | 3 + .gitmodules | 3 + conf.py | 2 + docs/shared_bindings_matrix.py | 2 +- docs/supported_ports.rst | 1 + ports/mimxrt10xx/.gitignore | 1 + ports/mimxrt10xx/Makefile | 253 ++++++++ ports/mimxrt10xx/README.md | 3 + ports/mimxrt10xx/background.c | 82 +++ ports/mimxrt10xx/background.h | 38 ++ ports/mimxrt10xx/boards/board.h | 48 ++ .../boards/feather_mimxrt1011/board.c | 55 ++ .../boards/feather_mimxrt1011/mpconfigboard.h | 31 + .../feather_mimxrt1011/mpconfigboard.mk | 21 + .../boards/feather_mimxrt1011/pins.c | 52 ++ .../boards/feather_mimxrt1062/board.c | 55 ++ .../boards/feather_mimxrt1062/mpconfigboard.h | 31 + .../feather_mimxrt1062/mpconfigboard.mk | 21 + .../boards/feather_mimxrt1062/pins.c | 45 ++ ports/mimxrt10xx/boards/imxrt1010_evk/board.c | 55 ++ .../boards/imxrt1010_evk/mpconfigboard.h | 31 + .../boards/imxrt1010_evk/mpconfigboard.mk | 22 + ports/mimxrt10xx/boards/imxrt1010_evk/pins.c | 37 ++ .../mimxrt1011-bootloader-external-flash.ld | 106 ++++ .../boards/mimxrt1011-external-flash.ld | 123 ++++ .../mimxrt1062-bootloader-external-flash.ld | 106 ++++ .../mimxrt10xx/common-hal/analogio/AnalogIn.c | 88 +++ .../mimxrt10xx/common-hal/analogio/AnalogIn.h | 40 ++ .../common-hal/analogio/AnalogOut.c | 46 ++ .../common-hal/analogio/AnalogOut.h | 37 ++ .../mimxrt10xx/common-hal/analogio/__init__.c | 1 + ports/mimxrt10xx/common-hal/board/__init__.c | 35 ++ ports/mimxrt10xx/common-hal/busio/I2C.c | 192 ++++++ ports/mimxrt10xx/common-hal/busio/I2C.h | 44 ++ ports/mimxrt10xx/common-hal/busio/OneWire.h | 33 ++ ports/mimxrt10xx/common-hal/busio/SPI.c | 318 ++++++++++ ports/mimxrt10xx/common-hal/busio/SPI.h | 46 ++ ports/mimxrt10xx/common-hal/busio/UART.c | 252 ++++++++ ports/mimxrt10xx/common-hal/busio/UART.h | 54 ++ ports/mimxrt10xx/common-hal/busio/__init__.c | 1 + .../common-hal/digitalio/DigitalInOut.c | 170 ++++++ .../common-hal/digitalio/DigitalInOut.h | 43 ++ .../common-hal/digitalio/__init__.c | 1 + .../common-hal/microcontroller/Pin.c | 226 +++++++ .../common-hal/microcontroller/Pin.h | 51 ++ .../common-hal/microcontroller/Processor.c | 65 +++ .../common-hal/microcontroller/Processor.h | 40 ++ .../common-hal/microcontroller/__init__.c | 284 +++++++++ .../common-hal/neopixel_write/__init__.c | 106 ++++ ports/mimxrt10xx/common-hal/os/__init__.c | 72 +++ ports/mimxrt10xx/common-hal/pulseio/PWMOut.c | 551 ++++++++++++++++++ ports/mimxrt10xx/common-hal/pulseio/PWMOut.h | 44 ++ ports/mimxrt10xx/common-hal/pulseio/PulseIn.c | 248 ++++++++ ports/mimxrt10xx/common-hal/pulseio/PulseIn.h | 55 ++ .../mimxrt10xx/common-hal/pulseio/PulseOut.c | 207 +++++++ .../mimxrt10xx/common-hal/pulseio/PulseOut.h | 45 ++ .../mimxrt10xx/common-hal/pulseio/__init__.c | 1 + ports/mimxrt10xx/common-hal/rtc/RTC.c | 76 +++ ports/mimxrt10xx/common-hal/rtc/RTC.h | 34 ++ ports/mimxrt10xx/common-hal/rtc/__init__.c | 0 .../common-hal/supervisor/Runtime.c | 37 ++ .../common-hal/supervisor/Runtime.h | 37 ++ .../common-hal/supervisor/__init__.c | 40 ++ ports/mimxrt10xx/common-hal/time/__init__.c | 39 ++ ports/mimxrt10xx/fatfs_port.c | 48 ++ ports/mimxrt10xx/mpconfigport.h | 51 ++ ports/mimxrt10xx/mpconfigport.mk | 20 + ports/mimxrt10xx/mphalport.c | 65 +++ ports/mimxrt10xx/mphalport.h | 52 ++ .../mimxrt10xx/MIMXRT1011/clocks.c | 293 ++++++++++ .../mimxrt10xx/MIMXRT1011/periph.c | 148 +++++ .../mimxrt10xx/MIMXRT1011/periph.h | 42 ++ .../peripherals/mimxrt10xx/MIMXRT1011/pins.c | 77 +++ .../peripherals/mimxrt10xx/MIMXRT1011/pins.h | 77 +++ .../mimxrt10xx/MIMXRT1062/clocks.c | 366 ++++++++++++ .../mimxrt10xx/MIMXRT1062/periph.c | 270 +++++++++ .../mimxrt10xx/MIMXRT1062/periph.h | 42 ++ .../peripherals/mimxrt10xx/MIMXRT1062/pins.c | 161 +++++ .../peripherals/mimxrt10xx/MIMXRT1062/pins.h | 161 +++++ .../peripherals/mimxrt10xx/clocks.h | 29 + .../peripherals/mimxrt10xx/periph.h | 77 +++ .../mimxrt10xx/peripherals/mimxrt10xx/pins.h | 75 +++ ports/mimxrt10xx/qstrdefsport.h | 1 + ports/mimxrt10xx/reset.c | 39 ++ ports/mimxrt10xx/reset.h | 43 ++ ports/mimxrt10xx/sdk | 1 + ports/mimxrt10xx/supervisor/cpu.S | 27 + .../supervisor/flexspi_nor_flash_ops.c | 347 +++++++++++ ports/mimxrt10xx/supervisor/internal_flash.c | 255 ++++++++ ports/mimxrt10xx/supervisor/internal_flash.h | 53 ++ .../supervisor/internal_flash_root_pointers.h | 31 + ports/mimxrt10xx/supervisor/port.c | 168 ++++++ ports/mimxrt10xx/supervisor/serial.c | 93 +++ ports/mimxrt10xx/supervisor/usb.c | 56 ++ ports/mimxrt10xx/tick.c | 92 +++ ports/mimxrt10xx/tick.h | 43 ++ tools/uf2 | 2 +- 97 files changed, 8189 insertions(+), 2 deletions(-) create mode 100644 ports/mimxrt10xx/.gitignore create mode 100644 ports/mimxrt10xx/Makefile create mode 100644 ports/mimxrt10xx/README.md create mode 100644 ports/mimxrt10xx/background.c create mode 100644 ports/mimxrt10xx/background.h create mode 100644 ports/mimxrt10xx/boards/board.h create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1011/board.c create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1062/board.c create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c create mode 100644 ports/mimxrt10xx/boards/imxrt1010_evk/board.c create mode 100644 ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/imxrt1010_evk/pins.c create mode 100644 ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld create mode 100644 ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld create mode 100644 ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld create mode 100644 ports/mimxrt10xx/common-hal/analogio/AnalogIn.c create mode 100644 ports/mimxrt10xx/common-hal/analogio/AnalogIn.h create mode 100644 ports/mimxrt10xx/common-hal/analogio/AnalogOut.c create mode 100644 ports/mimxrt10xx/common-hal/analogio/AnalogOut.h create mode 100644 ports/mimxrt10xx/common-hal/analogio/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/board/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/busio/I2C.c create mode 100644 ports/mimxrt10xx/common-hal/busio/I2C.h create mode 100644 ports/mimxrt10xx/common-hal/busio/OneWire.h create mode 100644 ports/mimxrt10xx/common-hal/busio/SPI.c create mode 100644 ports/mimxrt10xx/common-hal/busio/SPI.h create mode 100644 ports/mimxrt10xx/common-hal/busio/UART.c create mode 100644 ports/mimxrt10xx/common-hal/busio/UART.h create mode 100644 ports/mimxrt10xx/common-hal/busio/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c create mode 100644 ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h create mode 100644 ports/mimxrt10xx/common-hal/digitalio/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/microcontroller/Pin.c create mode 100644 ports/mimxrt10xx/common-hal/microcontroller/Pin.h create mode 100644 ports/mimxrt10xx/common-hal/microcontroller/Processor.c create mode 100644 ports/mimxrt10xx/common-hal/microcontroller/Processor.h create mode 100644 ports/mimxrt10xx/common-hal/microcontroller/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/neopixel_write/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/os/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/pulseio/PWMOut.c create mode 100644 ports/mimxrt10xx/common-hal/pulseio/PWMOut.h create mode 100644 ports/mimxrt10xx/common-hal/pulseio/PulseIn.c create mode 100644 ports/mimxrt10xx/common-hal/pulseio/PulseIn.h create mode 100644 ports/mimxrt10xx/common-hal/pulseio/PulseOut.c create mode 100644 ports/mimxrt10xx/common-hal/pulseio/PulseOut.h create mode 100644 ports/mimxrt10xx/common-hal/pulseio/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/rtc/RTC.c create mode 100644 ports/mimxrt10xx/common-hal/rtc/RTC.h create mode 100644 ports/mimxrt10xx/common-hal/rtc/__init__.c create mode 100755 ports/mimxrt10xx/common-hal/supervisor/Runtime.c create mode 100755 ports/mimxrt10xx/common-hal/supervisor/Runtime.h create mode 100755 ports/mimxrt10xx/common-hal/supervisor/__init__.c create mode 100644 ports/mimxrt10xx/common-hal/time/__init__.c create mode 100644 ports/mimxrt10xx/fatfs_port.c create mode 100644 ports/mimxrt10xx/mpconfigport.h create mode 100644 ports/mimxrt10xx/mpconfigport.mk create mode 100644 ports/mimxrt10xx/mphalport.c create mode 100644 ports/mimxrt10xx/mphalport.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/clocks.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h create mode 100644 ports/mimxrt10xx/qstrdefsport.h create mode 100644 ports/mimxrt10xx/reset.c create mode 100644 ports/mimxrt10xx/reset.h create mode 160000 ports/mimxrt10xx/sdk create mode 100755 ports/mimxrt10xx/supervisor/cpu.S create mode 100644 ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c create mode 100644 ports/mimxrt10xx/supervisor/internal_flash.c create mode 100644 ports/mimxrt10xx/supervisor/internal_flash.h create mode 100644 ports/mimxrt10xx/supervisor/internal_flash_root_pointers.h create mode 100644 ports/mimxrt10xx/supervisor/port.c create mode 100644 ports/mimxrt10xx/supervisor/serial.c create mode 100644 ports/mimxrt10xx/supervisor/usb.c create mode 100644 ports/mimxrt10xx/tick.c create mode 100644 ports/mimxrt10xx/tick.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 903948657c..041b8b27cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -102,6 +102,8 @@ jobs: - "feather_m0_rfm9x" - "feather_m0_supersized" - "feather_m4_express" + - "feather_mimxrt1011" + - "feather_mimxrt1062" - "feather_nrf52840_express" - "feather_radiofruit_zigbee" - "feather_stm32f405_express" @@ -109,6 +111,7 @@ jobs: - "grandcentral_m4_express" - "hallowing_m0_express" - "hallowing_m4_express" + - "imxrt1010_evk" - "itsybitsy_m0_express" - "itsybitsy_m4_express" - "itsybitsy_nrf52840_express" diff --git a/.gitmodules b/.gitmodules index da2360cb72..44fc818c84 100644 --- a/.gitmodules +++ b/.gitmodules @@ -108,3 +108,6 @@ [submodule "lib/mp3"] path = lib/mp3 url = https://github.com/adafruit/Adafruit_MP3 +[submodule "ports/mimxrt10xx/sdk"] + path = ports/mimxrt10xx/sdk + url = https://github.com/arturo182/MIMXRT10xx_SDK diff --git a/conf.py b/conf.py index 2e48703c93..abee78aba9 100644 --- a/conf.py +++ b/conf.py @@ -131,6 +131,8 @@ exclude_patterns = ["**/build*", "ports/esp8266/common-hal", "ports/esp8266/modules", "ports/minimal", + "ports/mimxrt10xx/peripherals", + "ports/mimxrt10xx/sdk", "ports/nrf/device", "ports/nrf/bluetooth", "ports/nrf/modules", diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index ba0ec0e4f9..6e0fc34bdd 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -26,7 +26,7 @@ import os import re -SUPPORTED_PORTS = ["atmel-samd", "nrf"] +SUPPORTED_PORTS = ["atmel-samd", "nrf", "mimxrt10xx"] def parse_port_config(contents, chip_keyword=None): diff --git a/docs/supported_ports.rst b/docs/supported_ports.rst index 13f1e65076..9416a9c4f5 100644 --- a/docs/supported_ports.rst +++ b/docs/supported_ports.rst @@ -8,6 +8,7 @@ and ESP8266. :maxdepth: 2 ../ports/atmel-samd/README + ../ports/mimxrt10xx/README ../ports/nrf/README ../ports/stm32f4/README ../ports/cxd56/README diff --git a/ports/mimxrt10xx/.gitignore b/ports/mimxrt10xx/.gitignore new file mode 100644 index 0000000000..414487d53e --- /dev/null +++ b/ports/mimxrt10xx/.gitignore @@ -0,0 +1 @@ +build-*/ diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile new file mode 100644 index 0000000000..68ddea565c --- /dev/null +++ b/ports/mimxrt10xx/Makefile @@ -0,0 +1,253 @@ +# This file is part of the MicroPython project, http://micropython.org/ +# +# The MIT License (MIT) +# +# Copyright (c) 2019 Dan Halbert 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. + +# Select the board to build for. +ifeq ($(BOARD),) + $(error You must provide a BOARD parameter) +else + ifeq ($(wildcard boards/$(BOARD)/.),) + $(error Invalid BOARD specified) + endif +endif + +# If the build directory is not given, make it reflect the board name. +BUILD ?= build-$(BOARD) + +include ../../py/mkenv.mk +# Board-specific +include boards/$(BOARD)/mpconfigboard.mk +# Port-specific +include mpconfigport.mk +# CircuitPython-specific +include $(TOP)/py/circuitpy_mpconfig.mk + +# qstr definitions (must come before including py.mk) +QSTR_DEFS = qstrdefsport.h + +# include py core make definitions +include $(TOP)/py/py.mk + +include $(TOP)/supervisor/supervisor.mk + +# Include make rules and variables common across CircuitPython builds. +include $(TOP)/py/circuitpy_defns.mk + +CROSS_COMPILE = arm-none-eabi- + +INC += \ + -I. \ + -I../.. \ + -I../lib/mp-readline \ + -I../lib/timeutils \ + -I../../lib/tinyusb/src \ + -I../../supervisor/shared/usb \ + -I$(BUILD) \ + -Iboards/ \ + -Iboards/$(BOARD) \ + -Iperipherals/ \ + -Iperipherals/mimxrt10xx/ \ + -Isdk/CMSIS/Include \ + -Isdk/devices/$(CHIP_FAMILY) \ + -Isdk/devices/$(CHIP_FAMILY)/drivers \ + +# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt. + +CFLAGS += -Os -DNDEBUG + +# TinyUSB defines +CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024 + +#Debugging/Optimization +ifeq ($(DEBUG), 1) + CFLAGS += -ggdb + # You may want to disable -flto if it interferes with debugging. + #CFLAGS += -flto -flto-partition=none + # You may want to enable these flags to make setting breakpoints easier. + CFLAGS += -fno-inline -fno-ipa-sra +else + # -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_SMALL_BUILD),1) + CFLAGS_INLINE_LIMIT = 50 + endif + endif + + ifdef CFLAGS_INLINE_LIMIT + CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT) + endif + #CFLAGS += -flto -flto-partition=none +endif + +CFLAGS += $(INC) -Wall -Wno-cast-align -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) + +CFLAGS += \ + -mthumb \ + -mapcs \ + -mcpu=cortex-m7 \ + -mfloat-abi=hard \ + -mfpu=fpv5-sp-d16 \ + -DCPU_$(CHIP_VARIANT) \ + -DDEBUG \ + -DXIP_EXTERNAL_FLASH=1 \ + -DXIP_BOOT_HEADER_ENABLE=1 \ + -D__START=main \ + -Os -g3 -Wno-unused-parameter \ + -ffunction-sections -fdata-sections -fstack-usage \ + -D__STARTUP_CLEAR_BSS + +LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs +LIBS := -lgcc -lc -lnosys -lm + +# Use toolchain libm if we're not using our own. +ifndef INTERNAL_LIBM +LIBS += -lm +endif + +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_tempmon.c \ + drivers/fsl_trng.c \ + system_$(CHIP_FAMILY).c \ + +SRC_SDK := $(addprefix sdk/devices/$(CHIP_FAMILY)/, $(SRC_SDK)) + +SRC_C = \ + background.c \ + boards/$(BOARD)/board.c \ + boards/$(BOARD)/pins.c \ + fatfs_port.c \ + lib/mp-readline/readline.c \ + lib/oofatfs/ff.c \ + lib/oofatfs/option/ccsbcs.c \ + lib/timeutils/timeutils.c \ + lib/utils/buffer_helper.c \ + lib/utils/context_manager_helpers.c \ + lib/utils/interrupt_char.c \ + lib/utils/pyexec.c \ + lib/utils/stdout_helpers.c \ + lib/utils/sys_stdio_mphal.c \ + lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c \ + mphalport.c \ + peripherals/mimxrt10xx/$(CHIP_FAMILY)/clocks.c \ + peripherals/mimxrt10xx/$(CHIP_FAMILY)/periph.c \ + peripherals/mimxrt10xx/$(CHIP_FAMILY)/pins.c \ + reset.c \ + supervisor/flexspi_nor_flash_ops.c \ + supervisor/shared/memory.c \ + tick.c + +ifeq ($(CIRCUITPY_NETWORK),1) +CFLAGS += -DMICROPY_PY_NETWORK=1 + +SRC_MOD += lib/netutils/netutils.c + +ifneq ($(MICROPY_PY_WIZNET5K),0) +WIZNET5K_DIR=drivers/wiznet5k +INC += -I$(TOP)/$(WIZNET5K_DIR) +CFLAGS_MOD += -DMICROPY_PY_WIZNET5K=$(MICROPY_PY_WIZNET5K) -D_WIZCHIP_=$(MICROPY_PY_WIZNET5K) +SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\ + ethernet/w$(MICROPY_PY_WIZNET5K)/w$(MICROPY_PY_WIZNET5K).c \ + ethernet/wizchip_conf.c \ + ethernet/socket.c \ + internet/dns/dns.c \ + internet/dhcp/dhcp.c \ + ) + +endif # MICROPY_PY_WIZNET5K +endif # CIRCUITPY_NETWORK + +ifeq ($(CIRCUITPY_NETWORK),1) +ifneq ($(MICROPY_PY_WIZNET5K),0) +SRC_SHARED_MODULE += wiznet/__init__.c wiznet/wiznet5k.c +endif +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)) + +SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \ + $(addprefix shared-module/, $(SRC_SHARED_MODULE)) \ + $(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL)) + +SRC_S = \ + sdk/devices/$(CHIP_FAMILY)/gcc/startup_$(CHIP_FAMILY).S \ + supervisor/cpu.S + +OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(SRC_SDK:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o)) +ifeq ($(INTERNAL_LIBM),1) +OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o)) +endif +OBJ += $(addprefix $(BUILD)/, $(SRC_S:.S=.o)) +OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o)) + +SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) + +all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 + +$(BUILD)/firmware.elf: $(LD_FILE) $(OBJ) + $(STEPECHO) "LINK $@" + $(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out $<,$^) -Wl,--start-group $(LIBS) -Wl,--end-group + +$(BUILD)/firmware.bin: $(BUILD)/firmware.elf + $(STEPECHO) "Create $@" + $(Q)$(OBJCOPY) -O binary -j .interrupts -j .text -j .ARM.exidx -j .data $^ $@ + +$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin + $(STEPECHO) "Create $@" + $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $^ + +include $(TOP)/py/mkrules.mk + +# Print out the value of a make variable. +# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile +print-%: + @echo $* = $($*) diff --git a/ports/mimxrt10xx/README.md b/ports/mimxrt10xx/README.md new file mode 100644 index 0000000000..fe7fd5ea69 --- /dev/null +++ b/ports/mimxrt10xx/README.md @@ -0,0 +1,3 @@ +# CircuitPython Port To The NXP i.MX RT10xx Series + +This is a port of CircuitPython to the i.MX RT10xx series of chips. diff --git a/ports/mimxrt10xx/background.c b/ports/mimxrt10xx/background.c new file mode 100644 index 0000000000..8c7333cf8b --- /dev/null +++ b/ports/mimxrt10xx/background.c @@ -0,0 +1,82 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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 "background.h" + +//#include "audio_dma.h" +#include "tick.h" +#include "supervisor/filesystem.h" +#include "supervisor/shared/tick.h" +#include "supervisor/usb.h" + +#include "py/runtime.h" +#include "shared-module/network/__init__.h" +#include "supervisor/shared/stack.h" + +// TODO +#ifdef CIRCUITPY_DISPLAYIO +//#include "shared-module/displayio/__init__.h" +#endif + +volatile uint64_t last_finished_tick = 0; + +bool stack_ok_so_far = true; + +static bool running_background_tasks = false; + +void background_tasks_reset(void) { + running_background_tasks = false; +} + +void run_background_tasks(void) { + // Don't call ourselves recursively. + if (running_background_tasks) { + return; + } + assert_heap_ok(); + running_background_tasks = true; + + #if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO + audio_dma_background(); + #endif + #if CIRCUITPY_DISPLAYIO + displayio_background(); + #endif + + #if CIRCUITPY_NETWORK + network_module_background(); + #endif + filesystem_background(); + usb_background(); + running_background_tasks = false; + assert_heap_ok(); + + last_finished_tick = supervisor_ticks_ms64(); +} + +bool background_tasks_ok(void) { + return supervisor_ticks_ms64() - last_finished_tick < 1000; +} diff --git a/ports/mimxrt10xx/background.h b/ports/mimxrt10xx/background.h new file mode 100644 index 0000000000..52789d0389 --- /dev/null +++ b/ports/mimxrt10xx/background.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_BACKGROUND_H +#define MICROPY_INCLUDED_MIMXRT10XX_BACKGROUND_H + +#include + +void background_tasks_reset(void); +void run_background_tasks(void); +void run_background_vm_tasks(void); +bool background_tasks_ok(void); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_BACKGROUND_H diff --git a/ports/mimxrt10xx/boards/board.h b/ports/mimxrt10xx/boards/board.h new file mode 100644 index 0000000000..92d02d900e --- /dev/null +++ b/ports/mimxrt10xx/boards/board.h @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// This file defines board specific functions. + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H +#define MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H + +#include + +#include "py/mpconfig.h" +#include "fsl_common.h" + +// Initializes board related state once on start up. +void board_init(void); + +// Returns true if the user initiates safe mode in a board specific way. +// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific +// way. +bool board_requests_safe_mode(void); + +// Reset the state of off MCU components such as neopixels. +void reset_board(void); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c new file mode 100644 index 0000000000..8e73df4ad4 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft 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 "boards/board.h" +#include "mpconfigboard.h" +#include "fsl_iomuxc.h" + +void board_init(void) { + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1,1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 1U); + + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B,0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 0x10E1U); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h new file mode 100644 index 0000000000..98d1f478bf --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h @@ -0,0 +1,31 @@ +#define MICROPY_HW_BOARD_NAME "Feather MIMXRT1011" +#define MICROPY_HW_MCU_NAME "IMXRT1011DAE5A" + +//TODO +//#define MICROPY_HW_LED_STATUS (&pin_PA27) + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO_SD_05) + +// These are pins not to reset. +// QSPI Data pins +//#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 ) +// QSPI CS, and QSPI SCK +//#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 ) +//#define MICROPY_PORT_C ( 0 ) +//#define MICROPY_PORT_D ( 0 ) + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (8 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_10) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_09) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO_AD_06) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO_AD_04) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO_AD_03) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_01) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_02) diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk new file mode 100644 index 0000000000..6efd3f329a --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk @@ -0,0 +1,21 @@ +LD_FILE = boards/mimxrt1011-bootloader-external-flash.ld +USB_VID = 0x239A +USB_PID = 0x8074 +USB_PRODUCT = "Feather MIMXRT1011" +USB_MANUFACTURER = "arturo182" +USB_DEVICES = "CDC,MSC,HID" + +CHIP_VARIANT = MIMXRT1011DAE5A +CHIP_FAMILY = MIMXRT1011 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_NVM = 0 +CIRCUITPY_ROTARYIO = 0 + +LONGINT_IMPL = MPZ diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c new file mode 100644 index 0000000000..2c6c1ce93e --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c @@ -0,0 +1,52 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // Analog + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_07) }, + + // Digital + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_AD_05) }, + + // SPI + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO_AD_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO_AD_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO_AD_04) }, + + // UART + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_AD_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_AD_01) }, + + // I2C + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_10) }, + + // ESP control + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_CS), MP_ROM_PTR(&pin_GPIO_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_GPIO0), MP_ROM_PTR(&pin_GPIO_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_GPIO_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_GPIO_AD_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_GPIO_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_GPIO_11) }, + //{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RTS), MP_ROM_PTR(&pin_) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO_SD_05) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c new file mode 100644 index 0000000000..979dd82ce8 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft 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 "boards/board.h" +#include "mpconfigboard.h" +#include "fsl_iomuxc.h" + +void board_init(void) { + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_06_FLEXSPIA_SS0_B, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_07_FLEXSPIA_SCLK,1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_08_FLEXSPIA_DATA00, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_09_FLEXSPIA_DATA01, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_10_FLEXSPIA_DATA02, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_11_FLEXSPIA_DATA03, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_05_FLEXSPIA_DQS, 1U); + + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_06_FLEXSPIA_SS0_B,0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_09_FLEXSPIA_DATA01, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_10_FLEXSPIA_DATA02, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_08_FLEXSPIA_DATA00, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_07_FLEXSPIA_SCLK, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_11_FLEXSPIA_DATA03, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_05_FLEXSPIA_DQS, 0x10E1U); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h new file mode 100644 index 0000000000..b91209c82a --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h @@ -0,0 +1,31 @@ +#define MICROPY_HW_BOARD_NAME "Feather MIMXRT1062" +#define MICROPY_HW_MCU_NAME "IMXRT1062DVJ6A" + +//TODO +//#define MICROPY_HW_LED_STATUS (&pin_PA27) + +//#define MICROPY_HW_NEOPIXEL (&pin_PB22) + +// These are pins not to reset. +// QSPI Data pins +//#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 ) +// QSPI CS, and QSPI SCK +//#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 ) +//#define MICROPY_PORT_C ( 0 ) +//#define MICROPY_PORT_D ( 0 ) + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (8 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_EMC_22) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_EMC_21) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO_B1_07) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO_B1_06) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO_B1_05) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_B1_03) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_B1_02) diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk new file mode 100644 index 0000000000..b2e356e558 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk @@ -0,0 +1,21 @@ +LD_FILE = boards/mimxrt1062-bootloader-external-flash.ld +USB_VID = 0x239A +USB_PID = 0x8076 +USB_PRODUCT = "Feather MIMXRT1062" +USB_MANUFACTURER = "arturo182" +USB_DEVICES = "CDC,MSC,HID" + +CHIP_VARIANT = MIMXRT1062DVJ6A +CHIP_FAMILY = MIMXRT1062 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_NVM = 0 +CIRCUITPY_ROTARYIO = 0 + +LONGINT_IMPL = MPZ diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c new file mode 100644 index 0000000000..eb287b87aa --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c @@ -0,0 +1,45 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // Analog + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_B0_14) }, + + // Digital + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_EMC_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_EMC_28) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_EMC_29) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_EMC_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_EMC_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_EMC_23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_EMC_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_B1_08) }, + + // SPI + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO_B1_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO_B1_06) }, + + // UART + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_B1_03) }, + + // I2C + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_EMC_21) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_EMC_22) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO_SD_B1_01) }, + + // TODO: Big connector + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/board.c b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c new file mode 100644 index 0000000000..8e73df4ad4 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft 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 "boards/board.h" +#include "mpconfigboard.h" +#include "fsl_iomuxc.h" + +void board_init(void) { + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1,1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 1U); + IOMUXC_SetPinMux(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 1U); + + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B,0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 0x10E1U); + IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 0x10E1U); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h new file mode 100644 index 0000000000..12cb5e8a86 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h @@ -0,0 +1,31 @@ +#define MICROPY_HW_BOARD_NAME "IMXRT1010-EVK" +#define MICROPY_HW_MCU_NAME "IMXRT1011DAE5A" + +//TODO +//#define MICROPY_HW_LED_STATUS (&pin_PA27) + +//#define MICROPY_HW_NEOPIXEL (&pin_PB22) + +// These are pins not to reset. +// QSPI Data pins +//#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 ) +// QSPI CS, and QSPI SCK +//#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 ) +//#define MICROPY_PORT_C ( 0 ) +//#define MICROPY_PORT_D ( 0 ) + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (16 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_02) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_01) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO_AD_06) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO_AD_04) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO_AD_03) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_09) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_10) diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk new file mode 100644 index 0000000000..4401647c44 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk @@ -0,0 +1,22 @@ +LD_FILE = boards/mimxrt1011-bootloader-external-flash.ld +USB_VID = 0x239A +USB_PID = 0x8078 +USB_PRODUCT = "IMXRT1010-EVK" +USB_MANUFACTURER = "NXP" +USB_DEVICES = "CDC,MSC,HID" + +CHIP_VARIANT = MIMXRT1011DAE5A +CHIP_FAMILY = MIMXRT1011 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_NVM = 0 +CIRCUITPY_ROTARYIO = 0 + +LONGINT_IMPL = MPZ diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c new file mode 100644 index 0000000000..cfc8763694 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c @@ -0,0 +1,37 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO_AD_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO_AD_06) }, + //{ MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO_08) }, // Connected to audio codec + //{ MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_01) }, // Connected to audio codec + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_AD_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO_AD_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO_SD_02) }, + //{ MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_03) }, // Connected to audio codec + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_AD_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_AD_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_AD_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_AD_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO_02) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_02) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_USR_LED), MP_ROM_PTR(&pin_GPIO_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_USR_SW), MP_ROM_PTR(&pin_GPIO_SD_05) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld b/ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld new file mode 100644 index 0000000000..d36ee12396 --- /dev/null +++ b/ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld @@ -0,0 +1,106 @@ +ENTRY(Reset_Handler) + +_minimum_stack_size = 64K; +_minimum_heap_size = 0; + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 8M + FLASH_BOOTLOADER (rx) : ORIGIN = 0x60000000, LENGTH = 48K + FLASH_ISR (rx) : ORIGIN = 0x6000C000, LENGTH = 1K + FLASH_TEXT (rx) : ORIGIN = 0x6000C400, LENGTH = 975K + FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = 7M + RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 32K + OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = 64K +} + +_estack = ORIGIN(OCRAM) + LENGTH(OCRAM); +_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; + +__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); +__fatfs_flash_length = LENGTH(FLASH_FATFS); + +__RAM_VECTOR_TABLE_SIZE_BYTES = 0; + +SECTIONS +{ + .interrupts : + { + __VECTOR_TABLE = .; + __VECTOR_RAM = .; + + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } > FLASH_ISR + + .text : + { + . = ALIGN(4); + *(EXCLUDE_FILE( + *flexspi_nor_flash_ops.o + *fsl_flexspi.o + ) .text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } > FLASH_TEXT + + .ARM.exidx : + { + *(.ARM.exidx*) + *(.gnu.linkonce.armexidx.*) + _etext = .; /* define a global symbol at end of code */ + __etext = .; /* define a global symbol at end of code */ + } > FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = .; + + .data : AT (_sidata) + { + . = ALIGN(4); + __data_start__ = .; /* create a global symbol at data start */ + + *(.data*) /* .data* sections */ + *flexspi_nor_flash_ops.o(.text*) + *fsl_flexspi.o(.text*) + . = ALIGN(4); + + __data_end__ = .; /* define a global symbol at data end */ + } > RAM + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + + *(.bss*) + *(COMMON) + + . = ALIGN(4); + __bss_end__ = .; + PROVIDE(end = .); + } > RAM + + .heap : + { + . = ALIGN(8); + _heap_start = .; /* define a global symbol at heap start */ + + . += _minimum_heap_size; + + __HeapLimit = .; + } > OCRAM + + .stack : + { + . = ALIGN(8); + . += _minimum_stack_size; + } > OCRAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + +ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") +ASSERT(_estack - _minimum_stack_size >= __HeapLimit, "region OCRAM overflowed with stack and heap") diff --git a/ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld b/ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld new file mode 100644 index 0000000000..f1b0d85545 --- /dev/null +++ b/ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld @@ -0,0 +1,123 @@ +ENTRY(Reset_Handler) + +_minimum_stack_size = 64K; +_minimum_heap_size = 0; + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 8M + FLASH_CONFIG (rx) : ORIGIN = 0x60000400, LENGTH = 3K + FLASH_IVT (rx) : ORIGIN = 0x60001000, LENGTH = 4K + FLASH_ISR (rx) : ORIGIN = 0x60002000, LENGTH = 1K + FLASH_TEXT (rx) : ORIGIN = 0x60002400, LENGTH = 1015K + FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = 7M + RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 32K + OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = 64K +} + +_estack = ORIGIN(OCRAM) + LENGTH(OCRAM); +_bootloader_dbl_tap = 0; + +__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); +__fatfs_flash_length = LENGTH(FLASH_FATFS); + +__RAM_VECTOR_TABLE_SIZE_BYTES = 0; + +SECTIONS +{ + .flash_config : + { + . = ALIGN(4); + KEEP(* (.boot_hdr.conf)) + . = ALIGN(4); + } > FLASH_CONFIG + + .ivt : + { + . = ALIGN(4); + KEEP(* (.boot_hdr.ivt)) + KEEP(* (.boot_hdr.boot_data)) + KEEP(* (.boot_hdr.dcd_data)) + . = ALIGN(4); + } > FLASH_IVT + + .interrupts : + { + __VECTOR_TABLE = .; + __VECTOR_RAM = .; + + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } > FLASH_ISR + + .text : + { + . = ALIGN(4); + *(EXCLUDE_FILE( + *flexspi_nor_flash_ops.o + *fsl_flexspi.o + ) .text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } > FLASH_TEXT + + .ARM.exidx : + { + *(.ARM.exidx*) + *(.gnu.linkonce.armexidx.*) + _etext = .; /* define a global symbol at end of code */ + __etext = .; /* define a global symbol at end of code */ + } > FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = .; + + .data : AT (_sidata) + { + . = ALIGN(4); + __data_start__ = .; /* create a global symbol at data start */ + + *(.data*) /* .data* sections */ + *flexspi_nor_flash_ops.o(.text*) + *fsl_flexspi.o(.text*) + . = ALIGN(4); + + __data_end__ = .; /* define a global symbol at data end */ + } > RAM + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + + *(.bss*) + *(COMMON) + + . = ALIGN(4); + __bss_end__ = .; + PROVIDE(end = .); + } > RAM + + .heap : + { + . = ALIGN(8); + _heap_start = .; /* define a global symbol at heap start */ + + . += _minimum_heap_size; + + __HeapLimit = .; + } > OCRAM + + .stack : + { + . = ALIGN(8); + . += _minimum_stack_size; + } > OCRAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + +ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") +ASSERT(_estack - _minimum_stack_size >= __HeapLimit, "region OCRAM overflowed with stack and heap") diff --git a/ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld b/ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld new file mode 100644 index 0000000000..16442607f3 --- /dev/null +++ b/ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld @@ -0,0 +1,106 @@ +ENTRY(Reset_Handler) + +_minimum_stack_size = 64K; +_minimum_heap_size = 0; + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 8M + FLASH_BOOTLOADER (rx) : ORIGIN = 0x60000000, LENGTH = 48K + FLASH_ISR (rx) : ORIGIN = 0x6000C000, LENGTH = 1K + FLASH_TEXT (rx) : ORIGIN = 0x6000C400, LENGTH = 975K + FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = 7M + RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 128K + OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = 768K +} + +_estack = ORIGIN(OCRAM) + LENGTH(OCRAM); +_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; + +__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); +__fatfs_flash_length = LENGTH(FLASH_FATFS); + +__RAM_VECTOR_TABLE_SIZE_BYTES = 0; + +SECTIONS +{ + .interrupts : + { + __VECTOR_TABLE = .; + __VECTOR_RAM = .; + + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } > FLASH_ISR + + .text : + { + . = ALIGN(4); + *(EXCLUDE_FILE( + *flexspi_nor_flash_ops.o + *fsl_flexspi.o + ) .text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } > FLASH_TEXT + + .ARM.exidx : + { + *(.ARM.exidx*) + *(.gnu.linkonce.armexidx.*) + _etext = .; /* define a global symbol at end of code */ + __etext = .; /* define a global symbol at end of code */ + } > FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = .; + + .data : AT (_sidata) + { + . = ALIGN(4); + __data_start__ = .; /* create a global symbol at data start */ + + *(.data*) /* .data* sections */ + *flexspi_nor_flash_ops.o(.text*) + *fsl_flexspi.o(.text*) + . = ALIGN(4); + + __data_end__ = .; /* define a global symbol at data end */ + } > RAM + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + + *(.bss*) + *(COMMON) + + . = ALIGN(4); + __bss_end__ = .; + PROVIDE(end = .); + } > RAM + + .heap : + { + . = ALIGN(8); + _heap_start = .; /* define a global symbol at heap start */ + + . += _minimum_heap_size; + + __HeapLimit = .; + } > OCRAM + + .stack : + { + . = ALIGN(8); + . += _minimum_stack_size; + } > OCRAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + +ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") +ASSERT(_estack - _minimum_stack_size >= __HeapLimit, "region OCRAM overflowed with stack and heap") diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogIn.c b/ports/mimxrt10xx/common-hal/analogio/AnalogIn.c new file mode 100644 index 0000000000..d714001f33 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogIn.c @@ -0,0 +1,88 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft 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 "common-hal/analogio/AnalogIn.h" + +#include + +#include "py/runtime.h" + +#include "fsl_adc.h" + +#define ADC_CHANNEL_GROUP 0 + +void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self, + const mcu_pin_obj_t *pin) { + adc_config_t config = {0}; + + if (pin->adc == NULL) { + mp_raise_ValueError(translate("Pin does not have ADC capabilities")); + } + + ADC_GetDefaultConfig(&config); + + config.enableLongSample = true; + config.samplePeriodMode = kADC_SamplePeriod8or24Clocks; + + ADC_Init(pin->adc, &config); + ADC_SetHardwareAverageConfig(pin->adc, kADC_HardwareAverageCount32); + ADC_DoAutoCalibration(pin->adc); + + claim_pin(pin); + + self->pin = pin; +} + +bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) { + return self->pin == mp_const_none; +} + +void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) { + if (common_hal_analogio_analogin_deinited(self)) { + return; + } + reset_pin_number(self->pin->number); + self->pin = mp_const_none; +} + +uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { + adc_channel_config_t config = { 0 }; + config.channelNumber = self->pin->adc_channel; + + ADC_SetChannelConfig(self->pin->adc, ADC_CHANNEL_GROUP, &config); + + while (!ADC_GetChannelStatusFlags(self->pin->adc, ADC_CHANNEL_GROUP)) { + + } + + // Shift the value to be 16 bit + return ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP) << 4; +} + +float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) { + return 3.3f; +} diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogIn.h b/ports/mimxrt10xx/common-hal/analogio/AnalogIn.h new file mode 100644 index 0000000000..c252ab5535 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogIn.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_ANALOGIO_ANALOGIN_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_ANALOGIO_ANALOGIN_H + +#include "common-hal/microcontroller/Pin.h" + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t *pin; +} analogio_analogin_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_ANALOGIO_ANALOGIN_H diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c new file mode 100644 index 0000000000..6e34a72178 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c @@ -0,0 +1,46 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * 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 "py/runtime.h" + +#include "shared-bindings/analogio/AnalogOut.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate.h" + +void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin) { + mp_raise_RuntimeError(translate("AnalogOut functionality not supported")); +} + +bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) { + return true; +} + +void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) { +} + +void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, uint16_t value) { +} diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.h b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.h new file mode 100644 index 0000000000..133cce8fb5 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_ANALOGIO_ANALOGOUT_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_ANALOGIO_ANALOGOUT_H + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; +} analogio_analogout_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_ANALOGIO_ANALOGOUT_H diff --git a/ports/mimxrt10xx/common-hal/analogio/__init__.c b/ports/mimxrt10xx/common-hal/analogio/__init__.c new file mode 100644 index 0000000000..eea58c77d6 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/analogio/__init__.c @@ -0,0 +1 @@ +// No analogio module functions. diff --git a/ports/mimxrt10xx/common-hal/board/__init__.c b/ports/mimxrt10xx/common-hal/board/__init__.c new file mode 100644 index 0000000000..e86251480e --- /dev/null +++ b/ports/mimxrt10xx/common-hal/board/__init__.c @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * 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 + +#include "py/runtime.h" +#include "py/mphal.h" +#include "common-hal/microcontroller/Pin.h" + +// Pins aren't actually defined here. They are in the board specific directory +// such as boards/imxrt1010_evk/pins.c. diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.c b/ports/mimxrt10xx/common-hal/busio/I2C.c new file mode 100644 index 0000000000..3c555df451 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/I2C.c @@ -0,0 +1,192 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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 + +#include "shared-bindings/busio/I2C.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "periph.h" + +#include "fsl_lpi2c.h" + +//TODO + +#define I2C_CLOCK_SOURCE_DIVIDER (5U) +#define I2C_CLOCK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8 / (I2C_CLOCK_SOURCE_DIVIDER + 1U)) + +static void config_periph_pin(const mcu_periph_obj_t *periph) { + 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(3) + | IOMUXC_SW_PAD_CTL_PAD_PUE(0) + | IOMUXC_SW_PAD_CTL_PAD_PKE(1) + | IOMUXC_SW_PAD_CTL_PAD_ODE(1) + | IOMUXC_SW_PAD_CTL_PAD_SPEED(2) + | IOMUXC_SW_PAD_CTL_PAD_DSE(4) + | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); +} + +void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, + const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) { + + const uint32_t sda_count = sizeof(mcu_i2c_sda_list) / sizeof(mcu_periph_obj_t); + const uint32_t scl_count = sizeof(mcu_i2c_scl_list) / sizeof(mcu_periph_obj_t); + + for (uint32_t i = 0; i < sda_count; ++i) { + if (mcu_i2c_sda_list[i].pin != sda) + continue; + + for (uint32_t j = 0; j < scl_count; ++j) { + if (mcu_i2c_scl_list[j].pin != scl) + continue; + + if (mcu_i2c_scl_list[j].bank_idx != mcu_i2c_sda_list[i].bank_idx) + continue; + + self->sda_pin = &mcu_i2c_sda_list[i]; + self->scl_pin = &mcu_i2c_scl_list[j]; + + break; + } + } + + if(self->sda_pin == NULL || self->scl_pin == NULL) { + mp_raise_RuntimeError(translate("Invalid I2C pin selection")); + } else { + self->i2c = mcu_i2c_banks[self->sda_pin->bank_idx - 1]; + } + + config_periph_pin(self->sda_pin); + config_periph_pin(self->scl_pin); + + lpi2c_master_config_t config = { 0 }; + LPI2C_MasterGetDefaultConfig(&config); + + config.baudRate_Hz = frequency; + + LPI2C_MasterInit(self->i2c, &config, I2C_CLOCK_FREQ); + +// if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) { +// reset_pin_number(sda->number); +// reset_pin_number(scl->number); +// mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); +// } + + claim_pin(self->sda_pin->pin); + claim_pin(self->scl_pin->pin); +} + +bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) { + return self->sda_pin == NULL; +} + +void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { + if (common_hal_busio_i2c_deinited(self)) { + return; + } + + LPI2C_MasterDeinit(self->i2c); + +// reset_pin_number(self->sda_pin); +// reset_pin_number(self->scl_pin); + + self->sda_pin = NULL; + self->scl_pin = NULL; +} + +bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { + lpi2c_master_transfer_t xfer = { 0 }; + xfer.slaveAddress = addr; + + return LPI2C_MasterTransferBlocking(self->i2c, &xfer) == kStatus_Success; +} + +bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) { + bool grabbed_lock = false; +// CRITICAL_SECTION_ENTER() + if (!self->has_lock) { + grabbed_lock = true; + self->has_lock = true; + } +// CRITICAL_SECTION_LEAVE(); + return grabbed_lock; +} + +bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) { + return self->has_lock; +} + +void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { + self->has_lock = false; +} + +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len, bool transmit_stop_bit) { + + lpi2c_master_transfer_t xfer = { 0 }; + xfer.flags = transmit_stop_bit ? kLPI2C_TransferDefaultFlag : kLPI2C_TransferNoStopFlag; + xfer.slaveAddress = addr; + xfer.data = (uint8_t*)data; + xfer.dataSize = len; + + const status_t status = LPI2C_MasterTransferBlocking(self->i2c, &xfer); + if (status == kStatus_Success) + return 0; + + return MP_EIO; +} + +uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *data, size_t len) { + + lpi2c_master_transfer_t xfer = { 0 }; + xfer.direction = kLPI2C_Read; + xfer.slaveAddress = addr; + xfer.data = data; + xfer.dataSize = len; + + const status_t status = LPI2C_MasterTransferBlocking(self->i2c, &xfer); + if (status == kStatus_Success) + return 0; + + return MP_EIO; +} + +void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { +// never_reset_sercom(self->i2c_desc.device.hw); +// +// never_reset_pin_number(self->scl_pin); +// never_reset_pin_number(self->sda_pin); +} diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.h b/ports/mimxrt10xx/common-hal/busio/I2C.h new file mode 100644 index 0000000000..924e108116 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/I2C.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_I2C_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_I2C_H + +#include "common-hal/microcontroller/Pin.h" +#include "fsl_common.h" +#include "periph.h" +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + LPI2C_Type *i2c; + bool has_lock; + const mcu_periph_obj_t *scl_pin; + const mcu_periph_obj_t *sda_pin; +} busio_i2c_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_I2C_H diff --git a/ports/mimxrt10xx/common-hal/busio/OneWire.h b/ports/mimxrt10xx/common-hal/busio/OneWire.h new file mode 100644 index 0000000000..bb4bc016a4 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/OneWire.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H + +// Use bitbangio. +#include "shared-module/busio/OneWire.h" + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c new file mode 100644 index 0000000000..5ff94bcf89 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -0,0 +1,318 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +//TODO +#include "shared-bindings/busio/SPI.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "periph.h" + +#include "fsl_lpspi.h" + +#include + +//bool never_reset_sercoms[SERCOM_INST_NUM]; +// +//void never_reset_sercom(Sercom* sercom) { +// // Reset all SERCOMs except the ones being used by on-board devices. +// Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; +// for (int i = 0; i < SERCOM_INST_NUM; i++) { +// if (sercom_instances[i] == sercom) { +// never_reset_sercoms[i] = true; +// break; +// } +// } +//} +// +//void allow_reset_sercom(Sercom* sercom) { +// // Reset all SERCOMs except the ones being used by on-board devices. +// Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; +// for (int i = 0; i < SERCOM_INST_NUM; i++) { +// if (sercom_instances[i] == sercom) { +// never_reset_sercoms[i] = false; +// break; +// } +// } +//} +// +//void reset_sercoms(void) { +// // Reset all SERCOMs except the ones being used by on-board devices. +// Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; +// for (int i = 0; i < SERCOM_INST_NUM; i++) { +// if (never_reset_sercoms[i]) { +// continue; +// } +// #ifdef MICROPY_HW_APA102_SERCOM +// if (sercom_instances[i] == MICROPY_HW_APA102_SERCOM) { +// continue; +// } +// #endif +// // SWRST is same for all modes of SERCOMs. +// sercom_instances[i]->SPI.CTRLA.bit.SWRST = 1; +// } +//} + +static void config_periph_pin(const mcu_periph_obj_t *periph) { + IOMUXC_SetPinMux( + periph->pin->mux_reg, periph->mux_mode, + periph->input_reg, periph->input_idx, + 0, + 0); + + 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)); +} + +#define LPSPI_CLOCK_SOURCE_DIVIDER (7U) +#define LPSPI_MASTER_CLK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk) / (LPSPI_CLOCK_SOURCE_DIVIDER + 1U)) + +void common_hal_busio_spi_construct(busio_spi_obj_t *self, + const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, + const mcu_pin_obj_t *miso) { + + // TODO: Allow none mosi or miso + + const uint32_t sck_count = sizeof(mcu_spi_sck_list) / sizeof(mcu_periph_obj_t); + const uint32_t miso_count = sizeof(mcu_spi_miso_list) / sizeof(mcu_periph_obj_t); + const uint32_t mosi_count = sizeof(mcu_spi_mosi_list) / sizeof(mcu_periph_obj_t); + + for (uint32_t i = 0; i < sck_count; ++i) { + if (mcu_spi_sck_list[i].pin != clock) + continue; + + for (uint32_t j = 0; j < miso_count; ++j) { + if (mcu_spi_miso_list[j].pin != miso) + continue; + + if (mcu_spi_miso_list[j].bank_idx != mcu_spi_sck_list[i].bank_idx) + continue; + + for (uint32_t k = 0; k < mosi_count; ++k) { + if (mcu_spi_mosi_list[k].pin != mosi) + continue; + + if (mcu_spi_mosi_list[k].bank_idx != mcu_spi_miso_list[j].bank_idx) + continue; + + self->clock_pin = &mcu_spi_sck_list[i]; + self->miso_pin = &mcu_spi_miso_list[j]; + self->mosi_pin = &mcu_spi_mosi_list[k]; + + break; + } + } + } + + if(self->clock_pin == NULL || self->mosi_pin == NULL || self->miso_pin == NULL) { + mp_raise_RuntimeError(translate("Invalid SPI pin selection")); + } else { + self->spi = mcu_spi_banks[self->clock_pin->bank_idx - 1]; + } + + config_periph_pin(self->mosi_pin); + config_periph_pin(self->miso_pin); + config_periph_pin(self->clock_pin); + + lpspi_master_config_t config = { 0 }; + LPSPI_MasterGetDefaultConfig(&config); + + // Always start at 250khz which is what SD cards need. They are sensitive to + // SPI bus noise before they are put into SPI mode. + config.baudRate = 250000; + + LPSPI_MasterInit(self->spi, &config, LPSPI_MASTER_CLK_FREQ); + + LPSPI_Enable(self->spi, false); + uint32_t tcrPrescaleValue; + self->baudrate = LPSPI_MasterSetBaudRate(self->spi, config.baudRate, LPSPI_MASTER_CLK_FREQ, &tcrPrescaleValue); + LPSPI_Enable(self->spi, true); + + claim_pin(self->clock_pin->pin); + +// if (mosi_none) { +// self->MOSI_pin = NO_PIN; +// } else { +// gpio_set_pin_direction(mosi->number, GPIO_DIRECTION_OUT); +// gpio_set_pin_pull_mode(mosi->number, GPIO_PULL_OFF); +// gpio_set_pin_function(mosi->number, mosi_pinmux); +// self->MOSI_pin = mosi->number; + claim_pin(self->mosi_pin->pin); +// } + +// if (miso_none) { +// self->MISO_pin = NO_PIN; +// } else { +// gpio_set_pin_direction(miso->number, GPIO_DIRECTION_IN); +// gpio_set_pin_pull_mode(miso->number, GPIO_PULL_OFF); +// gpio_set_pin_function(miso->number, miso_pinmux); +// self->MISO_pin = miso->number; + claim_pin(self->miso_pin->pin); +// } +} + +void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { +// never_reset_sercom(self->spi_desc.dev.prvt); + +// never_reset_pin_number(self->clock_pin); +// never_reset_pin_number(self->MOSI_pin); +// never_reset_pin_number(self->MISO_pin); +} + +bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) { + return self->clock_pin == NULL; +} + +void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { + if (common_hal_busio_spi_deinited(self)) { + return; + } + +// allow_reset_sercom(self->spi_desc.dev.prvt); + +// spi_m_sync_disable(&self->spi_desc); +// spi_m_sync_deinit(&self->spi_desc); +// reset_pin_number(self->clock_pin); +// reset_pin_number(self->MOSI_pin); +// reset_pin_number(self->MISO_pin); + self->clock_pin = NULL; +} + +bool common_hal_busio_spi_configure(busio_spi_obj_t *self, + uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t bits) { + lpspi_master_config_t config = { 0 }; + LPSPI_MasterGetDefaultConfig(&config); + + config.baudRate = baudrate; + config.cpol = polarity; + config.cpha = phase; + config.bitsPerFrame = bits; + + LPSPI_Deinit(self->spi); + LPSPI_MasterInit(self->spi, &config, LPSPI_MASTER_CLK_FREQ); + + LPSPI_Enable(self->spi, false); + uint32_t tcrPrescaleValue; + self->baudrate = LPSPI_MasterSetBaudRate(self->spi, config.baudRate, LPSPI_MASTER_CLK_FREQ, &tcrPrescaleValue); + LPSPI_Enable(self->spi, true); + + return true; +} + +bool common_hal_busio_spi_try_lock(busio_spi_obj_t *self) { + bool grabbed_lock = false; +// CRITICAL_SECTION_ENTER() + if (!self->has_lock) { + grabbed_lock = true; + self->has_lock = true; + } +// CRITICAL_SECTION_LEAVE(); + return grabbed_lock; +} + +bool common_hal_busio_spi_has_lock(busio_spi_obj_t *self) { + return self->has_lock; +} + +void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { + self->has_lock = false; +} + +bool common_hal_busio_spi_write(busio_spi_obj_t *self, + const uint8_t *data, size_t len) { + if (len == 0) { + return true; + } + + lpspi_transfer_t xfer = { 0 }; + xfer.txData = (uint8_t*)data; + xfer.dataSize = len; + xfer.configFlags = kLPSPI_MasterPcs0; + + const status_t status = LPSPI_MasterTransferBlocking(self->spi, &xfer); + if (status != kStatus_Success) + printf("%s: status %ld\r\n", __func__, status); + + return (status == kStatus_Success); +} + +bool common_hal_busio_spi_read(busio_spi_obj_t *self, + uint8_t *data, size_t len, uint8_t write_value) { + if (len == 0) { + return true; + } + + LPSPI_SetDummyData(self->spi, write_value); + + lpspi_transfer_t xfer = { 0 }; + xfer.rxData = data; + xfer.dataSize = len; + + const status_t status = LPSPI_MasterTransferBlocking(self->spi, &xfer); + if (status != kStatus_Success) + printf("%s: status %ld\r\n", __func__, status); + + return (status == kStatus_Success); +} + +bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) { + if (len == 0) { + return true; + } + + LPSPI_SetDummyData(self->spi, 0xFF); + + lpspi_transfer_t xfer = { 0 }; + xfer.txData = data_out; + xfer.rxData = data_in; + xfer.dataSize = len; + + const status_t status = LPSPI_MasterTransferBlocking(self->spi, &xfer); + if (status != kStatus_Success) + printf("%s: status %ld\r\n", __func__, status); + + return (status == kStatus_Success); +} + +uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t* self) { + return self->baudrate; +} + +uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t* self) { + return ((self->spi->TCR & LPSPI_TCR_CPHA_MASK) == LPSPI_TCR_CPHA_MASK); +} + +uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) { + return ((self->spi->TCR & LPSPI_TCR_CPOL_MASK) == LPSPI_TCR_CPOL_MASK); +} diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.h b/ports/mimxrt10xx/common-hal/busio/SPI.h new file mode 100644 index 0000000000..0895e1ddbc --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/SPI.h @@ -0,0 +1,46 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_SPI_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_SPI_H + +#include "common-hal/microcontroller/Pin.h" +#include "fsl_common.h" +#include "periph.h" +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + LPSPI_Type *spi; + bool has_lock; + uint32_t baudrate; + const mcu_periph_obj_t *clock_pin; + const mcu_periph_obj_t *mosi_pin; + const mcu_periph_obj_t *miso_pin; +} busio_spi_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_SPI_H diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c new file mode 100644 index 0000000000..a4819798bc --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -0,0 +1,252 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Damien P. George + * 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 "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/busio/UART.h" + +#include "mpconfigport.h" +#include "lib/utils/interrupt_char.h" +#include "supervisor/shared/tick.h" +#include "py/gc.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "py/stream.h" +#include "periph.h" + +#include "fsl_lpuart.h" + +// TODO + +#define UART_CLOCK_FREQ (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U) + +static void config_periph_pin(const mcu_periph_obj_t *periph) { + IOMUXC_SetPinMux( + periph->pin->mux_reg, periph->mux_mode, + periph->input_reg, periph->input_idx, + 0, + 0); + + 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(1) + | IOMUXC_SW_PAD_CTL_PAD_DSE(6) + | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); +} + +void LPUART_UserCallback(LPUART_Type *base, lpuart_handle_t *handle, status_t status, void *user_data) +{ + busio_uart_obj_t *self = (busio_uart_obj_t*)user_data; + + if (status == kStatus_LPUART_RxIdle) { + self->rx_ongoing = false; + } +} + +void common_hal_busio_uart_construct(busio_uart_obj_t *self, + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, + uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, + uint16_t receiver_buffer_size) { + + // TODO: Allow none rx or tx + + bool have_tx = tx != mp_const_none; + bool have_rx = rx != mp_const_none; + if (!have_tx && !have_rx) { + mp_raise_ValueError(translate("tx and rx cannot both be None")); + } + + self->baudrate = baudrate; + self->character_bits = bits; + self->timeout_ms = timeout * 1000; + + const uint32_t rx_count = sizeof(mcu_uart_rx_list) / sizeof(mcu_periph_obj_t); + const uint32_t tx_count = sizeof(mcu_uart_tx_list) / sizeof(mcu_periph_obj_t); + + for (uint32_t i = 0; i < rx_count; ++i) { + if (mcu_uart_rx_list[i].pin != rx) + continue; + + for (uint32_t j = 0; j < tx_count; ++j) { + if (mcu_uart_tx_list[j].pin != tx) + continue; + + if (mcu_uart_tx_list[j].bank_idx != mcu_uart_rx_list[i].bank_idx) + continue; + + self->rx_pin = &mcu_uart_rx_list[i]; + self->tx_pin = &mcu_uart_tx_list[j]; + + break; + } + } + + if(self->rx_pin == NULL || self->tx_pin == NULL) { + mp_raise_RuntimeError(translate("Invalid UART pin selection")); + } else { + self->uart = mcu_uart_banks[self->tx_pin->bank_idx - 1]; + } + + config_periph_pin(self->rx_pin); + config_periph_pin(self->tx_pin); + + lpuart_config_t config = { 0 }; + LPUART_GetDefaultConfig(&config); + + config.dataBitsCount = self->character_bits == 8 ? kLPUART_EightDataBits : kLPUART_SevenDataBits; + config.baudRate_Bps = self->baudrate; + config.enableTx = self->tx_pin != NULL; + config.enableRx = self->rx_pin != NULL; + + LPUART_Init(self->uart, &config, UART_CLOCK_FREQ); + + claim_pin(self->tx_pin->pin); + + if (self->rx_pin != NULL) { + ringbuf_alloc(&self->rbuf, receiver_buffer_size, true); + + if (!self->rbuf.buf) { + LPUART_Deinit(self->uart); + mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); + } + + LPUART_TransferCreateHandle(self->uart, &self->handle, LPUART_UserCallback, self); + LPUART_TransferStartRingBuffer(self->uart, &self->handle, self->rbuf.buf, self->rbuf.size); + + claim_pin(self->rx_pin->pin); + } +} + +bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { + return self->rx_pin == NULL && self->tx_pin == NULL; +} + +void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { + if (common_hal_busio_uart_deinited(self)) { + return; + } + + LPUART_Deinit(self->uart); + + gc_free(self->rbuf.buf); + self->rbuf.size = 0; + self->rbuf.iput = self->rbuf.iget = 0; + +// reset_pin_number(self->rx_pin); +// reset_pin_number(self->tx_pin); + + self->rx_pin = NULL; + self->tx_pin = NULL; +} + +// Read characters. +size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { + if (self->rx_pin == NULL) { + mp_raise_ValueError(translate("No RX pin")); + } + + if (len == 0) { + // Nothing to read. + return 0; + } + + lpuart_transfer_t xfer = { + .data = data, + .dataSize = len, + }; + + self->rx_ongoing = true; + LPUART_TransferReceiveNonBlocking(self->uart, &self->handle, &xfer, NULL); + + uint64_t start_ticks = supervisor_ticks_ms64(); + + // Wait for all bytes received or timeout + while (self->rx_ongoing && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { + RUN_BACKGROUND_TASKS; + + // Allow user to break out of a timeout with a KeyboardInterrupt. + if (mp_hal_is_interrupted()) { + break; + } + } + + // if we timed out, stop the transfer + if (self->rx_ongoing) { + LPUART_TransferAbortReceive(self->uart, &self->handle); + } + + return len - self->handle.rxDataSize; +} + +// Write characters. +size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { + if (self->tx_pin == NULL) { + mp_raise_ValueError(translate("No TX pin")); + } + + LPUART_WriteBlocking(self->uart, data, len); + + return len; +} + +uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) { + return self->baudrate; +} + +void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) { + if (LPUART_SetBaudRate(self->uart, baudrate, UART_CLOCK_FREQ) == kStatus_Success) { + self->baudrate = baudrate; + } +} + +mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) { + return (mp_float_t) (self->timeout_ms / 1000.0f); +} + +void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) { + self->timeout_ms = timeout * 1000; +} + +uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { + return LPUART_TransferGetRxRingBufferLength(self->uart, &self->handle); +} + +void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) { + self->handle.rxRingBufferHead = self->handle.rxRingBufferTail; +} + +bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { + if (self->tx_pin == NULL) { + return false; + } + + return LPUART_GetStatusFlags(self->uart) & kLPUART_TxDataRegEmptyFlag; +} diff --git a/ports/mimxrt10xx/common-hal/busio/UART.h b/ports/mimxrt10xx/common-hal/busio/UART.h new file mode 100644 index 0000000000..9e768db3c0 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/UART.h @@ -0,0 +1,54 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_UART_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_UART_H + +#include "common-hal/microcontroller/Pin.h" + +#include "py/ringbuf.h" +#include "py/obj.h" +#include "periph.h" + +#include "fsl_lpuart.h" + +typedef struct { + mp_obj_base_t base; + LPUART_Type *uart; + lpuart_handle_t handle; + ringbuf_t rbuf; + bool rx_ongoing; + uint32_t baudrate; + uint8_t character_bits; + uint32_t timeout_ms; + const mcu_periph_obj_t *rx_pin; + const mcu_periph_obj_t *tx_pin; + const mcu_periph_obj_t *cts_pin; + const mcu_periph_obj_t *rts_pin; +} busio_uart_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_UART_H diff --git a/ports/mimxrt10xx/common-hal/busio/__init__.c b/ports/mimxrt10xx/common-hal/busio/__init__.c new file mode 100644 index 0000000000..41761b6743 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/busio/__init__.c @@ -0,0 +1 @@ +// No busio module functions. diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c new file mode 100644 index 0000000000..d69a18d962 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c @@ -0,0 +1,170 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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 +#include +#include + +#include "py/runtime.h" +#include "py/mphal.h" + +#include "fsl_gpio.h" + +#include "common-hal/microcontroller/Pin.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "supervisor/shared/translate.h" + +#define IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5 5U + +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) + | IOMUXC_SW_PAD_CTL_PAD_PUE(pull != PULL_NONE) + | IOMUXC_SW_PAD_CTL_PAD_PKE(1) + | IOMUXC_SW_PAD_CTL_PAD_ODE(open_drain) + | IOMUXC_SW_PAD_CTL_PAD_SPEED(2) + | IOMUXC_SW_PAD_CTL_PAD_DSE(1) + | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); +} + +digitalinout_result_t common_hal_digitalio_digitalinout_construct( + digitalio_digitalinout_obj_t* self, const mcu_pin_obj_t* pin) { + claim_pin(pin); + self->pin = pin; + self->output = false; + self->open_drain = false; + self->pull = PULL_NONE; + + // GPIO is always IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5 until proven otherwise + IOMUXC_SetPinMux(pin->mux_reg, IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5, 0, 0, 0, 0); + + pin_config(pin, self->open_drain, self->pull); + + const gpio_pin_config_t config = { kGPIO_DigitalInput, 0, kGPIO_NoIntmode }; + GPIO_PinInit(self->pin->gpio, self->pin->number, &config); + + return DIGITALINOUT_OK; +} + +void common_hal_digitalio_digitalinout_never_reset( + digitalio_digitalinout_obj_t *self) { + never_reset_pin_number(self->pin->number); +} + +bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t* self) { + return self->pin == mp_const_none; +} + +void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self) { + if (common_hal_digitalio_digitalinout_deinited(self)) { + return; + } + reset_pin_number(self->pin->number); + self->pin = mp_const_none; +} + +void common_hal_digitalio_digitalinout_switch_to_input( + digitalio_digitalinout_obj_t* self, digitalio_pull_t pull) { + self->output = false; + + // This also sets direction to input. + common_hal_digitalio_digitalinout_set_pull(self, pull); +} + +void common_hal_digitalio_digitalinout_switch_to_output( + digitalio_digitalinout_obj_t* self, bool value, + digitalio_drive_mode_t drive_mode) { + self->output = true; + self->open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN; + self->pull = PULL_NONE; + + pin_config(self->pin, self->open_drain, self->pull); + + const gpio_pin_config_t config = { kGPIO_DigitalOutput, value, kGPIO_NoIntmode }; + GPIO_PinInit(self->pin->gpio, self->pin->number, &config); +} + +digitalio_direction_t common_hal_digitalio_digitalinout_get_direction( + digitalio_digitalinout_obj_t* self) { + return self->output ? DIRECTION_OUTPUT : DIRECTION_INPUT; +} + +void common_hal_digitalio_digitalinout_set_value( + digitalio_digitalinout_obj_t* self, bool value) { + GPIO_PinWrite(self->pin->gpio, self->pin->number, value); +} + +bool common_hal_digitalio_digitalinout_get_value( + digitalio_digitalinout_obj_t* self) { + return GPIO_PinRead(self->pin->gpio, self->pin->number); +} + +void common_hal_digitalio_digitalinout_set_drive_mode( + digitalio_digitalinout_obj_t* self, + digitalio_drive_mode_t drive_mode) { + bool value = common_hal_digitalio_digitalinout_get_value(self); + self->open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN; + + pin_config(self->pin, self->open_drain, self->pull); + + // True is implemented differently between modes so reset the value to make + // sure it's correct for the new mode. + if (value) { + common_hal_digitalio_digitalinout_set_value(self, value); + } +} + +digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode( + digitalio_digitalinout_obj_t* self) { + if (self->open_drain) { + return DRIVE_MODE_OPEN_DRAIN; + } else { + return DRIVE_MODE_PUSH_PULL; + } +} + +void common_hal_digitalio_digitalinout_set_pull( + digitalio_digitalinout_obj_t* self, digitalio_pull_t pull) { + self->pull = pull; + + pin_config(self->pin, self->open_drain, self->pull); + + const gpio_pin_config_t config = { kGPIO_DigitalInput, 0, kGPIO_NoIntmode }; + GPIO_PinInit(self->pin->gpio, self->pin->number, &config); +} + +digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( + digitalio_digitalinout_obj_t* self) { + if (self->output) { + mp_raise_AttributeError(translate("Cannot get pull while in output mode")); + return PULL_NONE; + } else { + return self->pull; + } +} diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h new file mode 100644 index 0000000000..4c19de20b6 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DIGITALIO_DIGITALINOUT_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DIGITALIO_DIGITALINOUT_H + +#include "common-hal/microcontroller/Pin.h" +#include "shared-bindings/digitalio/Pull.h" +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t *pin; + bool output; + bool open_drain; + digitalio_pull_t pull; +} digitalio_digitalinout_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DIGITALIO_DIGITALINOUT_H diff --git a/ports/mimxrt10xx/common-hal/digitalio/__init__.c b/ports/mimxrt10xx/common-hal/digitalio/__init__.c new file mode 100644 index 0000000000..20fad45959 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/digitalio/__init__.c @@ -0,0 +1 @@ +// No digitalio module functions. diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c new file mode 100644 index 0000000000..04dd997393 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -0,0 +1,226 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft 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 "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/rgb_led_status.h" + +#ifdef MICROPY_HW_NEOPIXEL +bool neopixel_in_use; +#endif +#ifdef MICROPY_HW_APA102_MOSI +bool apa102_sck_in_use; +bool apa102_mosi_in_use; +#endif +#ifdef SPEAKER_ENABLE_PIN +bool speaker_enable_in_use; +#endif + +//TODO + +#define PORT_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT / 32 + 1) + +//STATIC uint32_t never_reset_pins[PORT_COUNT]; + +void reset_all_pins(void) { +// uint32_t pin_mask[PORT_COUNT] = PORT_OUT_IMPLEMENTED; + +// // Do not full reset USB lines. +// pin_mask[0] &= ~(PORT_PA24 | PORT_PA25); + +// // Do not reset SWD when a debugger is present. +// if (DSU->STATUSB.bit.DBGPRES == 1) { +// pin_mask[0] &= ~(PORT_PA30 | PORT_PA31); +// } + +// for (uint32_t i = 0; i < PORT_COUNT; i++) { +// pin_mask[i] &= ~never_reset_pins[i]; +// } + +// gpio_set_port_direction(GPIO_PORTA, pin_mask[0] & ~MICROPY_PORT_A, GPIO_DIRECTION_OFF); +// gpio_set_port_direction(GPIO_PORTB, pin_mask[1] & ~MICROPY_PORT_B, GPIO_DIRECTION_OFF); +// #if PORT_BITS > 64 +// gpio_set_port_direction(GPIO_PORTC, pin_mask[2] & ~MICROPY_PORT_C, GPIO_DIRECTION_OFF); +// #endif +// #if PORT_BITS > 96 +// gpio_set_port_direction(GPIO_PORTD, pin_mask[3] & ~MICROPY_PORT_D, GPIO_DIRECTION_OFF); +// #endif +// +// // Configure SWD. SWDIO will be automatically switched on PA31 when a signal is input on +// // SWCLK. +// #ifdef SAMD51 +// gpio_set_pin_function(PIN_PA30, MUX_PA30H_CM4_SWCLK); +// #endif +// #ifdef SAMD21 +// gpio_set_pin_function(PIN_PA30, GPIO_PIN_FUNCTION_G); +// gpio_set_pin_function(PIN_PA31, GPIO_PIN_FUNCTION_G); +// #endif +// + #ifdef MICROPY_HW_NEOPIXEL + neopixel_in_use = false; + #endif + #ifdef MICROPY_HW_APA102_MOSI + apa102_sck_in_use = false; + apa102_mosi_in_use = false; + #endif + + // After configuring SWD because it may be shared. + #ifdef SPEAKER_ENABLE_PIN + speaker_enable_in_use = false; +// gpio_set_pin_function(SPEAKER_ENABLE_PIN->number, GPIO_PIN_FUNCTION_OFF); +// gpio_set_pin_direction(SPEAKER_ENABLE_PIN->number, GPIO_DIRECTION_OUT); +// gpio_set_pin_level(SPEAKER_ENABLE_PIN->number, false); + #endif +} + +void never_reset_pin_number(uint8_t pin_number) { +// never_reset_pins[GPIO_PORT(pin_number)] |= 1 << GPIO_PIN(pin_number); +} + +void reset_pin_number(uint8_t pin_number) { + // never_reset_pins[GPIO_PORT(pin_number)] &= ~(1 << GPIO_PIN(pin_number)); + + if (pin_number >= IOMUXC_SW_PAD_CTL_PAD_COUNT) { + return; + } + + #ifdef MICROPY_HW_NEOPIXEL + if (pin_number == MICROPY_HW_NEOPIXEL->number) { + neopixel_in_use = false; + rgb_led_status_init(); + return; + } + #endif + #ifdef MICROPY_HW_APA102_MOSI + if (pin_number == MICROPY_HW_APA102_MOSI->number || + pin_number == MICROPY_HW_APA102_SCK->number) { +// apa102_mosi_in_use = apa102_mosi_in_use && pin_number != MICROPY_HW_APA102_MOSI->number; +// apa102_sck_in_use = apa102_sck_in_use && pin_number != MICROPY_HW_APA102_SCK->number; + if (!apa102_sck_in_use && !apa102_mosi_in_use) { +// rgb_led_status_init(); + } + return; + } + #endif + +// if (pin_number == PIN_PA30 +// #ifdef SAMD51 +// ) { +// #endif +// #ifdef SAMD21 +// || pin_number == PIN_PA31) { +// #endif +// gpio_set_pin_function(pin_number, SWD_MUX); +// } else { +// gpio_set_pin_direction(pin_number, GPIO_DIRECTION_OFF); +// gpio_set_pin_function(pin_number, GPIO_PIN_FUNCTION_OFF); +// } +// + #ifdef SPEAKER_ENABLE_PIN + if (pin_number == SPEAKER_ENABLE_PIN->number) { + speaker_enable_in_use = false; +// gpio_set_pin_function(pin_number, GPIO_PIN_FUNCTION_OFF); +// gpio_set_pin_direction(SPEAKER_ENABLE_PIN->number, GPIO_DIRECTION_OUT); +// gpio_set_pin_level(SPEAKER_ENABLE_PIN->number, false); + } + #endif +} + +void claim_pin(const mcu_pin_obj_t* pin) { + #ifdef MICROPY_HW_NEOPIXEL + if (pin == MICROPY_HW_NEOPIXEL) { + neopixel_in_use = true; + } + #endif + #ifdef MICROPY_HW_APA102_MOSI + if (pin == MICROPY_HW_APA102_MOSI) { + apa102_mosi_in_use = true; + } + if (pin == MICROPY_HW_APA102_SCK) { + apa102_sck_in_use = true; + } + #endif + + #ifdef SPEAKER_ENABLE_PIN + if (pin == SPEAKER_ENABLE_PIN) { + speaker_enable_in_use = true; + } + #endif +} + +bool pin_number_is_free(uint8_t pin_number) { +// PortGroup *const port = &PORT->Group[(enum gpio_port)GPIO_PORT(pin_number)]; +// uint8_t pin_index = GPIO_PIN(pin_number); +// volatile PORT_PINCFG_Type *state = &port->PINCFG[pin_index]; +// volatile PORT_PMUX_Type *pmux = &port->PMUX[pin_index / 2]; +// +// if (pin_number == PIN_PA30 || pin_number == PIN_PA31) { +// if (DSU->STATUSB.bit.DBGPRES == 1) { +// return false; +// } +// if (pin_number == PIN_PA30 +// #ifdef SAMD51 +// ) { +// #endif +// #ifdef SAMD21 +// || pin_number == PIN_PA31) { +// #endif) { +// return state->bit.PMUXEN == 1 && ((pmux->reg >> (4 * pin_index % 2)) & 0xf) == SWD_MUX; +// } +// } +// +// return state->bit.PMUXEN == 0 && state->bit.INEN == 0 && +// state->bit.PULLEN == 0 && (port->DIR.reg & (1 << pin_index)) == 0; + return true; +} + +bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin) { + #ifdef MICROPY_HW_NEOPIXEL + if (pin == MICROPY_HW_NEOPIXEL) { + return !neopixel_in_use; + } + #endif + #ifdef MICROPY_HW_APA102_MOSI + if (pin == MICROPY_HW_APA102_MOSI) { + return !apa102_mosi_in_use; + } + if (pin == MICROPY_HW_APA102_SCK) { + return !apa102_sck_in_use; + } + #endif + + #ifdef SPEAKER_ENABLE_PIN + if (pin == SPEAKER_ENABLE_PIN) { + return !speaker_enable_in_use; + } + #endif + + return pin_number_is_free(pin->number); +} + +void common_hal_reset_pin(const mcu_pin_obj_t* pin) { +// reset_pin_number(pin->number); +} diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.h b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h new file mode 100644 index 0000000000..74a1f7cbbd --- /dev/null +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.h @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H + +#include + +#include "pins.h" + +#ifdef MICROPY_HW_NEOPIXEL +extern bool neopixel_in_use; +#endif +#ifdef MICROPY_HW_APA102_MOSI +extern bool apa102_sck_in_use; +extern bool apa102_mosi_in_use; +#endif + +void reset_all_pins(void); +// reset_pin_number takes the pin number instead of the pointer so that objects don't +// need to store a full pointer. +void reset_pin_number(uint8_t pin_number); +void never_reset_pin_number(uint8_t pin_number); +void claim_pin(const mcu_pin_obj_t* pin); +bool pin_number_is_free(uint8_t pin_number); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c new file mode 100644 index 0000000000..23493f7660 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -0,0 +1,65 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Dan Halbert 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 + +#include "common-hal/microcontroller/Processor.h" + +#include "fsl_tempmon.h" +#include "fsl_ocotp.h" +#include "clocks.h" + +float common_hal_mcu_processor_get_temperature(void) { + tempmon_config_t config; + TEMPMON_GetDefaultConfig(&config); + + TEMPMON_Init(TEMPMON, &config); + TEMPMON_StartMeasure(TEMPMON); + + const float temp = TEMPMON_GetCurrentTemperature(TEMPMON); + TEMPMON_Deinit(TEMPMON); + + return temp; +} + +float common_hal_mcu_processor_get_voltage(void) { + return NAN; +} + +uint32_t common_hal_mcu_processor_get_frequency(void) { + return SystemCoreClock; +} + +void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { + OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk)); + + // Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info) + for (int i = 0; i < 4; ++i) + ((uint32_t*) raw_id)[i] = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); + + OCOTP_Deinit(OCOTP); +} diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.h b/ports/mimxrt10xx/common-hal/microcontroller/Processor.h new file mode 100644 index 0000000000..43b0ec878c --- /dev/null +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Dan Halbert 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H + +#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 16 + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + // Stores no state currently. +} mcu_processor_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c new file mode 100644 index 0000000000..68de3a8907 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -0,0 +1,284 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft 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. + */ +//TODO +#include "py/mphal.h" +#include "py/obj.h" +#include "py/runtime.h" + +#include "fsl_device_registers.h" + +#include "reset.h" + +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/microcontroller/Processor.h" +#include "supervisor/shared/safe_mode.h" +#include "supervisor/shared/translate.h" + +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) { + __disable_irq(); + __DMB(); + nesting_count++; +} + +void HardFault_Handler(void); +void common_hal_mcu_enable_interrupts(void) { + if (nesting_count == 0) { + // This is very very bad because it means there was mismatched disable/enables so we + // "HardFault". + HardFault_Handler(); + } + nesting_count--; + if (nesting_count > 0) { + return; + } + __DMB(); + __enable_irq(); +} + +void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { + if (runmode == RUNMODE_BOOTLOADER) { + if (!bootloader_available()) { + mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present.")); + } + // Pretend to be the first of the two reset presses needed to enter the + // bootloader. That way one reset will end in the bootloader. + _bootloader_dbl_tap = DBL_TAP_MAGIC; + } else { + // Set up the default. + _bootloader_dbl_tap = DBL_TAP_MAGIC_QUICK_BOOT; + } + if (runmode == RUNMODE_SAFE_MODE) { + safe_mode_on_next_reset(PROGRAMMATIC_SAFE_MODE); + } +} + +void common_hal_mcu_reset(void) { + NVIC_SystemReset(); +} + +// The singleton microcontroller.Processor object, bound to microcontroller.cpu +// It currently only has properties, and no state. +const mcu_processor_obj_t common_hal_mcu_processor_obj = { + .base = { + .type = &mcu_processor_type, + }, +}; + +// NVM is only available on Express boards for now. +#if CIRCUITPY_INTERNAL_NVM_SIZE > 0 +// The singleton nvm.ByteArray object. +const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = { + .base = { + .type = &nvm_bytearray_type, + }, + .len = CIRCUITPY_INTERNAL_NVM_SIZE, + .start_address = (uint8_t*) (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE) +}; +#endif + +// This maps MCU pin names to pin objects. +STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = { +#ifdef MIMXRT1011_SERIES + { MP_ROM_QSTR(MP_QSTR_GPIO_00), MP_ROM_PTR(&pin_GPIO_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_01), MP_ROM_PTR(&pin_GPIO_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_02), MP_ROM_PTR(&pin_GPIO_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_03), MP_ROM_PTR(&pin_GPIO_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_04), MP_ROM_PTR(&pin_GPIO_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_05), MP_ROM_PTR(&pin_GPIO_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_06), MP_ROM_PTR(&pin_GPIO_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_07), MP_ROM_PTR(&pin_GPIO_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_08), MP_ROM_PTR(&pin_GPIO_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_09), MP_ROM_PTR(&pin_GPIO_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_10), MP_ROM_PTR(&pin_GPIO_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_11), MP_ROM_PTR(&pin_GPIO_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_12), MP_ROM_PTR(&pin_GPIO_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_13), MP_ROM_PTR(&pin_GPIO_13) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_00), MP_ROM_PTR(&pin_GPIO_SD_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_01), MP_ROM_PTR(&pin_GPIO_SD_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_02), MP_ROM_PTR(&pin_GPIO_SD_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_03), MP_ROM_PTR(&pin_GPIO_SD_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_04), MP_ROM_PTR(&pin_GPIO_SD_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_05), MP_ROM_PTR(&pin_GPIO_SD_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_06), MP_ROM_PTR(&pin_GPIO_SD_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_07), MP_ROM_PTR(&pin_GPIO_SD_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_08), MP_ROM_PTR(&pin_GPIO_SD_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_09), MP_ROM_PTR(&pin_GPIO_SD_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_10), MP_ROM_PTR(&pin_GPIO_SD_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_11), MP_ROM_PTR(&pin_GPIO_SD_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_12), MP_ROM_PTR(&pin_GPIO_SD_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_13), MP_ROM_PTR(&pin_GPIO_SD_13) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_00), MP_ROM_PTR(&pin_GPIO_AD_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_01), MP_ROM_PTR(&pin_GPIO_AD_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_02), MP_ROM_PTR(&pin_GPIO_AD_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_03), MP_ROM_PTR(&pin_GPIO_AD_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_04), MP_ROM_PTR(&pin_GPIO_AD_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_05), MP_ROM_PTR(&pin_GPIO_AD_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_06), MP_ROM_PTR(&pin_GPIO_AD_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_07), MP_ROM_PTR(&pin_GPIO_AD_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_08), MP_ROM_PTR(&pin_GPIO_AD_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_09), MP_ROM_PTR(&pin_GPIO_AD_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_10), MP_ROM_PTR(&pin_GPIO_AD_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_11), MP_ROM_PTR(&pin_GPIO_AD_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_12), MP_ROM_PTR(&pin_GPIO_AD_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_13), MP_ROM_PTR(&pin_GPIO_AD_13) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_14), MP_ROM_PTR(&pin_GPIO_AD_14) }, +#else + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_00), MP_ROM_PTR(&pin_GPIO_EMC_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_01), MP_ROM_PTR(&pin_GPIO_EMC_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_02), MP_ROM_PTR(&pin_GPIO_EMC_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_03), MP_ROM_PTR(&pin_GPIO_EMC_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_04), MP_ROM_PTR(&pin_GPIO_EMC_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_05), MP_ROM_PTR(&pin_GPIO_EMC_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_06), MP_ROM_PTR(&pin_GPIO_EMC_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_07), MP_ROM_PTR(&pin_GPIO_EMC_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_08), MP_ROM_PTR(&pin_GPIO_EMC_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_09), MP_ROM_PTR(&pin_GPIO_EMC_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_10), MP_ROM_PTR(&pin_GPIO_EMC_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_11), MP_ROM_PTR(&pin_GPIO_EMC_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_12), MP_ROM_PTR(&pin_GPIO_EMC_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_13), MP_ROM_PTR(&pin_GPIO_EMC_13) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_14), MP_ROM_PTR(&pin_GPIO_EMC_14) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_15), MP_ROM_PTR(&pin_GPIO_EMC_15) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_16), MP_ROM_PTR(&pin_GPIO_EMC_16) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_17), MP_ROM_PTR(&pin_GPIO_EMC_17) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_18), MP_ROM_PTR(&pin_GPIO_EMC_18) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_19), MP_ROM_PTR(&pin_GPIO_EMC_19) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_20), MP_ROM_PTR(&pin_GPIO_EMC_20) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_21), MP_ROM_PTR(&pin_GPIO_EMC_21) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_22), MP_ROM_PTR(&pin_GPIO_EMC_22) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_23), MP_ROM_PTR(&pin_GPIO_EMC_23) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_24), MP_ROM_PTR(&pin_GPIO_EMC_24) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_25), MP_ROM_PTR(&pin_GPIO_EMC_25) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_26), MP_ROM_PTR(&pin_GPIO_EMC_26) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_27), MP_ROM_PTR(&pin_GPIO_EMC_27) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_28), MP_ROM_PTR(&pin_GPIO_EMC_28) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_29), MP_ROM_PTR(&pin_GPIO_EMC_29) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_30), MP_ROM_PTR(&pin_GPIO_EMC_30) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_31), MP_ROM_PTR(&pin_GPIO_EMC_31) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_32), MP_ROM_PTR(&pin_GPIO_EMC_32) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_33), MP_ROM_PTR(&pin_GPIO_EMC_33) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_34), MP_ROM_PTR(&pin_GPIO_EMC_34) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_35), MP_ROM_PTR(&pin_GPIO_EMC_35) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_36), MP_ROM_PTR(&pin_GPIO_EMC_36) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_37), MP_ROM_PTR(&pin_GPIO_EMC_37) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_38), MP_ROM_PTR(&pin_GPIO_EMC_38) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_39), MP_ROM_PTR(&pin_GPIO_EMC_39) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_40), MP_ROM_PTR(&pin_GPIO_EMC_40) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_EMC_41), MP_ROM_PTR(&pin_GPIO_EMC_41) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_00), MP_ROM_PTR(&pin_GPIO_AD_B0_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_01), MP_ROM_PTR(&pin_GPIO_AD_B0_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_02), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_03), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_04), MP_ROM_PTR(&pin_GPIO_AD_B0_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_05), MP_ROM_PTR(&pin_GPIO_AD_B0_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_06), MP_ROM_PTR(&pin_GPIO_AD_B0_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_07), MP_ROM_PTR(&pin_GPIO_AD_B0_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_08), MP_ROM_PTR(&pin_GPIO_AD_B0_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_09), MP_ROM_PTR(&pin_GPIO_AD_B0_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_10), MP_ROM_PTR(&pin_GPIO_AD_B0_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_11), MP_ROM_PTR(&pin_GPIO_AD_B0_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_12), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_13), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_14), MP_ROM_PTR(&pin_GPIO_AD_B0_14) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B0_15), MP_ROM_PTR(&pin_GPIO_AD_B0_15) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_00), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_01), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_02), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_03), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_04), MP_ROM_PTR(&pin_GPIO_AD_B1_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_05), MP_ROM_PTR(&pin_GPIO_AD_B1_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_06), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_07), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_08), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_09), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_10), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_11), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_12), MP_ROM_PTR(&pin_GPIO_AD_B1_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_13), MP_ROM_PTR(&pin_GPIO_AD_B1_13) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_14), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_15), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_00), MP_ROM_PTR(&pin_GPIO_B0_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_01), MP_ROM_PTR(&pin_GPIO_B0_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_02), MP_ROM_PTR(&pin_GPIO_B0_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_03), MP_ROM_PTR(&pin_GPIO_B0_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_04), MP_ROM_PTR(&pin_GPIO_B0_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_05), MP_ROM_PTR(&pin_GPIO_B0_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_06), MP_ROM_PTR(&pin_GPIO_B0_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_07), MP_ROM_PTR(&pin_GPIO_B0_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_08), MP_ROM_PTR(&pin_GPIO_B0_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_09), MP_ROM_PTR(&pin_GPIO_B0_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_10), MP_ROM_PTR(&pin_GPIO_B0_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_11), MP_ROM_PTR(&pin_GPIO_B0_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_12), MP_ROM_PTR(&pin_GPIO_B0_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_13), MP_ROM_PTR(&pin_GPIO_B0_13) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_14), MP_ROM_PTR(&pin_GPIO_B0_14) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B0_15), MP_ROM_PTR(&pin_GPIO_B0_15) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_00), MP_ROM_PTR(&pin_GPIO_B1_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_01), MP_ROM_PTR(&pin_GPIO_B1_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_02), MP_ROM_PTR(&pin_GPIO_B1_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_03), MP_ROM_PTR(&pin_GPIO_B1_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_04), MP_ROM_PTR(&pin_GPIO_B1_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_05), MP_ROM_PTR(&pin_GPIO_B1_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_06), MP_ROM_PTR(&pin_GPIO_B1_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_07), MP_ROM_PTR(&pin_GPIO_B1_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_08), MP_ROM_PTR(&pin_GPIO_B1_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_09), MP_ROM_PTR(&pin_GPIO_B1_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_10), MP_ROM_PTR(&pin_GPIO_B1_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_11), MP_ROM_PTR(&pin_GPIO_B1_11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_12), MP_ROM_PTR(&pin_GPIO_B1_12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_13), MP_ROM_PTR(&pin_GPIO_B1_13) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_14), MP_ROM_PTR(&pin_GPIO_B1_14) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_B1_15), MP_ROM_PTR(&pin_GPIO_B1_15) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_00), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_01), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_02), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_03), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_04), MP_ROM_PTR(&pin_GPIO_SD_B0_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_05), MP_ROM_PTR(&pin_GPIO_SD_B0_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_00), MP_ROM_PTR(&pin_GPIO_SD_B1_00) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_01), MP_ROM_PTR(&pin_GPIO_SD_B1_01) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_02), MP_ROM_PTR(&pin_GPIO_SD_B1_02) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_03), MP_ROM_PTR(&pin_GPIO_SD_B1_03) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_04), MP_ROM_PTR(&pin_GPIO_SD_B1_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_05), MP_ROM_PTR(&pin_GPIO_SD_B1_05) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_06), MP_ROM_PTR(&pin_GPIO_SD_B1_06) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_07), MP_ROM_PTR(&pin_GPIO_SD_B1_07) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_08), MP_ROM_PTR(&pin_GPIO_SD_B1_08) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_09), MP_ROM_PTR(&pin_GPIO_SD_B1_09) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_10), MP_ROM_PTR(&pin_GPIO_SD_B1_10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_11), MP_ROM_PTR(&pin_GPIO_SD_B1_11) }, +#endif +}; +MP_DEFINE_CONST_DICT(mcu_pin_globals, mcu_pin_global_dict_table); diff --git a/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c b/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c new file mode 100644 index 0000000000..9ea2335021 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/neopixel_write/__init__.c @@ -0,0 +1,106 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * Copyright (c) 2020 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 "py/mphal.h" +#include "shared-bindings/neopixel_write/__init__.h" + +#include "tick.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "common-hal/microcontroller/Pin.h" +#include "fsl_gpio.h" + +uint64_t next_start_tick_ms = 0; +uint32_t next_start_tick_us = 1000; + +//sysclock divisors +#define MAGIC_800_INT 900000 // ~1.11 us -> 1.2 field +#define MAGIC_800_T0H 2800000 // ~0.36 us -> 0.44 field +#define MAGIC_800_T1H 1350000 // ~0.74 us -> 0.84 field + +#pragma GCC push_options +#pragma GCC optimize ("Os") + +void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, + uint32_t numBytes) { + uint8_t *p = pixels, *end = p + numBytes, pix = *p++, mask = 0x80; + uint32_t start = 0; + uint32_t cyc = 0; + + //assumes 800_000Hz frequency + //Theoretical values here are 800_000 -> 1.25us, 2500000->0.4us, 1250000->0.8us + //TODO: try to get dynamic weighting working again +#ifdef MIMXRT1011_SERIES + uint32_t sys_freq = CLOCK_GetCoreFreq(); +#else + uint32_t sys_freq = CLOCK_GetAhbFreq(); +#endif + uint32_t interval = sys_freq/MAGIC_800_INT; + uint32_t t0 = (sys_freq/MAGIC_800_T0H); + uint32_t t1 = (sys_freq/MAGIC_800_T1H); + + // This must be called while interrupts are on in case we're waiting for a + // future ms tick. + wait_until(next_start_tick_ms, next_start_tick_us); + + GPIO_Type *gpio = digitalinout->pin->gpio; + 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; + DWT->CYCCNT = 0; + + for(;;) { + cyc = (pix & mask) ? t1 : t0; + start = DWT->CYCCNT; + GPIO_PinWrite(gpio, pin, 1); + while((DWT->CYCCNT - start) < cyc); + GPIO_PinWrite(gpio, pin, 0); + while((DWT->CYCCNT - start) < interval); + if(!(mask >>= 1)) { + if(p >= end) break; + pix = *p++; + mask = 0x80; + } + } + + // Enable interrupts again + __enable_irq(); + + // Update the next start. + current_tick(&next_start_tick_ms, &next_start_tick_us); + if (next_start_tick_us < 100) { + next_start_tick_ms += 1; + next_start_tick_us = 100 - next_start_tick_us; + } else { + next_start_tick_us -= 100; + } +} + +#pragma GCC pop_options diff --git a/ports/mimxrt10xx/common-hal/os/__init__.c b/ports/mimxrt10xx/common-hal/os/__init__.c new file mode 100644 index 0000000000..e84beb526c --- /dev/null +++ b/ports/mimxrt10xx/common-hal/os/__init__.c @@ -0,0 +1,72 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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 "genhdr/mpversion.h" +#include "py/mpconfig.h" +#include "py/objstr.h" +#include "py/objtuple.h" +#include "py/qstr.h" + +#include "fsl_trng.h" + +STATIC const qstr os_uname_info_fields[] = { + MP_QSTR_sysname, MP_QSTR_nodename, + MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine +}; +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "mimxrt10xx"); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "mimxrt10xx"); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); + +STATIC MP_DEFINE_ATTRTUPLE( + os_uname_info_obj, + os_uname_info_fields, + 5, + (mp_obj_t)&os_uname_info_sysname_obj, + (mp_obj_t)&os_uname_info_nodename_obj, + (mp_obj_t)&os_uname_info_release_obj, + (mp_obj_t)&os_uname_info_version_obj, + (mp_obj_t)&os_uname_info_machine_obj +); + +mp_obj_t common_hal_os_uname(void) { + return (mp_obj_t)&os_uname_info_obj; +} + +bool common_hal_os_urandom(uint8_t* buffer, uint32_t length) { + trng_config_t trngConfig; + + TRNG_GetDefaultConfig(&trngConfig); + trngConfig.sampleMode = kTRNG_SampleModeVonNeumann; + + TRNG_Init(TRNG, &trngConfig); + TRNG_GetRandomData(TRNG, buffer, length); + TRNG_Deinit(TRNG); + + return true; +} diff --git a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c b/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c new file mode 100644 index 0000000000..c75b75316a --- /dev/null +++ b/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c @@ -0,0 +1,551 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2016 Damien P. George + * 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 + +#include "py/runtime.h" +#include "common-hal/pulseio/PWMOut.h" +#include "shared-bindings/pulseio/PWMOut.h" +#include "shared-bindings/microcontroller/Processor.h" + +#include "fsl_pwm.h" + +#include "supervisor/shared/translate.h" +#include "periph.h" + +#include + +// TODO +//#include "samd/pins.h" + +//#undef ENABLE +// +//# define _TCC_SIZE(unused, n) TCC ## n ## _SIZE, +//# define TCC_SIZES { REPEAT_MACRO(_TCC_SIZE, 0, TCC_INST_NUM) } +// +//static uint32_t tcc_periods[TCC_INST_NUM]; +//static uint32_t tc_periods[TC_INST_NUM]; +// +//uint32_t target_tcc_frequencies[TCC_INST_NUM]; +//uint8_t tcc_refcount[TCC_INST_NUM]; +// +//// This bitmask keeps track of which channels of a TCC are currently claimed. +//#ifdef SAMD21 +//uint8_t tcc_channels[3]; // Set by pwmout_reset() to {0xf0, 0xfc, 0xfc} initially. +//#endif +//#ifdef SAMD51 +//uint8_t tcc_channels[5]; // Set by pwmout_reset() to {0xc0, 0xf0, 0xf8, 0xfc, 0xfc} initially. +//#endif +// +//static uint8_t never_reset_tc_or_tcc[TC_INST_NUM + TCC_INST_NUM]; + +void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) { +// if (self->timer->is_tc) { +// never_reset_tc_or_tcc[self->timer->index] += 1; +// } else { +// never_reset_tc_or_tcc[TC_INST_NUM + self->timer->index] += 1; +// } +// +// never_reset_pin_number(self->pin->number); +} + +void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) { +// if (self->timer->is_tc) { +// never_reset_tc_or_tcc[self->timer->index] -= 1; +// } else { +// never_reset_tc_or_tcc[TC_INST_NUM + self->timer->index] -= 1; +// } +} + +void pwmout_reset(void) { +// // Reset all timers +// for (int i = 0; i < TCC_INST_NUM; i++) { +// target_tcc_frequencies[i] = 0; +// tcc_refcount[i] = 0; +// } +// Tcc *tccs[TCC_INST_NUM] = TCC_INSTS; +// for (int i = 0; i < TCC_INST_NUM; i++) { +// if (never_reset_tc_or_tcc[TC_INST_NUM + i] > 0) { +// continue; +// } +// // Disable the module before resetting it. +// if (tccs[i]->CTRLA.bit.ENABLE == 1) { +// tccs[i]->CTRLA.bit.ENABLE = 0; +// while (tccs[i]->SYNCBUSY.bit.ENABLE == 1) { +// } +// } +// uint8_t mask = 0xff; +// for (uint8_t j = 0; j < tcc_cc_num[i]; j++) { +// mask <<= 1; +// } +// tcc_channels[i] = mask; +// tccs[i]->CTRLA.bit.SWRST = 1; +// while (tccs[i]->CTRLA.bit.SWRST == 1) { +// } +// } +// Tc *tcs[TC_INST_NUM] = TC_INSTS; +// for (int i = 0; i < TC_INST_NUM; i++) { +// if (never_reset_tc_or_tcc[i] > 0) { +// continue; +// } +// tcs[i]->COUNT16.CTRLA.bit.SWRST = 1; +// while (tcs[i]->COUNT16.CTRLA.bit.SWRST == 1) { +// } +// } +} + +//static uint8_t tcc_channel(const pin_timer_t* t) { +// // For the SAMD51 this hardcodes the use of OTMX == 0x0, the output matrix mapping, which uses +// // SAMD21-style modulo mapping. +// return t->wave_output % tcc_cc_num[t->index]; +//} + +//bool channel_ok(const pin_timer_t* t) { +// uint8_t channel_bit = 1 << tcc_channel(t); +// return (!t->is_tc && ((tcc_channels[t->index] & channel_bit) == 0)) || +// t->is_tc; +//} + +#define PWM_SRC_CLK_FREQ CLOCK_GetFreq(kCLOCK_IpgClk) + +pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self, + const mcu_pin_obj_t *pin, + uint16_t duty, + uint32_t frequency, + bool variable_frequency) { + self->pin = pin; + self->variable_frequency = variable_frequency; + + const uint32_t pwm_count = sizeof(mcu_pwm_list) / sizeof(mcu_pwm_obj_t); + + for (uint32_t i = 0; i < pwm_count; ++i) { + if (mcu_pwm_list[i].pin != pin) + continue; + + printf("pwm: 0x%p, sum %d, chan %d, mux %d\r\n", mcu_pwm_list[i].pwm, mcu_pwm_list[i].submodule, mcu_pwm_list[i].channel, mcu_pwm_list[i].mux_mode); + + self->pwm = &mcu_pwm_list[i]; + + break; + } + + if (self->pwm == NULL) { + return PWMOUT_INVALID_PIN; + } + + CLOCK_SetDiv(kCLOCK_AhbDiv, 0x2); /* Set AHB PODF to 2, divide by 3 */ + CLOCK_SetDiv(kCLOCK_IpgDiv, 0x3); /* Set IPG PODF to 3, divede by 4 */ + +//TODO re-enable +// IOMUXC_SetPinMux( +// IOMUXC_GPIO_SD_02_FLEXPWM1_PWM0_A, /* GPIO_02 is configured as FLEXPWM1_PWM0_A */ +// 0U); /* Software Input On Field: Input Path is determined by functionality */ +// +// IOMUXC_SetPinConfig( +// IOMUXC_GPIO_SD_02_FLEXPWM1_PWM0_A, /* GPIO_02 PAD functional properties : */ +// 0x10A0U); /* Slew Rate Field: Slow Slew Rate +// Drive Strength Field: R0/4 +// Speed Field: fast(150MHz) +// Open Drain Enable Field: Open Drain Disabled +// Pull / Keep Enable Field: Pull/Keeper Enabled +// Pull / Keep Select Field: Keeper +// Pull Up / Down Config. Field: 100K Ohm Pull Down +// Hyst. Enable Field: Hysteresis Disabled */ + + pwm_config_t pwmConfig; + + /* + * pwmConfig.enableDebugMode = false; + * pwmConfig.enableWait = false; + * pwmConfig.reloadSelect = kPWM_LocalReload; + * pwmConfig.faultFilterCount = 0; + * pwmConfig.faultFilterPeriod = 0; + * pwmConfig.clockSource = kPWM_BusClock; + * pwmConfig.prescale = kPWM_Prescale_Divide_1; + * pwmConfig.initializationControl = kPWM_Initialize_LocalSync; + * pwmConfig.forceTrigger = kPWM_Force_Local; + * pwmConfig.reloadFrequency = kPWM_LoadEveryOportunity; + * pwmConfig.reloadLogic = kPWM_ReloadImmediate; + * pwmConfig.pairOperation = kPWM_Independent; + */ + PWM_GetDefaultConfig(&pwmConfig); + + //pwmConfig.reloadLogic = kPWM_ReloadPwmFullCycle; + pwmConfig.enableDebugMode = true; + + if (PWM_Init(PWM1, self->pwm->submodule, &pwmConfig) == kStatus_Fail) { + printf("PWM initialization failed\r\n"); + return PWMOUT_INVALID_PIN; + } + + pwm_signal_param_t pwmSignal; + + /* Set deadtime count, we set this to about 650ns */ + uint16_t deadTimeVal = ((uint64_t)PWM_SRC_CLK_FREQ * 650) / 1000000000; + + pwmSignal.pwmChannel = self->pwm->channel; + pwmSignal.level = kPWM_HighTrue; + pwmSignal.dutyCyclePercent = frequency / 2; /* 1 percent dutycycle */ + pwmSignal.deadtimeValue = deadTimeVal; + + PWM_SetupPwm(PWM1, self->pwm->submodule, &pwmSignal, 1, kPWM_SignedCenterAligned, frequency, PWM_SRC_CLK_FREQ); + + PWM_SetPwmLdok(PWM1, kPWM_Control_Module_0 | kPWM_Control_Module_1 | kPWM_Control_Module_2, true); + + PWM_StartTimer(PWM1, kPWM_Control_Module_0 | kPWM_Control_Module_1 | kPWM_Control_Module_2); + +// if (frequency == 0 || frequency > 6000000) { +// return PWMOUT_INVALID_FREQUENCY; +// } + +// // Figure out which timer we are using. +// // First see if a tcc is already going with the frequency we want and our +// // channel is unused. tc's don't have enough channels to share. +// const pin_timer_t* timer = NULL; +// uint8_t mux_position = 0; +// if (!variable_frequency) { +// for (uint8_t i = 0; i < TCC_INST_NUM && timer == NULL; i++) { +// if (target_tcc_frequencies[i] != frequency) { +// continue; +// } +// for (uint8_t j = 0; j < NUM_TIMERS_PER_PIN && timer == NULL; j++) { +// const pin_timer_t* t = &pin->timer[j]; +// if (t->index != i || t->is_tc || t->index >= TCC_INST_NUM) { +// continue; +// } +// Tcc* tcc = tcc_insts[t->index]; +// if (tcc->CTRLA.bit.ENABLE == 1 && channel_ok(t)) { +// timer = t; +// mux_position = j; +// // Claim channel. +// tcc_channels[timer->index] |= (1 << tcc_channel(timer)); +// +// } +// } +// } +// } +// +// // No existing timer has been found, so find a new one to use and set it up. +// if (timer == NULL) { +// // By default, with fixed frequency we want to share a TCC because its likely we'll have +// // other outputs at the same frequency. If the frequency is variable then we'll only have +// // one output so we start with the TCs to see if they work. +// int8_t direction = -1; +// uint8_t start = NUM_TIMERS_PER_PIN - 1; +// bool found = false; +// if (variable_frequency) { +// direction = 1; +// start = 0; +// } +// for (int8_t i = start; i >= 0 && i < NUM_TIMERS_PER_PIN && timer == NULL; i += direction) { +// const pin_timer_t* t = &pin->timer[i]; +// if ((!t->is_tc && t->index >= TCC_INST_NUM) || +// (t->is_tc && t->index >= TC_INST_NUM)) { +// continue; +// } +// if (t->is_tc) { +// found = true; +// Tc* tc = tc_insts[t->index]; +// if (tc->COUNT16.CTRLA.bit.ENABLE == 0 && t->wave_output == 1) { +// timer = t; +// mux_position = i; +// } +// } else { +// Tcc* tcc = tcc_insts[t->index]; +// if (tcc->CTRLA.bit.ENABLE == 0 && channel_ok(t)) { +// timer = t; +// mux_position = i; +// } +// } +// } +// +// if (timer == NULL) { +// if (found) { +// return PWMOUT_ALL_TIMERS_ON_PIN_IN_USE; +// } +// return PWMOUT_ALL_TIMERS_IN_USE; +// } +// +// uint8_t resolution = 0; +// if (timer->is_tc) { +// resolution = 16; +// } else { +// // TCC resolution varies so look it up. +// const uint8_t _tcc_sizes[TCC_INST_NUM] = TCC_SIZES; +// resolution = _tcc_sizes[timer->index]; +// } +// // First determine the divisor that gets us the highest resolution. +// uint32_t system_clock = common_hal_mcu_processor_get_frequency(); +// uint32_t top; +// uint8_t divisor; +// for (divisor = 0; divisor < 8; divisor++) { +// top = (system_clock / prescaler[divisor] / frequency) - 1; +// if (top < (1u << resolution)) { +// break; +// } +// } +// +// set_timer_handler(timer->is_tc, timer->index, TC_HANDLER_NO_INTERRUPT); +// // We use the zeroeth clock on either port to go full speed. +// turn_on_clocks(timer->is_tc, timer->index, 0); +// +// if (timer->is_tc) { +// tc_periods[timer->index] = top; +// Tc* tc = tc_insts[timer->index]; +// #ifdef SAMD21 +// tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | +// TC_CTRLA_PRESCALER(divisor) | +// TC_CTRLA_WAVEGEN_MPWM; +// tc->COUNT16.CC[0].reg = top; +// #endif +// #ifdef SAMD51 +// +// tc->COUNT16.CTRLA.bit.SWRST = 1; +// while (tc->COUNT16.CTRLA.bit.SWRST == 1) { +// } +// tc_set_enable(tc, false); +// tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_PRESCALER(divisor); +// tc->COUNT16.WAVE.reg = TC_WAVE_WAVEGEN_MPWM; +// tc->COUNT16.CCBUF[0].reg = top; +// tc->COUNT16.CCBUF[1].reg = 0; +// #endif +// +// tc_set_enable(tc, true); +// } else { +// tcc_periods[timer->index] = top; +// Tcc* tcc = tcc_insts[timer->index]; +// tcc_set_enable(tcc, false); +// tcc->CTRLA.bit.PRESCALER = divisor; +// tcc->PER.bit.PER = top; +// tcc->WAVE.bit.WAVEGEN = TCC_WAVE_WAVEGEN_NPWM_Val; +// tcc_set_enable(tcc, true); +// target_tcc_frequencies[timer->index] = frequency; +// tcc_refcount[timer->index]++; +// if (variable_frequency) { +// // We're changing frequency so claim all of the channels. +// tcc_channels[timer->index] = 0xff; +// } else { +// tcc_channels[timer->index] |= (1 << tcc_channel(timer)); +// } +// } +// } +// +// self->timer = timer; +// +// gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_E + mux_position); + + common_hal_pulseio_pwmout_set_duty_cycle(self, duty); + + return PWMOUT_OK; +} + +bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) { + return self->pin == NULL; +} + +void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { + if (common_hal_pulseio_pwmout_deinited(self)) { + return; + } + +// const pin_timer_t* t = self->timer; +// if (t->is_tc) { +// Tc* tc = tc_insts[t->index]; +// tc_set_enable(tc, false); +// tc->COUNT16.CTRLA.bit.SWRST = true; +// tc_wait_for_sync(tc); +// } else { +// tcc_refcount[t->index]--; +// tcc_channels[t->index] &= ~(1 << tcc_channel(t)); +// if (tcc_refcount[t->index] == 0) { +// target_tcc_frequencies[t->index] = 0; +// Tcc* tcc = tcc_insts[t->index]; +// tcc_set_enable(tcc, false); +// tcc->CTRLA.bit.SWRST = true; +// while (tcc->SYNCBUSY.bit.SWRST != 0) { +// /* Wait for sync */ +// } +// } +// } +// reset_pin_number(self->pin->number); + self->pin = NULL; +} + +void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t *self, uint16_t duty) { + PWM_UpdatePwmDutycycle(PWM1, self->pwm->submodule, self->pwm->channel, kPWM_SignedCenterAligned, duty); + +// const pin_timer_t* t = self->timer; +// if (t->is_tc) { +// uint16_t adjusted_duty = tc_periods[t->index] * duty / 0xffff; +// #ifdef SAMD21 +// tc_insts[t->index]->COUNT16.CC[t->wave_output].reg = adjusted_duty; +// #endif +// #ifdef SAMD51 +// Tc* tc = tc_insts[t->index]; +// while (tc->COUNT16.SYNCBUSY.bit.CC1 != 0) {} +// tc->COUNT16.CCBUF[1].reg = adjusted_duty; +// #endif +// } else { +// uint32_t adjusted_duty = ((uint64_t) tcc_periods[t->index]) * duty / 0xffff; +// uint8_t channel = tcc_channel(t); +// Tcc* tcc = tcc_insts[t->index]; +// +// // Write into the CC buffer register, which will be transferred to the +// // CC register on an UPDATE (when period is finished). +// // Do clock domain syncing as necessary. +// +// while (tcc->SYNCBUSY.reg != 0) {} +// +// // Lock out double-buffering while updating the CCB value. +// tcc->CTRLBSET.bit.LUPD = 1; +// #ifdef SAMD21 +// tcc->CCB[channel].reg = adjusted_duty; +// #endif +// #ifdef SAMD51 +// tcc->CCBUF[channel].reg = adjusted_duty; +// #endif +// tcc->CTRLBCLR.bit.LUPD = 1; +// } +} + +uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) { + return 0; +// const pin_timer_t* t = self->timer; +// if (t->is_tc) { +// Tc* tc = tc_insts[t->index]; +// tc_wait_for_sync(tc); +// uint16_t cv = tc->COUNT16.CC[t->wave_output].reg; +// return cv * 0xffff / tc_periods[t->index]; +// } else { +// Tcc* tcc = tcc_insts[t->index]; +// uint8_t channel = tcc_channel(t); +// uint32_t cv = 0; +// +// while (tcc->SYNCBUSY.bit.CTRLB) {} +// +// #ifdef SAMD21 +// // If CCBV (CCB valid) is set, the CCB value hasn't yet been copied +// // to the CC value. +// if ((tcc->STATUS.vec.CCBV & (1 << channel)) != 0) { +// cv = tcc->CCB[channel].reg; +// } else { +// cv = tcc->CC[channel].reg; +// } +// #endif +// #ifdef SAMD51 +// if ((tcc->STATUS.vec.CCBUFV & (1 << channel)) != 0) { +// cv = tcc->CCBUF[channel].reg; +// } else { +// cv = tcc->CC[channel].reg; +// } +// #endif +// +// uint32_t duty_cycle = ((uint64_t) cv) * 0xffff / tcc_periods[t->index]; +// +// return duty_cycle; +// } +} + +void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, + uint32_t frequency) { +// if (frequency == 0 || frequency > 6000000) { +// mp_raise_ValueError(translate("Invalid PWM frequency")); +// } +// const pin_timer_t* t = self->timer; +// uint8_t resolution; +// if (t->is_tc) { +// resolution = 16; +// } else { +// resolution = 24; +// } +// uint32_t system_clock = common_hal_mcu_processor_get_frequency(); +// uint32_t new_top; +// uint8_t new_divisor; +// for (new_divisor = 0; new_divisor < 8; new_divisor++) { +// new_top = (system_clock / prescaler[new_divisor] / frequency) - 1; +// if (new_top < (1u << resolution)) { +// break; +// } +// } +// uint16_t old_duty = common_hal_pulseio_pwmout_get_duty_cycle(self); +// if (t->is_tc) { +// Tc* tc = tc_insts[t->index]; +// uint8_t old_divisor = tc->COUNT16.CTRLA.bit.PRESCALER; +// if (new_divisor != old_divisor) { +// tc_set_enable(tc, false); +// tc->COUNT16.CTRLA.bit.PRESCALER = new_divisor; +// tc_set_enable(tc, true); +// } +// tc_periods[t->index] = new_top; +// #ifdef SAMD21 +// tc->COUNT16.CC[0].reg = new_top; +// #endif +// #ifdef SAMD51 +// while (tc->COUNT16.SYNCBUSY.reg != 0) {} +// tc->COUNT16.CCBUF[0].reg = new_top; +// #endif +// } else { +// Tcc* tcc = tcc_insts[t->index]; +// uint8_t old_divisor = tcc->CTRLA.bit.PRESCALER; +// if (new_divisor != old_divisor) { +// tcc_set_enable(tcc, false); +// tcc->CTRLA.bit.PRESCALER = new_divisor; +// tcc_set_enable(tcc, true); +// } +// while (tcc->SYNCBUSY.reg != 0) {} +// tcc_periods[t->index] = new_top; +// #ifdef SAMD21 +// tcc->PERB.bit.PERB = new_top; +// #endif +// #ifdef SAMD51 +// tcc->PERBUF.bit.PERBUF = new_top; +// #endif +// } + +// common_hal_pulseio_pwmout_set_duty_cycle(self, old_duty); +} + +uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) { +// uint32_t system_clock = common_hal_mcu_processor_get_frequency(); +// const pin_timer_t* t = self->timer; +// uint8_t divisor; +// uint32_t top; +// if (t->is_tc) { +// divisor = tc_insts[t->index]->COUNT16.CTRLA.bit.PRESCALER; +// top = tc_periods[t->index]; +// } else { +// divisor = tcc_insts[t->index]->CTRLA.bit.PRESCALER; +// top = tcc_periods[t->index]; +// } +// return (system_clock / prescaler[divisor]) / (top + 1); + return 0; +} + +bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) { + return self->variable_frequency; +} diff --git a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.h b/ports/mimxrt10xx/common-hal/pulseio/PWMOut.h new file mode 100644 index 0000000000..2f0fe94c44 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/pulseio/PWMOut.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H + +#include "common-hal/microcontroller/Pin.h" +#include "periph.h" +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t *pin; + const mcu_pwm_obj_t *pwm; + bool variable_frequency; +} pulseio_pwmout_obj_t; + +void pwmout_reset(void); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c new file mode 100644 index 0000000000..24e9ad85de --- /dev/null +++ b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c @@ -0,0 +1,248 @@ +/* + * 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 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 "common-hal/pulseio/PulseIn.h" + +#include + +#include "background.h" +#include "mpconfigport.h" +#include "py/gc.h" +#include "py/runtime.h" + +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/pulseio/PulseIn.h" +#include "supervisor/shared/translate.h" + +#include "tick.h" + +// TODO +//static void pulsein_set_config(pulseio_pulsein_obj_t* self, bool first_edge) { +// uint32_t sense_setting; +// if (!first_edge) { +// sense_setting = EIC_CONFIG_SENSE0_BOTH_Val; +// configure_eic_channel(self->channel, sense_setting); +// return; +// } else if (self->idle_state) { +// sense_setting = EIC_CONFIG_SENSE0_FALL_Val; +// } else { +// sense_setting = EIC_CONFIG_SENSE0_RISE_Val; +// } +// set_eic_handler(self->channel, EIC_HANDLER_PULSEIN); +// turn_on_eic_channel(self->channel, sense_setting); +//} + +//void pulsein_interrupt_handler(uint8_t channel) { +// // Grab the current time first. +// uint32_t current_us; +// uint64_t current_ms; +// current_tick(¤t_ms, ¤t_us); +// +// // current_tick gives us the remaining us until the next tick but we want the number since the +// // last ms. +// current_us = 1000 - current_us; +// pulseio_pulsein_obj_t* self = get_eic_channel_data(channel); +// if (!background_tasks_ok() || self->errored_too_fast) { +// self->errored_too_fast = true; +// common_hal_pulseio_pulsein_pause(self); +// return; +// } +// if (self->first_edge) { +// self->first_edge = false; +// pulsein_set_config(self, false); +// } else { +// uint32_t ms_diff = current_ms - self->last_ms; +// uint16_t us_diff = current_us - self->last_us; +// uint32_t total_diff = us_diff; +// if (self->last_us > current_us) { +// total_diff = 1000 + current_us - self->last_us; +// if (ms_diff > 1) { +// total_diff += (ms_diff - 1) * 1000; +// } +// } else { +// total_diff += ms_diff * 1000; +// } +// uint16_t duration = 0xffff; +// if (total_diff < duration) { +// duration = total_diff; +// } +// +// uint16_t i = (self->start + self->len) % self->maxlen; +// self->buffer[i] = duration; +// if (self->len < self->maxlen) { +// self->len++; +// } else { +// self->start++; +// } +// } +// self->last_ms = current_ms; +// self->last_us = current_us; +//} + +void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, + const mcu_pin_obj_t* pin, uint16_t maxlen, bool idle_state) { +// if (!pin->has_extint) { +// mp_raise_RuntimeError(translate("No hardware support on pin")); +// } +// if (eic_get_enable() && !eic_channel_free(pin->extint_channel)) { +// mp_raise_RuntimeError(translate("EXTINT channel already in use")); +// } +// +// self->buffer = (uint16_t *) m_malloc(maxlen * sizeof(uint16_t), false); +// if (self->buffer == NULL) { +// mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t)); +// } +// self->channel = pin->extint_channel; +// self->pin = pin->number; +// self->maxlen = maxlen; +// self->idle_state = idle_state; +// self->start = 0; +// self->len = 0; +// self->first_edge = true; +// self->last_us = 0; +// self->last_ms = 0; +// self->errored_too_fast = false; +// +// set_eic_channel_data(pin->extint_channel, (void*) self); +// +// // Check to see if the EIC is enabled and start it up if its not.' +// if (eic_get_enable() == 0) { +// turn_on_external_interrupt_controller(); +// } +// +// gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_A); +// +// turn_on_cpu_interrupt(self->channel); +// +// claim_pin(pin); +// +// // Set config will enable the EIC. +// pulsein_set_config(self, true); +} + +bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) { +// return self->pin == NO_PIN; + return true; +} + +void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) { +// if (common_hal_pulseio_pulsein_deinited(self)) { +// return; +// } +// set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT); +// turn_off_eic_channel(self->channel); +// reset_pin_number(self->pin); +// self->pin = NO_PIN; +} + +void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self) { +// uint32_t mask = 1 << self->channel; +// EIC->INTENCLR.reg = mask << EIC_INTENSET_EXTINT_Pos; +} + +void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, + uint16_t trigger_duration) { +// // Make sure we're paused. +// common_hal_pulseio_pulsein_pause(self); +// +// // Reset erroring +// self->errored_too_fast = false; +// +// // Send the trigger pulse. +// if (trigger_duration > 0) { +// gpio_set_pin_pull_mode(self->pin, GPIO_PULL_OFF); +// gpio_set_pin_direction(self->pin, GPIO_DIRECTION_OUT); +// gpio_set_pin_level(self->pin, !self->idle_state); +// common_hal_mcu_delay_us((uint32_t)trigger_duration); +// gpio_set_pin_level(self->pin, self->idle_state); +// } +// +// // Reconfigure the pin and make sure its set to detect the first edge. +// self->first_edge = true; +// self->last_ms = 0; +// self->last_us = 0; +// gpio_set_pin_function(self->pin, GPIO_PIN_FUNCTION_A); +// uint32_t mask = 1 << self->channel; +// // Clear previous interrupt state and re-enable it. +// EIC->INTFLAG.reg = mask << EIC_INTFLAG_EXTINT_Pos; +// EIC->INTENSET.reg = mask << EIC_INTENSET_EXTINT_Pos; +// +// pulsein_set_config(self, true); +} + +void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) { +// common_hal_mcu_disable_interrupts(); +// self->start = 0; +// self->len = 0; +// common_hal_mcu_enable_interrupts(); +} + +uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) { +// if (self->len == 0) { +// mp_raise_IndexError(translate("pop from an empty PulseIn")); +// } +// common_hal_mcu_disable_interrupts(); +// uint16_t value = self->buffer[self->start]; +// self->start = (self->start + 1) % self->maxlen; +// self->len--; +// common_hal_mcu_enable_interrupts(); +// +// return value; + return 0; +} + +uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self) { +// return self->maxlen; + return 0; +} + +uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self) { +// return self->len; + return 0; +} + +bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t* self) { +// uint32_t mask = 1 << self->channel; +// return (EIC->INTENSET.reg & (mask << EIC_INTENSET_EXTINT_Pos)) == 0; + return true; +} + +uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, + int16_t index) { +// common_hal_mcu_disable_interrupts(); +// if (index < 0) { +// index += self->len; +// } +// if (index < 0 || index >= self->len) { +// common_hal_mcu_enable_interrupts(); +// mp_raise_IndexError(translate("index out of range")); +// } +// uint16_t value = self->buffer[(self->start + index) % self->maxlen]; +// common_hal_mcu_enable_interrupts(); +// return value; + return 0; +} diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseIn.h b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.h new file mode 100644 index 0000000000..af742f319f --- /dev/null +++ b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.h @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PULSEIN_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PULSEIN_H + +#include "common-hal/microcontroller/Pin.h" + +#include "py/obj.h" + +// TODO +typedef struct { + mp_obj_base_t base; +// uint8_t channel; +// uint8_t pin; +// uint16_t* buffer; +// uint16_t maxlen; +// bool idle_state; +// volatile uint16_t start; +// volatile uint16_t len; +// volatile bool first_edge; +// volatile uint64_t last_ms; +// volatile uint16_t last_us; +// volatile bool errored_too_fast; +} pulseio_pulsein_obj_t; + +//void pulsein_reset(void); +// +//void pulsein_interrupt_handler(uint8_t channel); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PULSEIN_H diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c new file mode 100644 index 0000000000..a49cfa7af7 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c @@ -0,0 +1,207 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Damien P. George + * 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 "common-hal/pulseio/PulseOut.h" + +#include + +#include "mpconfigport.h" +#include "py/gc.h" +#include "py/runtime.h" +#include "shared-bindings/pulseio/PulseOut.h" +#include "supervisor/shared/translate.h" + +// TODO + +// This timer is shared amongst all PulseOut objects under the assumption that +// the code is single threaded. +//static uint8_t refcount = 0; +// +//static uint8_t pulseout_tc_index = 0xff; +// +//static __IO PORT_PINCFG_Type *active_pincfg = NULL; +//static uint16_t *pulse_buffer = NULL; +//static volatile uint16_t pulse_index = 0; +//static uint16_t pulse_length; +//static volatile uint32_t current_compare = 0; +// +//static void turn_on(__IO PORT_PINCFG_Type * pincfg) { +// pincfg->reg = PORT_PINCFG_PMUXEN; +//} +// +//static void turn_off(__IO PORT_PINCFG_Type * pincfg) { +// pincfg->reg = PORT_PINCFG_RESETVALUE; +//} +// +//void pulse_finish(void) { +// pulse_index++; +// +// if (active_pincfg == NULL) { +// return; +// } +// // Always turn it off. +// turn_off(active_pincfg); +// if (pulse_index >= pulse_length) { +// return; +// } +// current_compare = (current_compare + pulse_buffer[pulse_index] * 3 / 4) & 0xffff; +// Tc* tc = tc_insts[pulseout_tc_index]; +// tc->COUNT16.CC[0].reg = current_compare; +// if (pulse_index % 2 == 0) { +// turn_on(active_pincfg); +// } +//} + +void pulseout_interrupt_handler(uint8_t index) { +// if (index != pulseout_tc_index) return; +// Tc* tc = tc_insts[index]; +// if (!tc->COUNT16.INTFLAG.bit.MC0) return; +// +// pulse_finish(); +// +// // Clear the interrupt bit. +// tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; +} + +void pulseout_reset() { +// refcount = 0; +// pulseout_tc_index = 0xff; +// active_pincfg = NULL; +} + +void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self, + const pulseio_pwmout_obj_t* carrier) { +// if (refcount == 0) { +// // Find a spare timer. +// Tc *tc = NULL; +// int8_t index = TC_INST_NUM - 1; +// for (; index >= 0; index--) { +// if (tc_insts[index]->COUNT16.CTRLA.bit.ENABLE == 0) { +// tc = tc_insts[index]; +// break; +// } +// } +// if (tc == NULL) { +// mp_raise_RuntimeError(translate("All timers in use")); +// } +// +// pulseout_tc_index = index; +// +// set_timer_handler(true, index, TC_HANDLER_PULSEOUT); +// // We use GCLK0 for SAMD21 and GCLK1 for SAMD51 because they both run at 48mhz making our +// // math the same across the boards. +// #ifdef SAMD21 +// turn_on_clocks(true, index, 0); +// #endif +// #ifdef SAMD51 +// turn_on_clocks(true, index, 1); +// #endif +// +// +// #ifdef SAMD21 +// tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | +// TC_CTRLA_PRESCALER_DIV64 | +// TC_CTRLA_WAVEGEN_NFRQ; +// #endif +// #ifdef SAMD51 +// tc_reset(tc); +// tc_set_enable(tc, false); +// tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_PRESCALER_DIV64; +// tc->COUNT16.WAVE.reg = TC_WAVE_WAVEGEN_NFRQ; +// #endif +// +// tc_set_enable(tc, true); +// tc->COUNT16.CTRLBSET.reg = TC_CTRLBSET_CMD_STOP; +// } +// refcount++; +// +// self->pin = carrier->pin->number; +// +// PortGroup *const port_base = &PORT->Group[GPIO_PORT(self->pin)]; +// self->pincfg = &port_base->PINCFG[self->pin % 32]; +// +// // Set the port to output a zero. +// port_base->OUTCLR.reg = 1 << (self->pin % 32); +// port_base->DIRSET.reg = 1 << (self->pin % 32); +// +// // Turn off the pinmux which should connect the port output. +// turn_off(self->pincfg); +} + +bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self) { +// return self->pin == NO_PIN; + return false; +} + +void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) { +// if (common_hal_pulseio_pulseout_deinited(self)) { +// return; +// } +// PortGroup *const port_base = &PORT->Group[GPIO_PORT(self->pin)]; +// port_base->DIRCLR.reg = 1 << (self->pin % 32); +// +// turn_on(self->pincfg); +// +// refcount--; +// if (refcount == 0) { +// tc_reset(tc_insts[pulseout_tc_index]); +// pulseout_tc_index = 0xff; +// } +// self->pin = NO_PIN; +} + +void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) { +// if (active_pincfg != NULL) { +// mp_raise_RuntimeError(translate("Another send is already active")); +// } +// active_pincfg = self->pincfg; +// pulse_buffer = pulses; +// pulse_index = 0; +// pulse_length = length; +// +// current_compare = pulses[0] * 3 / 4; +// Tc* tc = tc_insts[pulseout_tc_index]; +// tc->COUNT16.CC[0].reg = current_compare; +// +// // Clear our interrupt in case it was set earlier +// tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; +// tc->COUNT16.INTENSET.reg = TC_INTENSET_MC0; +// tc_enable_interrupts(pulseout_tc_index); +// turn_on(active_pincfg); +// tc->COUNT16.CTRLBSET.reg = TC_CTRLBSET_CMD_RETRIGGER; +// +// while(pulse_index < length) { +// // Do other things while we wait. The interrupts will handle sending the +// // signal. +// RUN_BACKGROUND_TASKS; +// } +// +// tc->COUNT16.CTRLBSET.reg = TC_CTRLBSET_CMD_STOP; +// tc->COUNT16.INTENCLR.reg = TC_INTENCLR_MC0; +// tc_disable_interrupts(pulseout_tc_index); +// active_pincfg = NULL; +} diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseOut.h b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.h new file mode 100644 index 0000000000..ee70ac17ec --- /dev/null +++ b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.h @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PULSEOUT_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PULSEOUT_H + +#include "common-hal/microcontroller/Pin.h" + +#include "py/obj.h" + +// TODO +typedef struct { + mp_obj_base_t base; +// __IO PORT_PINCFG_Type *pincfg; +// uint8_t pin; +} pulseio_pulseout_obj_t; + +void pulseout_reset(void); +//void pulseout_interrupt_handler(uint8_t index); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PULSEOUT_H diff --git a/ports/mimxrt10xx/common-hal/pulseio/__init__.c b/ports/mimxrt10xx/common-hal/pulseio/__init__.c new file mode 100644 index 0000000000..2bee925bc7 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/pulseio/__init__.c @@ -0,0 +1 @@ +// No pulseio module functions. diff --git a/ports/mimxrt10xx/common-hal/rtc/RTC.c b/ports/mimxrt10xx/common-hal/rtc/RTC.c new file mode 100644 index 0000000000..5d6cae5201 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/rtc/RTC.c @@ -0,0 +1,76 @@ +/* + * 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) 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 + +#include "py/obj.h" +#include "py/runtime.h" +#include "lib/timeutils/timeutils.h" +#include "shared-bindings/rtc/__init__.h" +#include "supervisor/shared/translate.h" + +#include "fsl_snvs_hp.h" + +void rtc_init(void) { + snvs_hp_rtc_config_t config; + SNVS_HP_RTC_GetDefaultConfig(&config); + + SNVS_HP_RTC_Init(SNVS, &config); + SNVS_HP_RTC_StartTimer(SNVS); +} + +void common_hal_rtc_get_time(timeutils_struct_time_t *tm) { + snvs_hp_rtc_datetime_t rtcDate; + SNVS_HP_RTC_GetDatetime(SNVS, &rtcDate); + + tm->tm_year = rtcDate.year; + tm->tm_mon = rtcDate.month; + tm->tm_mday = rtcDate.day; + tm->tm_hour = rtcDate.hour; + tm->tm_min = rtcDate.minute; + tm->tm_sec = rtcDate.second; +} + +void common_hal_rtc_set_time(timeutils_struct_time_t *tm) { + snvs_hp_rtc_datetime_t rtcDate; + rtcDate.year = tm->tm_year; + rtcDate.month = tm->tm_mon; + rtcDate.day = tm->tm_mday; + rtcDate.hour = tm->tm_hour; + rtcDate.minute = tm->tm_min; + rtcDate.second = tm->tm_sec; + + SNVS_HP_RTC_SetDatetime(SNVS, &rtcDate); +} + +int common_hal_rtc_get_calibration(void) { + return 0; +} + +void common_hal_rtc_set_calibration(int calibration) { + mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board")); +} diff --git a/ports/mimxrt10xx/common-hal/rtc/RTC.h b/ports/mimxrt10xx/common-hal/rtc/RTC.h new file mode 100644 index 0000000000..4965356c50 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/rtc/RTC.h @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Noralf Trønnes + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_RTC_RTC_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_RTC_RTC_H + +extern void rtc_init(void); +extern void rtc_reset(void); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_RTC_RTC_H diff --git a/ports/mimxrt10xx/common-hal/rtc/__init__.c b/ports/mimxrt10xx/common-hal/rtc/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/mimxrt10xx/common-hal/supervisor/Runtime.c b/ports/mimxrt10xx/common-hal/supervisor/Runtime.c new file mode 100755 index 0000000000..6be38f216a --- /dev/null +++ b/ports/mimxrt10xx/common-hal/supervisor/Runtime.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Michael Schroeder + * + * 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-bindings/supervisor/Runtime.h" +#include "supervisor/serial.h" + +bool common_hal_get_serial_connected(void) { + return (bool) serial_connected(); +} + +bool common_hal_get_serial_bytes_available(void) { + return (bool) serial_bytes_available(); +} diff --git a/ports/mimxrt10xx/common-hal/supervisor/Runtime.h b/ports/mimxrt10xx/common-hal/supervisor/Runtime.h new file mode 100755 index 0000000000..11bb590635 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/supervisor/Runtime.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Michael Schroeder + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_SUPERVISOR_RUNTIME_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_SUPERVISOR_RUNTIME_H + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + // Stores no state currently. +} super_runtime_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_SUPERVISOR_RUNTIME_H diff --git a/ports/mimxrt10xx/common-hal/supervisor/__init__.c b/ports/mimxrt10xx/common-hal/supervisor/__init__.c new file mode 100755 index 0000000000..ac88556b45 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/supervisor/__init__.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Michael Schroeder + * + * 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/obj.h" + +#include "shared-bindings/supervisor/__init__.h" +#include "shared-bindings/supervisor/Runtime.h" + + +// The singleton supervisor.Runtime object, bound to supervisor.runtime +// It currently only has properties, and no state. +const super_runtime_obj_t common_hal_supervisor_runtime_obj = { + .base = { + .type = &supervisor_runtime_type, + }, +}; \ No newline at end of file diff --git a/ports/mimxrt10xx/common-hal/time/__init__.c b/ports/mimxrt10xx/common-hal/time/__init__.c new file mode 100644 index 0000000000..2d82b3d1ad --- /dev/null +++ b/ports/mimxrt10xx/common-hal/time/__init__.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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 "py/mphal.h" + +#include "shared-bindings/time/__init__.h" + +#include "supervisor/shared/tick.h" + +inline uint64_t common_hal_time_monotonic() { + return supervisor_ticks_ms64(); +} + +void common_hal_time_delay_ms(uint32_t delay) { + mp_hal_delay_ms(delay); +} diff --git a/ports/mimxrt10xx/fatfs_port.c b/ports/mimxrt10xx/fatfs_port.c new file mode 100644 index 0000000000..c4ce18c2a7 --- /dev/null +++ b/ports/mimxrt10xx/fatfs_port.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * + * 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/mphal.h" +#include "py/runtime.h" +#include "lib/oofatfs/ff.h" /* FatFs lower layer API */ +#include "lib/oofatfs/diskio.h" /* FatFs lower layer API */ +#include "lib/timeutils/timeutils.h" + +#if CIRCUITPY_RTC +#include "shared-bindings/rtc/RTC.h" +#endif + +DWORD get_fattime(void) { +#if CIRCUITPY_RTC + timeutils_struct_time_t tm; + common_hal_rtc_get_time(&tm); + return ((tm.tm_year - 1980) << 25) | (tm.tm_mon << 21) | (tm.tm_mday << 16) | + (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec >> 1); +#else + return ((2016 - 1980) << 25) | ((9) << 21) | ((1) << 16) | ((16) << 11) | ((43) << 5) | (35 / 2); +#endif + + +} diff --git a/ports/mimxrt10xx/mpconfigport.h b/ports/mimxrt10xx/mpconfigport.h new file mode 100644 index 0000000000..47b793fed9 --- /dev/null +++ b/ports/mimxrt10xx/mpconfigport.h @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert 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. + */ + +#ifndef __INCLUDED_MPCONFIGPORT_H +#define __INCLUDED_MPCONFIGPORT_H + +#define MICROPY_PY_SYS_PLATFORM "NXP IMXRT10XX" +#define SPI_FLASH_MAX_BAUDRATE 24000000 + +// 20kiB stack +#define CIRCUITPY_DEFAULT_STACK_SIZE 0x5000 +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) +#define MICROPY_PY_FUNCTION_ATTRS (0) +#define MICROPY_PY_IO (1) +#define MICROPY_PY_UJSON (1) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) + +#include "py/circuitpy_mpconfig.h" + +#define MICROPY_PORT_ROOT_POINTERS \ + CIRCUITPY_COMMON_ROOT_POINTERS \ + +// TODO: +// mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; + +#endif // __INCLUDED_MPCONFIGPORT_H diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk new file mode 100644 index 0000000000..f1106e88f0 --- /dev/null +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -0,0 +1,20 @@ +# 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. + +ifeq ($(LONGINT_IMPL),NONE) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none +endif + +ifeq ($(LONGINT_IMPL),MPZ) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz +endif + +ifeq ($(LONGINT_IMPL),LONGLONG) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong +endif + +INTERNAL_LIBM = 1 + +USB_SERIAL_NUMBER_LENGTH = 32 +USB_MSC_MAX_PACKET_SIZE = 512 diff --git a/ports/mimxrt10xx/mphalport.c b/ports/mimxrt10xx/mphalport.c new file mode 100644 index 0000000000..b333730b9a --- /dev/null +++ b/ports/mimxrt10xx/mphalport.c @@ -0,0 +1,65 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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 "py/mpstate.h" +#include "py/smallint.h" + +#include "shared-bindings/microcontroller/__init__.h" +#include "supervisor/shared/tick.h" + +#include "fsl_common.h" + +void mp_hal_delay_ms(mp_uint_t delay) { + uint64_t start_tick = supervisor_ticks_ms64(); + uint64_t duration = 0; + while (duration < delay) { + RUN_BACKGROUND_TASKS; + // Check to see if we've been CTRL-Ced by autoreload or the user. + if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) || + MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { + break; + } + duration = (supervisor_ticks_ms64() - start_tick); + // TODO(tannewt): Go to sleep for a little while while we wait. + } +} + +void mp_hal_delay_us(mp_uint_t delay) { +#ifdef MIMXRT1011_SERIES + SDK_DelayAtLeastUs(delay, SystemCoreClock); +#else + SDK_DelayAtLeastUs(delay); +#endif +} + +void mp_hal_disable_all_interrupts(void) { + common_hal_mcu_disable_interrupts(); +} + +void mp_hal_enable_all_interrupts(void) { + common_hal_mcu_enable_interrupts(); +} diff --git a/ports/mimxrt10xx/mphalport.h b/ports/mimxrt10xx/mphalport.h new file mode 100644 index 0000000000..1acc461b7e --- /dev/null +++ b/ports/mimxrt10xx/mphalport.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_MPHALPORT_H +#define MICROPY_INCLUDED_MIMXRT10XX_MPHALPORT_H + +#include "py/obj.h" + +#include "lib/oofatfs/ff.h" + +#include "supervisor/shared/tick.h" + +// Global millisecond tick count (driven by SysTick interrupt). +static inline mp_uint_t mp_hal_ticks_ms(void) { + return supervisor_ticks_ms32(); +} +// Number of bytes in receive buffer +volatile uint8_t usb_rx_count; +volatile bool mp_cdc_enabled; + +int receive_usb(void); + +void mp_hal_set_interrupt_char(int c); + +void mp_hal_disable_all_interrupts(void); +void mp_hal_enable_all_interrupts(void); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_MPHALPORT_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c new file mode 100644 index 0000000000..59f7bcd24a --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c @@ -0,0 +1,293 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "mpconfigport.h" + +#include "fsl_clock.h" +#include "fsl_iomuxc.h" + +#define BOARD_XTAL0_CLK_HZ 24000000U /*!< Board xtal0 frequency in Hz */ +#define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32k frequency in Hz */ + +#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 500000000U /*!< Core clock frequency: 500000000Hz */ + +/* Clock outputs (values are in Hz): */ +#define BOARD_BOOTCLOCKRUN_ADC_ALT_CLK 40000000UL +#define BOARD_BOOTCLOCKRUN_CKIL_SYNC_CLK_ROOT 32768UL +#define BOARD_BOOTCLOCKRUN_CLKO1_CLK 0UL +#define BOARD_BOOTCLOCKRUN_CLKO2_CLK 0UL +#define BOARD_BOOTCLOCKRUN_CLK_1M 1000000UL +#define BOARD_BOOTCLOCKRUN_CLK_24M 24000000UL +#define BOARD_BOOTCLOCKRUN_CORE_CLK_ROOT 500000000UL +#define BOARD_BOOTCLOCKRUN_ENET_500M_REF_CLK 500000000UL +#define BOARD_BOOTCLOCKRUN_FLEXIO1_CLK_ROOT 30000000UL +#define BOARD_BOOTCLOCKRUN_FLEXSPI_CLK_ROOT 132000000UL +#define BOARD_BOOTCLOCKRUN_GPT1_IPG_CLK_HIGHFREQ 62500000UL +#define BOARD_BOOTCLOCKRUN_GPT2_IPG_CLK_HIGHFREQ 62500000UL +#define BOARD_BOOTCLOCKRUN_IPG_CLK_ROOT 125000000UL +#define BOARD_BOOTCLOCKRUN_LPI2C_CLK_ROOT 60000000UL +#define BOARD_BOOTCLOCKRUN_LPSPI_CLK_ROOT 105600000UL +#define BOARD_BOOTCLOCKRUN_MQS_MCLK 63529411UL +#define BOARD_BOOTCLOCKRUN_PERCLK_CLK_ROOT 62500000UL +#define BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI1_MCLK1 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI1_MCLK2 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI1_MCLK3 30000000UL +#define BOARD_BOOTCLOCKRUN_SAI3_CLK_ROOT 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI3_MCLK1 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI3_MCLK2 0UL +#define BOARD_BOOTCLOCKRUN_SAI3_MCLK3 30000000UL +#define BOARD_BOOTCLOCKRUN_SPDIF0_CLK_ROOT 30000000UL +#define BOARD_BOOTCLOCKRUN_SPDIF0_EXTCLK_OUT 0UL +#define BOARD_BOOTCLOCKRUN_TRACE_CLK_ROOT 117333333UL +#define BOARD_BOOTCLOCKRUN_UART_CLK_ROOT 80000000UL +#define BOARD_BOOTCLOCKRUN_USBPHY_CLK 0UL + +/*! @brief Usb1 PLL set for BOARD_BootClockRUN configuration. + */ +//extern const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN; +/*! @brief Sys PLL for BOARD_BootClockRUN configuration. + */ +//extern const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN; +/*! @brief Enet PLL set for BOARD_BootClockRUN configuration. + */ +//extern const clock_enet_pll_config_t enetPllConfig_BOARD_BootClockRUN; + +const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN = { + .loopDivider = 1, /* PLL loop divider, Fout = Fin * ( 20 + loopDivider*2 + numerator / denominator ) */ + .numerator = 0, /* 30 bit numerator of fractional loop divider */ + .denominator = 1, /* 30 bit denominator of fractional loop divider */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ +}; +const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN = { + .loopDivider = 0, /* PLL loop divider, Fout = Fin * 20 */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ +}; +const clock_enet_pll_config_t enetPllConfig_BOARD_BootClockRUN = { + .enableClkOutput500M = true, /* Enable the PLL providing the ENET 500MHz reference clock */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ +}; +void clocks_init(void) { + /* Init RTC OSC clock frequency. */ + CLOCK_SetRtcXtalFreq(32768U); + /* Enable 1MHz clock output. */ + XTALOSC24M->OSC_CONFIG2 |= XTALOSC24M_OSC_CONFIG2_ENABLE_1M_MASK; + /* Use free 1MHz clock output. */ + XTALOSC24M->OSC_CONFIG2 &= ~XTALOSC24M_OSC_CONFIG2_MUX_1M_MASK; + /* Set XTAL 24MHz clock frequency. */ + CLOCK_SetXtalFreq(24000000U); + /* Enable XTAL 24MHz clock source. */ + CLOCK_InitExternalClk(0); + /* Enable internal RC. */ + CLOCK_InitRcOsc24M(); + /* Switch clock source to external OSC. */ + CLOCK_SwitchOsc(kCLOCK_XtalOsc); + /* Set Oscillator ready counter value. */ + CCM->CCR = (CCM->CCR & (~CCM_CCR_OSCNT_MASK)) | CCM_CCR_OSCNT(127); + /* Setting PeriphClk2Mux and PeriphMux to provide stable clock before PLLs are initialed */ + CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 1); /* Set PERIPH_CLK2 MUX to OSC */ + CLOCK_SetMux(kCLOCK_PeriphMux, 1); /* Set PERIPH_CLK MUX to PERIPH_CLK2 */ + /* Setting the VDD_SOC to 1.5V. It is necessary to config CORE to 500Mhz. */ + DCDC->REG3 = (DCDC->REG3 & (~DCDC_REG3_TRG_MASK)) | DCDC_REG3_TRG(0x12); + /* Waiting for DCDC_STS_DC_OK bit is asserted */ + while (DCDC_REG0_STS_DC_OK_MASK != (DCDC_REG0_STS_DC_OK_MASK & DCDC->REG0)) + { + } + /* Set AHB_PODF. */ + CLOCK_SetDiv(kCLOCK_AhbDiv, 0); + /* Disable IPG clock gate. */ + CLOCK_DisableClock(kCLOCK_Adc1); + CLOCK_DisableClock(kCLOCK_Xbar1); + /* Set IPG_PODF. */ + CLOCK_SetDiv(kCLOCK_IpgDiv, 3); + /* Disable PERCLK clock gate. */ + CLOCK_DisableClock(kCLOCK_Gpt1); + CLOCK_DisableClock(kCLOCK_Gpt1S); + CLOCK_DisableClock(kCLOCK_Gpt2); + CLOCK_DisableClock(kCLOCK_Gpt2S); + CLOCK_DisableClock(kCLOCK_Pit); + /* Set PERCLK_PODF. */ + CLOCK_SetDiv(kCLOCK_PerclkDiv, 1); + /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. + * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left + * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as + * well.*/ +#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) + /* Disable Flexspi clock gate. */ + CLOCK_DisableClock(kCLOCK_FlexSpi); + /* Set FLEXSPI_PODF. */ + CLOCK_SetDiv(kCLOCK_FlexspiDiv, 3); + /* Set Flexspi clock source. */ + CLOCK_SetMux(kCLOCK_FlexspiMux, 0); + CLOCK_SetMux(kCLOCK_FlexspiSrcMux, 0); +#endif + /* Disable ADC_ACLK_EN clock gate. */ + CCM->CSCMR2 &= ~CCM_CSCMR2_ADC_ACLK_EN_MASK; + /* Set ADC_ACLK_PODF. */ + CLOCK_SetDiv(kCLOCK_AdcDiv, 11); + /* Disable LPSPI clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpspi1); + CLOCK_DisableClock(kCLOCK_Lpspi2); + /* Set LPSPI_PODF. */ + CLOCK_SetDiv(kCLOCK_LpspiDiv, 7); + /* Set Lpspi clock source. */ + CLOCK_SetMux(kCLOCK_LpspiMux, 1); + /* Disable TRACE clock gate. */ + CLOCK_DisableClock(kCLOCK_Trace); + /* Set TRACE_PODF. */ + CLOCK_SetDiv(kCLOCK_TraceDiv, 2); + /* Set Trace clock source. */ + CLOCK_SetMux(kCLOCK_TraceMux, 2); + /* Disable SAI1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai1); + /* Set SAI1_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai1PreDiv, 3); + /* Set SAI1_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai1Div, 1); + /* Set Sai1 clock source. */ + CLOCK_SetMux(kCLOCK_Sai1Mux, 0); + /* Disable SAI3 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai3); + /* Set SAI3_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai3PreDiv, 3); + /* Set SAI3_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai3Div, 1); + /* Set Sai3 clock source. */ + CLOCK_SetMux(kCLOCK_Sai3Mux, 0); + /* Disable Lpi2c clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpi2c1); + CLOCK_DisableClock(kCLOCK_Lpi2c2); + /* Set LPI2C_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Lpi2cDiv, 5U); + /* Set Lpi2c clock source. */ + CLOCK_SetMux(kCLOCK_Lpi2cMux, 0); + /* Disable UART clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpuart1); + CLOCK_DisableClock(kCLOCK_Lpuart2); + CLOCK_DisableClock(kCLOCK_Lpuart3); + CLOCK_DisableClock(kCLOCK_Lpuart4); + /* Set UART_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_UartDiv, 0); + /* Set Uart clock source. */ + CLOCK_SetMux(kCLOCK_UartMux, 0); + /* Disable SPDIF clock gate. */ + CLOCK_DisableClock(kCLOCK_Spdif); + /* Set SPDIF0_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Spdif0PreDiv, 1); + /* Set SPDIF0_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Spdif0Div, 7); + /* Set Spdif clock source. */ + CLOCK_SetMux(kCLOCK_SpdifMux, 3); + /* Disable Flexio1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Flexio1); + /* Set FLEXIO1_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Flexio1PreDiv, 1); + /* Set FLEXIO1_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Flexio1Div, 7); + /* Set Flexio1 clock source. */ + CLOCK_SetMux(kCLOCK_Flexio1Mux, 3); + /* Set Pll3 sw clock source. */ + CLOCK_SetMux(kCLOCK_Pll3SwMux, 0); + /* Init System PLL. */ + CLOCK_InitSysPll(&sysPllConfig_BOARD_BootClockRUN); + /* Init System pfd0. */ + CLOCK_InitSysPfd(kCLOCK_Pfd0, 27); + /* Init System pfd1. */ + CLOCK_InitSysPfd(kCLOCK_Pfd1, 16); + /* Init System pfd2. */ + CLOCK_InitSysPfd(kCLOCK_Pfd2, 18); + /* Init System pfd3. */ + CLOCK_InitSysPfd(kCLOCK_Pfd3, 18); + /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. + * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left + * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as + * well.*/ +#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) + /* Init Usb1 PLL. */ + CLOCK_InitUsb1Pll(&usb1PllConfig_BOARD_BootClockRUN); + /* Init Usb1 pfd0. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 22); + /* Init Usb1 pfd1. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd1, 16); + /* Init Usb1 pfd2. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd2, 17); + /* Init Usb1 pfd3. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd3, 18); + /* Disable Usb1 PLL output for USBPHY1. */ + CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; +#endif + /* 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; + /* Init Enet PLL. */ + CLOCK_InitEnetPll(&enetPllConfig_BOARD_BootClockRUN); + /* Set preperiph clock source. */ + CLOCK_SetMux(kCLOCK_PrePeriphMux, 3); + /* Set periph clock source. */ + CLOCK_SetMux(kCLOCK_PeriphMux, 0); + /* Set periph clock2 clock source. */ + CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 0); + /* Set per clock source. */ + CLOCK_SetMux(kCLOCK_PerclkMux, 0); + /* Set clock out1 divider. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO1_DIV_MASK)) | CCM_CCOSR_CLKO1_DIV(0); + /* Set clock out1 source. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO1_SEL_MASK)) | CCM_CCOSR_CLKO1_SEL(1); + /* Set clock out2 divider. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO2_DIV_MASK)) | CCM_CCOSR_CLKO2_DIV(0); + /* Set clock out2 source. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO2_SEL_MASK)) | CCM_CCOSR_CLKO2_SEL(18); + /* Set clock out1 drives clock out1. */ + CCM->CCOSR &= ~CCM_CCOSR_CLK_OUT_SEL_MASK; + /* Disable clock out1. */ + CCM->CCOSR &= ~CCM_CCOSR_CLKO1_EN_MASK; + /* Disable clock out2. */ + CCM->CCOSR &= ~CCM_CCOSR_CLKO2_EN_MASK; + /* Set SAI1 MCLK1 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk1Sel, 0); + /* Set SAI1 MCLK2 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk2Sel, 0); + /* Set SAI1 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk3Sel, 0); + /* Set SAI3 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI3MClk3Sel, 0); + /* Set MQS configuration. */ + IOMUXC_MQSConfig(IOMUXC_GPR, kIOMUXC_MqsPwmOverSampleRate32, 0); + /* Set GPT1 High frequency reference clock source. */ + IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT1_MASK; + /* Set GPT2 High frequency reference clock source. */ + IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT2_MASK; + /* Set SystemCoreClock variable. */ + SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK; + + CLOCK_EnableClock(kCLOCK_Iomuxc); +} diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c new file mode 100644 index 0000000000..e9d735830f --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c @@ -0,0 +1,148 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "py/obj.h" +#include "py/mphal.h" +#include "mimxrt10xx/periph.h" + +LPI2C_Type *mcu_i2c_banks[] = { 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), + PERIPH_PIN(1, 1, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 1, &pin_GPIO_SD_05), + PERIPH_PIN(1, 1, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 2, &pin_GPIO_11), + PERIPH_PIN(1, 3, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 3, &pin_GPIO_01), + + PERIPH_PIN(2, 0, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_07), + PERIPH_PIN(2, 3, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 1, &pin_GPIO_AD_01), + PERIPH_PIN(2, 1, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 2, &pin_GPIO_SD_07), + PERIPH_PIN(2, 3, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 3, &pin_GPIO_09), +}; + +const mcu_periph_obj_t mcu_i2c_scl_list[8] = { + PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_14), + PERIPH_PIN(1, 1, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 1, &pin_GPIO_SD_06), + PERIPH_PIN(1, 1, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 2, &pin_GPIO_12), + PERIPH_PIN(1, 3, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 3, &pin_GPIO_02), + + PERIPH_PIN(2, 0, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_08), + PERIPH_PIN(2, 3, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 1, &pin_GPIO_AD_02), + PERIPH_PIN(2, 1, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 2, &pin_GPIO_SD_08), + PERIPH_PIN(2, 3, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 3, &pin_GPIO_10), +}; + +LPSPI_Type *mcu_spi_banks[] = { 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), + PERIPH_PIN(1, 2, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 1, &pin_GPIO_SD_08), + + PERIPH_PIN(2, 0, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_12), + PERIPH_PIN(2, 1, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 1, &pin_GPIO_SD_11), +}; + +const mcu_periph_obj_t mcu_spi_mosi_list[4] = { + PERIPH_PIN(1, 0, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_04), + PERIPH_PIN(1, 2, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 1, &pin_GPIO_SD_06), + + PERIPH_PIN(2, 0, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_10), + PERIPH_PIN(2, 1, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_SD_10), +}; + +const mcu_periph_obj_t mcu_spi_miso_list[4] = { + PERIPH_PIN(1, 0, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_03), + PERIPH_PIN(1, 2, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 1, &pin_GPIO_SD_05), + + PERIPH_PIN(2, 0, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_09), + PERIPH_PIN(2, 1, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_SD_09), +}; + +LPUART_Type *mcu_uart_banks[] = { 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), + PERIPH_PIN(1, 0, kIOMUXC_LPUART1_RXD_SELECT_INPUT, 1, &pin_GPIO_09), + + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RXD_SELECT_INPUT, 0, &pin_GPIO_SD_09), + PERIPH_PIN(2, 0, kIOMUXC_LPUART2_RXD_SELECT_INPUT, 1, &pin_GPIO_13), + + PERIPH_PIN(3, 1, kIOMUXC_LPUART3_RXD_SELECT_INPUT, 0, &pin_GPIO_AD_07), + PERIPH_PIN(3, 0, kIOMUXC_LPUART3_RXD_SELECT_INPUT, 1, &pin_GPIO_11), + PERIPH_PIN(3, 3, kIOMUXC_LPUART3_RXD_SELECT_INPUT, 2, &pin_GPIO_07), + + PERIPH_PIN(4, 0, kIOMUXC_LPUART4_RXD_SELECT_INPUT, 0, &pin_GPIO_AD_01), + PERIPH_PIN(4, 3, kIOMUXC_LPUART4_RXD_SELECT_INPUT, 1, &pin_GPIO_05), +}; + +const mcu_periph_obj_t mcu_uart_tx_list[9] = { + PERIPH_PIN(1, 2, kIOMUXC_LPUART1_TXD_SELECT_INPUT, 0, &pin_GPIO_SD_12), + PERIPH_PIN(1, 0, kIOMUXC_LPUART1_TXD_SELECT_INPUT, 1, &pin_GPIO_10), + + PERIPH_PIN(2, 0, kIOMUXC_LPUART2_TXD_SELECT_INPUT, 0, &pin_GPIO_AD_00), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TXD_SELECT_INPUT, 1, &pin_GPIO_SD_10), + + PERIPH_PIN(3, 1, kIOMUXC_LPUART3_TXD_SELECT_INPUT, 0, &pin_GPIO_AD_08), + PERIPH_PIN(3, 0, kIOMUXC_LPUART3_TXD_SELECT_INPUT, 1, &pin_GPIO_12), + PERIPH_PIN(3, 3, kIOMUXC_LPUART3_TXD_SELECT_INPUT, 2, &pin_GPIO_08), + + PERIPH_PIN(4, 0, kIOMUXC_LPUART4_TXD_SELECT_INPUT, 0, &pin_GPIO_AD_02), + PERIPH_PIN(4, 3, kIOMUXC_LPUART4_TXD_SELECT_INPUT, 1, &pin_GPIO_06), +}; + +const mcu_pwm_obj_t mcu_pwm_list[20] = { + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 2, &pin_GPIO_02), + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 2, &pin_GPIO_SD_02), + + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmB, 2, &pin_GPIO_01), + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmB, 2, &pin_GPIO_SD_01), + + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmX, 1, &pin_GPIO_AD_12), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmA, 2, &pin_GPIO_04), + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmA, 2, &pin_GPIO_SD_04), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmB, 2, &pin_GPIO_03), + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmB, 2, &pin_GPIO_SD_03), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmX, 1, &pin_GPIO_AD_11), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmA, 2, &pin_GPIO_06), + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmA, 2, &pin_GPIO_AD_04), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmB, 2, &pin_GPIO_05), + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmB, 2, &pin_GPIO_AD_03), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmX, 1, &pin_GPIO_AD_10), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 2, &pin_GPIO_08), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 2, &pin_GPIO_AD_06), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 2, &pin_GPIO_07), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 2, &pin_GPIO_AD_05), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmX, 1, &pin_GPIO_AD_09), +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h new file mode 100644 index 0000000000..c91d5808af --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h @@ -0,0 +1,42 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H + +extern const mcu_periph_obj_t mcu_i2c_sda_list[8]; +extern const mcu_periph_obj_t mcu_i2c_scl_list[8]; + +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 const mcu_periph_obj_t mcu_uart_rx_list[9]; +extern const mcu_periph_obj_t mcu_uart_tx_list[9]; + +extern const mcu_pwm_obj_t mcu_pwm_list[20]; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIP_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c new file mode 100644 index 0000000000..0b219468f5 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c @@ -0,0 +1,77 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "py/obj.h" +#include "py/mphal.h" +#include "mimxrt10xx/pins.h" + +const mcu_pin_obj_t pin_GPIO_00 = PIN(GPIO1, 0, GPIO_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_01 = PIN(GPIO1, 1, GPIO_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_02 = PIN(GPIO1, 2, GPIO_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_03 = PIN(GPIO1, 3, GPIO_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_04 = PIN(GPIO1, 4, GPIO_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_05 = PIN(GPIO1, 5, GPIO_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_06 = PIN(GPIO1, 6, GPIO_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_07 = PIN(GPIO1, 7, GPIO_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_08 = PIN(GPIO1, 8, GPIO_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_09 = PIN(GPIO1, 9, GPIO_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_10 = PIN(GPIO1, 10, GPIO_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_11 = PIN(GPIO1, 11, GPIO_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_12 = PIN(GPIO1, 12, GPIO_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_13 = PIN(GPIO1, 13, GPIO_11, NO_ADC, 0); + +const mcu_pin_obj_t pin_GPIO_AD_00 = PIN(GPIO1, 14, GPIO_AD_00, ADC1, 0); +const mcu_pin_obj_t pin_GPIO_AD_01 = PIN(GPIO1, 15, GPIO_AD_01, ADC1, 1); +const mcu_pin_obj_t pin_GPIO_AD_02 = PIN(GPIO1, 16, GPIO_AD_02, ADC1, 2); +const mcu_pin_obj_t pin_GPIO_AD_03 = PIN(GPIO1, 17, GPIO_AD_03, ADC1, 3); +const mcu_pin_obj_t pin_GPIO_AD_04 = PIN(GPIO1, 18, GPIO_AD_04, ADC1, 4); +const mcu_pin_obj_t pin_GPIO_AD_05 = PIN(GPIO1, 19, GPIO_AD_05, ADC1, 5); +const mcu_pin_obj_t pin_GPIO_AD_06 = PIN(GPIO1, 20, GPIO_AD_06, ADC1, 6); +const mcu_pin_obj_t pin_GPIO_AD_07 = PIN(GPIO1, 21, GPIO_AD_07, ADC1, 7); +const mcu_pin_obj_t pin_GPIO_AD_08 = PIN(GPIO1, 22, GPIO_AD_08, ADC1, 8); +const mcu_pin_obj_t pin_GPIO_AD_09 = PIN(GPIO1, 23, GPIO_AD_09, ADC1, 9); +const mcu_pin_obj_t pin_GPIO_AD_10 = PIN(GPIO1, 24, GPIO_AD_10, ADC1, 10); +const mcu_pin_obj_t pin_GPIO_AD_11 = PIN(GPIO1, 25, GPIO_AD_11, ADC1, 11); +const mcu_pin_obj_t pin_GPIO_AD_12 = PIN(GPIO1, 26, GPIO_AD_12, ADC1, 12); +const mcu_pin_obj_t pin_GPIO_AD_13 = PIN(GPIO1, 27, GPIO_AD_13, ADC1, 13); +const mcu_pin_obj_t pin_GPIO_AD_14 = PIN(GPIO1, 28, GPIO_AD_14, ADC1, 14); + +const mcu_pin_obj_t pin_GPIO_SD_00 = PIN(GPIO2, 0, GPIO_SD_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_01 = PIN(GPIO2, 1, GPIO_SD_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_02 = PIN(GPIO2, 2, GPIO_SD_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_03 = PIN(GPIO2, 3, GPIO_SD_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_04 = PIN(GPIO2, 4, GPIO_SD_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_05 = PIN(GPIO2, 5, GPIO_SD_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_06 = PIN(GPIO2, 6, GPIO_SD_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_07 = PIN(GPIO2, 7, GPIO_SD_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_08 = PIN(GPIO2, 8, GPIO_SD_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_09 = PIN(GPIO2, 9, GPIO_SD_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_10 = PIN(GPIO2, 10, GPIO_SD_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_11 = PIN(GPIO2, 11, GPIO_SD_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_12 = PIN(GPIO2, 12, GPIO_SD_12, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_13 = PIN(GPIO2, 13, GPIO_SD_13, NO_ADC, 0); + diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.h new file mode 100644 index 0000000000..6b31d6d8ed --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.h @@ -0,0 +1,77 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PINS_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PINS_H + +extern const mcu_pin_obj_t pin_GPIO_00; +extern const mcu_pin_obj_t pin_GPIO_01; +extern const mcu_pin_obj_t pin_GPIO_02; +extern const mcu_pin_obj_t pin_GPIO_03; +extern const mcu_pin_obj_t pin_GPIO_04; +extern const mcu_pin_obj_t pin_GPIO_05; +extern const mcu_pin_obj_t pin_GPIO_06; +extern const mcu_pin_obj_t pin_GPIO_07; +extern const mcu_pin_obj_t pin_GPIO_08; +extern const mcu_pin_obj_t pin_GPIO_09; +extern const mcu_pin_obj_t pin_GPIO_10; +extern const mcu_pin_obj_t pin_GPIO_11; +extern const mcu_pin_obj_t pin_GPIO_12; +extern const mcu_pin_obj_t pin_GPIO_13; + +extern const mcu_pin_obj_t pin_GPIO_SD_00; +extern const mcu_pin_obj_t pin_GPIO_SD_01; +extern const mcu_pin_obj_t pin_GPIO_SD_02; +extern const mcu_pin_obj_t pin_GPIO_SD_03; +extern const mcu_pin_obj_t pin_GPIO_SD_04; +extern const mcu_pin_obj_t pin_GPIO_SD_05; +extern const mcu_pin_obj_t pin_GPIO_SD_06; +extern const mcu_pin_obj_t pin_GPIO_SD_07; +extern const mcu_pin_obj_t pin_GPIO_SD_08; +extern const mcu_pin_obj_t pin_GPIO_SD_09; +extern const mcu_pin_obj_t pin_GPIO_SD_10; +extern const mcu_pin_obj_t pin_GPIO_SD_11; +extern const mcu_pin_obj_t pin_GPIO_SD_12; +extern const mcu_pin_obj_t pin_GPIO_SD_13; +extern const mcu_pin_obj_t pin_GPIO_SD_14; + +extern const mcu_pin_obj_t pin_GPIO_AD_00; +extern const mcu_pin_obj_t pin_GPIO_AD_01; +extern const mcu_pin_obj_t pin_GPIO_AD_02; +extern const mcu_pin_obj_t pin_GPIO_AD_03; +extern const mcu_pin_obj_t pin_GPIO_AD_04; +extern const mcu_pin_obj_t pin_GPIO_AD_05; +extern const mcu_pin_obj_t pin_GPIO_AD_06; +extern const mcu_pin_obj_t pin_GPIO_AD_07; +extern const mcu_pin_obj_t pin_GPIO_AD_08; +extern const mcu_pin_obj_t pin_GPIO_AD_09; +extern const mcu_pin_obj_t pin_GPIO_AD_10; +extern const mcu_pin_obj_t pin_GPIO_AD_11; +extern const mcu_pin_obj_t pin_GPIO_AD_12; +extern const mcu_pin_obj_t pin_GPIO_AD_13; +extern const mcu_pin_obj_t pin_GPIO_AD_14; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PINS_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c new file mode 100644 index 0000000000..422834529d --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c @@ -0,0 +1,366 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "mpconfigport.h" + +#include "fsl_clock.h" +#include "fsl_iomuxc.h" + +#define BOARD_XTAL0_CLK_HZ 24000000U /*!< Board xtal0 frequency in Hz */ +#define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32k frequency in Hz */ +#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 600000000U /*!< Core clock frequency: 600000000Hz */ + +/*! @brief Usb1 PLL set for BOARD_BootClockRUN configuration. + */ +//extern const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN; +/*! @brief Sys PLL for BOARD_BootClockRUN configuration. + */ +//extern const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN; +/*! @brief Enet PLL set for BOARD_BootClockRUN configuration. + */ +//extern const clock_enet_pll_config_t enetPllConfig_BOARD_BootClockRUN; + +const clock_arm_pll_config_t armPllConfig_BOARD_BootClockRUN = + { + .loopDivider = 100, /* PLL loop divider, Fout = Fin * 50 */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ + }; +const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN = + { + .loopDivider = 1, /* PLL loop divider, Fout = Fin * ( 20 + loopDivider*2 + numerator / denominator ) */ + .numerator = 0, /* 30 bit numerator of fractional loop divider */ + .denominator = 1, /* 30 bit denominator of fractional loop divider */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ + }; +const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN = + { + .loopDivider = 0, /* PLL loop divider, Fout = Fin * 20 */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ + }; +void clocks_init(void) { + /* Init RTC OSC clock frequency. */ + CLOCK_SetRtcXtalFreq(32768U); + /* Enable 1MHz clock output. */ + XTALOSC24M->OSC_CONFIG2 |= XTALOSC24M_OSC_CONFIG2_ENABLE_1M_MASK; + /* Use free 1MHz clock output. */ + XTALOSC24M->OSC_CONFIG2 &= ~XTALOSC24M_OSC_CONFIG2_MUX_1M_MASK; + /* Set XTAL 24MHz clock frequency. */ + CLOCK_SetXtalFreq(24000000U); + /* Enable XTAL 24MHz clock source. */ + CLOCK_InitExternalClk(0); + /* Enable internal RC. */ + CLOCK_InitRcOsc24M(); + /* Switch clock source to external OSC. */ + CLOCK_SwitchOsc(kCLOCK_XtalOsc); + /* Set Oscillator ready counter value. */ + CCM->CCR = (CCM->CCR & (~CCM_CCR_OSCNT_MASK)) | CCM_CCR_OSCNT(127); + /* Setting PeriphClk2Mux and PeriphMux to provide stable clock before PLLs are initialed */ + CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 1); /* Set PERIPH_CLK2 MUX to OSC */ + CLOCK_SetMux(kCLOCK_PeriphMux, 1); /* Set PERIPH_CLK MUX to PERIPH_CLK2 */ + /* Setting the VDD_SOC to 1.275V. It is necessary to config AHB to 600Mhz. */ + DCDC->REG3 = (DCDC->REG3 & (~DCDC_REG3_TRG_MASK)) | DCDC_REG3_TRG(0x13); + /* Waiting for DCDC_STS_DC_OK bit is asserted */ + while (DCDC_REG0_STS_DC_OK_MASK != (DCDC_REG0_STS_DC_OK_MASK & DCDC->REG0)) + { + } + /* Set AHB_PODF. */ + CLOCK_SetDiv(kCLOCK_AhbDiv, 0); + /* Disable IPG clock gate. */ + CLOCK_DisableClock(kCLOCK_Adc1); + CLOCK_DisableClock(kCLOCK_Adc2); + CLOCK_DisableClock(kCLOCK_Xbar1); + CLOCK_DisableClock(kCLOCK_Xbar2); + /* Set IPG_PODF. */ + CLOCK_SetDiv(kCLOCK_IpgDiv, 3); + /* Set ARM_PODF. */ + CLOCK_SetDiv(kCLOCK_ArmDiv, 1); + /* Set PERIPH_CLK2_PODF. */ + CLOCK_SetDiv(kCLOCK_PeriphClk2Div, 0); + /* Disable PERCLK clock gate. */ + CLOCK_DisableClock(kCLOCK_Gpt1); + CLOCK_DisableClock(kCLOCK_Gpt1S); + CLOCK_DisableClock(kCLOCK_Gpt2); + CLOCK_DisableClock(kCLOCK_Gpt2S); + CLOCK_DisableClock(kCLOCK_Pit); + /* Set PERCLK_PODF. */ + CLOCK_SetDiv(kCLOCK_PerclkDiv, 1); + /* Disable USDHC1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Usdhc1); + /* Set USDHC1_PODF. */ + CLOCK_SetDiv(kCLOCK_Usdhc1Div, 1); + /* Set Usdhc1 clock source. */ + CLOCK_SetMux(kCLOCK_Usdhc1Mux, 0); + /* Disable USDHC2 clock gate. */ + CLOCK_DisableClock(kCLOCK_Usdhc2); + /* Set USDHC2_PODF. */ + CLOCK_SetDiv(kCLOCK_Usdhc2Div, 1); + /* Set Usdhc2 clock source. */ + CLOCK_SetMux(kCLOCK_Usdhc2Mux, 0); + /* In SDK projects, SDRAM (configured by SEMC) will be initialized in either debug script or dcd. + * With this macro SKIP_SYSCLK_INIT, system pll (selected to be SEMC source clock in SDK projects) will be left unchanged. + * Note: If another clock source is selected for SEMC, user may want to avoid changing that clock as well.*/ +#ifndef SKIP_SYSCLK_INIT + /* Disable Semc clock gate. */ + CLOCK_DisableClock(kCLOCK_Semc); + /* Set SEMC_PODF. */ + CLOCK_SetDiv(kCLOCK_SemcDiv, 7); + /* Set Semc alt clock source. */ + CLOCK_SetMux(kCLOCK_SemcAltMux, 0); + /* Set Semc clock source. */ + CLOCK_SetMux(kCLOCK_SemcMux, 0); +#endif + /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. + * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left unchanged. + * Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as well.*/ +#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) + /* Disable Flexspi clock gate. */ + CLOCK_DisableClock(kCLOCK_FlexSpi); + /* Set FLEXSPI_PODF. */ + CLOCK_SetDiv(kCLOCK_FlexspiDiv, 1); + /* Set Flexspi clock source. */ + CLOCK_SetMux(kCLOCK_FlexspiMux, 3); +#endif + /* Disable LPSPI clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpspi1); + CLOCK_DisableClock(kCLOCK_Lpspi2); + CLOCK_DisableClock(kCLOCK_Lpspi3); + CLOCK_DisableClock(kCLOCK_Lpspi4); + /* Set LPSPI_PODF. */ + CLOCK_SetDiv(kCLOCK_LpspiDiv, 4); + /* Set Lpspi clock source. */ + CLOCK_SetMux(kCLOCK_LpspiMux, 2); + /* Disable TRACE clock gate. */ + CLOCK_DisableClock(kCLOCK_Trace); + /* Set TRACE_PODF. */ + CLOCK_SetDiv(kCLOCK_TraceDiv, 2); + /* Set Trace clock source. */ + CLOCK_SetMux(kCLOCK_TraceMux, 2); + /* Disable SAI1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai1); + /* Set SAI1_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai1PreDiv, 3); + /* Set SAI1_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai1Div, 1); + /* Set Sai1 clock source. */ + CLOCK_SetMux(kCLOCK_Sai1Mux, 0); + /* Disable SAI2 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai2); + /* Set SAI2_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai2PreDiv, 3); + /* Set SAI2_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai2Div, 1); + /* Set Sai2 clock source. */ + CLOCK_SetMux(kCLOCK_Sai2Mux, 0); + /* Disable SAI3 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai3); + /* Set SAI3_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai3PreDiv, 3); + /* Set SAI3_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai3Div, 1); + /* Set Sai3 clock source. */ + CLOCK_SetMux(kCLOCK_Sai3Mux, 0); + /* Disable Lpi2c clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpi2c1); + CLOCK_DisableClock(kCLOCK_Lpi2c2); + CLOCK_DisableClock(kCLOCK_Lpi2c3); + /* Set LPI2C_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Lpi2cDiv, 0); + /* Set Lpi2c clock source. */ + CLOCK_SetMux(kCLOCK_Lpi2cMux, 0); + /* Disable CAN clock gate. */ + CLOCK_DisableClock(kCLOCK_Can1); + CLOCK_DisableClock(kCLOCK_Can2); + CLOCK_DisableClock(kCLOCK_Can3); + CLOCK_DisableClock(kCLOCK_Can1S); + CLOCK_DisableClock(kCLOCK_Can2S); + CLOCK_DisableClock(kCLOCK_Can3S); + /* Set CAN_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_CanDiv, 1); + /* Set Can clock source. */ + CLOCK_SetMux(kCLOCK_CanMux, 2); + /* Disable UART clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpuart1); + CLOCK_DisableClock(kCLOCK_Lpuart2); + CLOCK_DisableClock(kCLOCK_Lpuart3); + CLOCK_DisableClock(kCLOCK_Lpuart4); + CLOCK_DisableClock(kCLOCK_Lpuart5); + CLOCK_DisableClock(kCLOCK_Lpuart6); + CLOCK_DisableClock(kCLOCK_Lpuart7); + CLOCK_DisableClock(kCLOCK_Lpuart8); + /* Set UART_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_UartDiv, 0); + /* Set Uart clock source. */ + CLOCK_SetMux(kCLOCK_UartMux, 0); + /* Disable SPDIF clock gate. */ + CLOCK_DisableClock(kCLOCK_Spdif); + /* Set SPDIF0_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Spdif0PreDiv, 1); + /* Set SPDIF0_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Spdif0Div, 7); + /* Set Spdif clock source. */ + CLOCK_SetMux(kCLOCK_SpdifMux, 3); + /* Disable Flexio1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Flexio1); + /* Set FLEXIO1_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Flexio1PreDiv, 1); + /* Set FLEXIO1_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Flexio1Div, 7); + /* Set Flexio1 clock source. */ + CLOCK_SetMux(kCLOCK_Flexio1Mux, 3); + /* Disable Flexio2 clock gate. */ + CLOCK_DisableClock(kCLOCK_Flexio2); + /* Set FLEXIO2_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Flexio2PreDiv, 1); + /* Set FLEXIO2_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Flexio2Div, 7); + /* Set Flexio2 clock source. */ + CLOCK_SetMux(kCLOCK_Flexio2Mux, 3); + /* Set Pll3 sw clock source. */ + CLOCK_SetMux(kCLOCK_Pll3SwMux, 0); + /* Init ARM PLL. */ + CLOCK_InitArmPll(&armPllConfig_BOARD_BootClockRUN); + /* In SDK projects, SDRAM (configured by SEMC) will be initialized in either debug script or dcd. + * With this macro SKIP_SYSCLK_INIT, system pll (selected to be SEMC source clock in SDK projects) will be left unchanged. + * Note: If another clock source is selected for SEMC, user may want to avoid changing that clock as well.*/ +#ifndef SKIP_SYSCLK_INIT + /* Init System PLL. */ + CLOCK_InitSysPll(&sysPllConfig_BOARD_BootClockRUN); + /* Init System pfd0. */ + CLOCK_InitSysPfd(kCLOCK_Pfd0, 27); + /* Init System pfd1. */ + CLOCK_InitSysPfd(kCLOCK_Pfd1, 16); + /* Init System pfd2. */ + CLOCK_InitSysPfd(kCLOCK_Pfd2, 24); + /* Init System pfd3. */ + CLOCK_InitSysPfd(kCLOCK_Pfd3, 16); +#endif + /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. + * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left unchanged. + * Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as well.*/ +#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) + /* Init Usb1 PLL. */ + CLOCK_InitUsb1Pll(&usb1PllConfig_BOARD_BootClockRUN); + /* Init Usb1 pfd0. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 33); + /* Init Usb1 pfd1. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd1, 16); + /* Init Usb1 pfd2. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd2, 17); + /* Init Usb1 pfd3. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd3, 19); + /* Disable Usb1 PLL output for USBPHY1. */ + CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; +#endif + /* 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; + /* DeInit Video PLL. */ + CLOCK_DeinitVideoPll(); + /* Bypass Video PLL. */ + CCM_ANALOG->PLL_VIDEO |= CCM_ANALOG_PLL_VIDEO_BYPASS_MASK; + /* Set divider for Video PLL. */ + CCM_ANALOG->MISC2 = (CCM_ANALOG->MISC2 & (~CCM_ANALOG_MISC2_VIDEO_DIV_MASK)) | CCM_ANALOG_MISC2_VIDEO_DIV(0); + /* Enable Video PLL output. */ + CCM_ANALOG->PLL_VIDEO |= CCM_ANALOG_PLL_VIDEO_ENABLE_MASK; + /* DeInit Enet PLL. */ + CLOCK_DeinitEnetPll(); + /* Bypass Enet PLL. */ + CLOCK_SetPllBypass(CCM_ANALOG, kCLOCK_PllEnet, 1); + /* Set Enet output divider. */ + CCM_ANALOG->PLL_ENET = (CCM_ANALOG->PLL_ENET & (~CCM_ANALOG_PLL_ENET_DIV_SELECT_MASK)) | CCM_ANALOG_PLL_ENET_DIV_SELECT(1); + /* Enable Enet output. */ + CCM_ANALOG->PLL_ENET |= CCM_ANALOG_PLL_ENET_ENABLE_MASK; + /* Set Enet2 output divider. */ + CCM_ANALOG->PLL_ENET = (CCM_ANALOG->PLL_ENET & (~CCM_ANALOG_PLL_ENET_ENET2_DIV_SELECT_MASK)) | CCM_ANALOG_PLL_ENET_ENET2_DIV_SELECT(0); + /* Enable Enet2 output. */ + CCM_ANALOG->PLL_ENET |= CCM_ANALOG_PLL_ENET_ENET2_REF_EN_MASK; + /* Enable Enet25M output. */ + CCM_ANALOG->PLL_ENET |= CCM_ANALOG_PLL_ENET_ENET_25M_REF_EN_MASK; + /* DeInit Usb2 PLL. */ + CLOCK_DeinitUsb2Pll(); + /* Bypass Usb2 PLL. */ + CLOCK_SetPllBypass(CCM_ANALOG, kCLOCK_PllUsb2, 1); + /* Enable Usb2 PLL output. */ + CCM_ANALOG->PLL_USB2 |= CCM_ANALOG_PLL_USB2_ENABLE_MASK; + /* Set preperiph clock source. */ + CLOCK_SetMux(kCLOCK_PrePeriphMux, 3); + /* Set periph clock source. */ + CLOCK_SetMux(kCLOCK_PeriphMux, 0); + /* Set periph clock2 clock source. */ + CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 0); + /* Set per clock source. */ + CLOCK_SetMux(kCLOCK_PerclkMux, 0); + /* Set lvds1 clock source. */ + CCM_ANALOG->MISC1 = (CCM_ANALOG->MISC1 & (~CCM_ANALOG_MISC1_LVDS1_CLK_SEL_MASK)) | CCM_ANALOG_MISC1_LVDS1_CLK_SEL(0); + /* Set clock out1 divider. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO1_DIV_MASK)) | CCM_CCOSR_CLKO1_DIV(0); + /* Set clock out1 source. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO1_SEL_MASK)) | CCM_CCOSR_CLKO1_SEL(1); + /* Set clock out2 divider. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO2_DIV_MASK)) | CCM_CCOSR_CLKO2_DIV(0); + /* Set clock out2 source. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO2_SEL_MASK)) | CCM_CCOSR_CLKO2_SEL(18); + /* Set clock out1 drives clock out1. */ + CCM->CCOSR &= ~CCM_CCOSR_CLK_OUT_SEL_MASK; + /* Disable clock out1. */ + CCM->CCOSR &= ~CCM_CCOSR_CLKO1_EN_MASK; + /* Disable clock out2. */ + CCM->CCOSR &= ~CCM_CCOSR_CLKO2_EN_MASK; + /* Set SAI1 MCLK1 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk1Sel, 0); + /* Set SAI1 MCLK2 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk2Sel, 0); + /* Set SAI1 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk3Sel, 0); + /* Set SAI2 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI2MClk3Sel, 0); + /* Set SAI3 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI3MClk3Sel, 0); + /* Set MQS configuration. */ + IOMUXC_MQSConfig(IOMUXC_GPR,kIOMUXC_MqsPwmOverSampleRate32, 0); + /* Set ENET1 Tx clock source. */ + IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1RefClkMode, false); + /* Set ENET2 Tx clock source. */ +#if defined(FSL_IOMUXC_DRIVER_VERSION) && (FSL_IOMUXC_DRIVER_VERSION != (MAKE_VERSION(2, 0, 0))) + IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET2RefClkMode, false); +#else + IOMUXC_EnableMode(IOMUXC_GPR, IOMUXC_GPR_GPR1_ENET2_CLK_SEL_MASK, false); +#endif + /* Set GPT1 High frequency reference clock source. */ + IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT1_MASK; + /* Set GPT2 High frequency reference clock source. */ + IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT2_MASK; + /* Set SystemCoreClock variable. */ + SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK; + + CLOCK_EnableClock(kCLOCK_Iomuxc); +} diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c new file mode 100644 index 0000000000..fc90e2374d --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c @@ -0,0 +1,270 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 R 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/obj.h" +#include "py/mphal.h" +#include "mimxrt10xx/periph.h" + +LPI2C_Type *mcu_i2c_banks[] = { 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), + PERIPH_PIN(1, 3, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 1, &pin_GPIO_AD_B1_01), + + PERIPH_PIN(2, 3, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 0, &pin_GPIO_SD_B1_10), + PERIPH_PIN(2, 2, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 1, &pin_GPIO_B0_05), + + PERIPH_PIN(3, 2, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 0, &pin_GPIO_EMC_21), + PERIPH_PIN(3, 2, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 1, &pin_GPIO_SD_B0_01), + PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 2, &pin_GPIO_AD_B1_06), + + PERIPH_PIN(4, 2, kIOMUXC_LPI2C4_SDA_SELECT_INPUT, 0, &pin_GPIO_EMC_11), + PERIPH_PIN(4, 0, kIOMUXC_LPI2C4_SDA_SELECT_INPUT, 1, &pin_GPIO_AD_B0_13), +}; + +const mcu_periph_obj_t mcu_i2c_scl_list[9] = { + PERIPH_PIN(1, 2, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 0, &pin_GPIO_SD_B1_04), + PERIPH_PIN(1, 3, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 1, &pin_GPIO_AD_B1_00), + + PERIPH_PIN(2, 3, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 0, &pin_GPIO_SD_B1_11), + PERIPH_PIN(2, 2, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 1, &pin_GPIO_B0_04), + + PERIPH_PIN(3, 2, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 0, &pin_GPIO_EMC_22), + PERIPH_PIN(3, 2, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 1, &pin_GPIO_SD_B0_00), + PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 2, &pin_GPIO_AD_B1_07), + + PERIPH_PIN(4, 2, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 0, &pin_GPIO_EMC_12), + PERIPH_PIN(4, 0, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 1, &pin_GPIO_AD_B0_12), +}; + +LPSPI_Type *mcu_spi_banks[] = { 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), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 1, &pin_GPIO_SD_B0_00), + + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 0, &pin_GPIO_SD_B1_07), + PERIPH_PIN(2, 2, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 1, &pin_GPIO_EMC_00), + + PERIPH_PIN(3, 7, kIOMUXC_LPSPI3_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B0_00), + PERIPH_PIN(3, 2, kIOMUXC_LPSPI3_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B1_15), + + PERIPH_PIN(4, 3, kIOMUXC_LPSPI4_SCK_SELECT_INPUT, 0, &pin_GPIO_B0_03), + PERIPH_PIN(4, 1, kIOMUXC_LPSPI4_SCK_SELECT_INPUT, 1, &pin_GPIO_B1_07), +}; + +const mcu_periph_obj_t mcu_spi_mosi_list[8] = { + PERIPH_PIN(1, 3, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 0, &pin_GPIO_EMC_28), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 1, &pin_GPIO_SD_B0_02), + + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_SD_B1_08), + PERIPH_PIN(2, 2, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_EMC_02), + + PERIPH_PIN(3, 7, kIOMUXC_LPSPI3_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B0_01), + PERIPH_PIN(3, 2, kIOMUXC_LPSPI3_SDO_SELECT_INPUT, 1, &pin_GPIO_AD_B1_14), + + PERIPH_PIN(4, 3, kIOMUXC_LPSPI4_SDO_SELECT_INPUT, 0, &pin_GPIO_B0_02), + PERIPH_PIN(4, 1, kIOMUXC_LPSPI4_SDO_SELECT_INPUT, 1, &pin_GPIO_B1_06), +}; + +const mcu_periph_obj_t mcu_spi_miso_list[8] = { + PERIPH_PIN(1, 3, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 0, &pin_GPIO_EMC_29), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 1, &pin_GPIO_SD_B0_03), + + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_SD_B1_09), + PERIPH_PIN(2, 2, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_03), + + PERIPH_PIN(3, 7, kIOMUXC_LPSPI3_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B0_02), + PERIPH_PIN(3, 2, kIOMUXC_LPSPI3_SDI_SELECT_INPUT, 1, &pin_GPIO_AD_B1_13), + + PERIPH_PIN(4, 3, kIOMUXC_LPSPI4_SDI_SELECT_INPUT, 0, &pin_GPIO_B0_01), + PERIPH_PIN(4, 1, kIOMUXC_LPSPI4_SDI_SELECT_INPUT, 1, &pin_GPIO_B1_05), +}; + +LPUART_Type *mcu_uart_banks[] = { 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), + + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_10), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_03), + + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_RX_SELECT_INPUT, 0, &pin_GPIO_AD_B1_07), + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_14), + PERIPH_PIN(3, 3, kIOMUXC_LPUART3_RX_SELECT_INPUT, 2, &pin_GPIO_B0_09), + + PERIPH_PIN(4, 4, kIOMUXC_LPUART4_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_01), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_20), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 2, &pin_GPIO_B1_01), + + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_24), + PERIPH_PIN(5, 1, kIOMUXC_LPUART5_RX_SELECT_INPUT, 1, &pin_GPIO_B1_13), + + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_26), + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_03), + + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_32), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_09), + + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B0_05), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_11), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 2, &pin_GPIO_EMC_39), +}; + +const mcu_periph_obj_t mcu_uart_tx_list[18] = { + PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_12), + + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_11), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_02), + + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_TX_SELECT_INPUT, 0, &pin_GPIO_AD_B1_06), + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_13), + PERIPH_PIN(3, 3, kIOMUXC_LPUART3_TX_SELECT_INPUT, 2, &pin_GPIO_B0_08), + + PERIPH_PIN(4, 4, kIOMUXC_LPUART4_TX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_00), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_19), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 2, &pin_GPIO_B1_00), + + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_23), + PERIPH_PIN(5, 1, kIOMUXC_LPUART5_TX_SELECT_INPUT, 1, &pin_GPIO_B1_12), + + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_25), + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_02), + + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_08), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_31), + + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 0, &pin_GPIO_SD_B0_04), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_10), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 2, &pin_GPIO_EMC_38), +}; + +const mcu_pwm_obj_t mcu_pwm_list[67] = { + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_EMC_23), + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_SD_B0_00), + + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_EMC_24), + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_SD_B0_01), + + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmX, 4, &pin_GPIO_AD_B0_02), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_EMC_25), + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_SD_B0_02), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_EMC_26), + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_SD_B0_03), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmX, 4, &pin_GPIO_AD_B0_03), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_EMC_27), + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_SD_B0_04), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_EMC_28), + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_SD_B0_05), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmX, 4, &pin_GPIO_AD_B0_12), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_AD_B0_10), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_EMC_38), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 2, &pin_GPIO_SD_B1_00), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 4, &pin_GPIO_EMC_12), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 6, &pin_GPIO_B1_00), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 1, &pin_GPIO_AD_B0_11), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 1, &pin_GPIO_EMC_39), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 2, &pin_GPIO_SD_B1_01), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 4, &pin_GPIO_EMC_13), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 6, &pin_GPIO_B1_01), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmX, 4, &pin_GPIO_AD_B0_13), + + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_EMC_06), + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmA, 2, &pin_GPIO_B0_06), + + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_EMC_07), + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmB, 2, &pin_GPIO_B0_07), + + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_EMC_08), + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmA, 2, &pin_GPIO_B0_08), + + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_EMC_09), + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmB, 2, &pin_GPIO_B0_09), + + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_EMC_10), + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmA, 2, &pin_GPIO_B0_10), + + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_EMC_11), + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmB, 2, &pin_GPIO_B0_11), + + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmA, 0, &pin_GPIO_AD_B0_00), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_AD_B0_09), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_EMC_19), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmA, 2, &pin_GPIO_SD_B1_02), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmA, 6, &pin_GPIO_B1_02), + + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmB, 0, &pin_GPIO_AD_B0_01), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmB, 1, &pin_GPIO_EMC_20), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmB, 2, &pin_GPIO_SD_B1_03), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmB, 6, &pin_GPIO_B1_03), + + PWM_PIN(PWM3, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_EMC_29), + + PWM_PIN(PWM3, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_EMC_30), + + PWM_PIN(PWM3, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_EMC_31), + + PWM_PIN(PWM3, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_EMC_32), + + PWM_PIN(PWM3, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_EMC_33), + + PWM_PIN(PWM3, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_EMC_34), + + PWM_PIN(PWM3, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_EMC_21), + + PWM_PIN(PWM3, kPWM_Module_3, kPWM_PwmB, 1, &pin_GPIO_EMC_22), + + PWM_PIN(PWM4, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_AD_B1_08), + PWM_PIN(PWM4, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_EMC_00), + + PWM_PIN(PWM4, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_EMC_01), + + PWM_PIN(PWM4, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_AD_B1_09), + PWM_PIN(PWM4, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_EMC_02), + + PWM_PIN(PWM4, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_EMC_03), + + PWM_PIN(PWM4, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_B1_14), + PWM_PIN(PWM4, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_EMC_04), + + PWM_PIN(PWM4, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_EMC_05), + + PWM_PIN(PWM4, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_B1_15), + PWM_PIN(PWM4, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_EMC_17), + + PWM_PIN(PWM4, kPWM_Module_3, kPWM_PwmB, 1, &pin_GPIO_EMC_18), + +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h new file mode 100644 index 0000000000..b069ca76bb --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h @@ -0,0 +1,42 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H + +extern const mcu_periph_obj_t mcu_i2c_sda_list[9]; +extern const mcu_periph_obj_t mcu_i2c_scl_list[9]; + +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 const mcu_periph_obj_t mcu_uart_rx_list[18]; +extern const mcu_periph_obj_t mcu_uart_tx_list[18]; + +extern const mcu_pwm_obj_t mcu_pwm_list[67]; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c new file mode 100644 index 0000000000..c622e759ae --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c @@ -0,0 +1,161 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "py/obj.h" +#include "py/mphal.h" +#include "mimxrt10xx/pins.h" + +const mcu_pin_obj_t pin_GPIO_EMC_00 = PIN(GPIO4, 0, GPIO_EMC_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_01 = PIN(GPIO4, 1, GPIO_EMC_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_02 = PIN(GPIO4, 2, GPIO_EMC_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_03 = PIN(GPIO4, 3, GPIO_EMC_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_04 = PIN(GPIO4, 4, GPIO_EMC_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_05 = PIN(GPIO4, 5, GPIO_EMC_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_06 = PIN(GPIO4, 6, GPIO_EMC_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_07 = PIN(GPIO4, 7, GPIO_EMC_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_08 = PIN(GPIO4, 8, GPIO_EMC_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_09 = PIN(GPIO4, 9, GPIO_EMC_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_10 = PIN(GPIO4, 10, GPIO_EMC_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_11 = PIN(GPIO4, 11, GPIO_EMC_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_12 = PIN(GPIO4, 12, GPIO_EMC_12, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_13 = PIN(GPIO4, 13, GPIO_EMC_13, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_14 = PIN(GPIO4, 14, GPIO_EMC_14, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_15 = PIN(GPIO4, 15, GPIO_EMC_15, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_16 = PIN(GPIO4, 16, GPIO_EMC_16, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_17 = PIN(GPIO4, 17, GPIO_EMC_17, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_18 = PIN(GPIO4, 18, GPIO_EMC_18, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_19 = PIN(GPIO4, 19, GPIO_EMC_19, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_20 = PIN(GPIO4, 20, GPIO_EMC_20, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_21 = PIN(GPIO4, 21, GPIO_EMC_21, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_22 = PIN(GPIO4, 22, GPIO_EMC_22, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_23 = PIN(GPIO4, 23, GPIO_EMC_23, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_24 = PIN(GPIO4, 24, GPIO_EMC_24, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_25 = PIN(GPIO4, 25, GPIO_EMC_25, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_26 = PIN(GPIO4, 26, GPIO_EMC_26, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_27 = PIN(GPIO4, 27, GPIO_EMC_27, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_28 = PIN(GPIO4, 28, GPIO_EMC_28, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_29 = PIN(GPIO4, 29, GPIO_EMC_29, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_30 = PIN(GPIO4, 30, GPIO_EMC_30, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_31 = PIN(GPIO4, 31, GPIO_EMC_31, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_32 = PIN(GPIO3, 18, GPIO_EMC_32, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_33 = PIN(GPIO3, 19, GPIO_EMC_33, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_34 = PIN(GPIO3, 20, GPIO_EMC_34, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_35 = PIN(GPIO3, 21, GPIO_EMC_35, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_36 = PIN(GPIO3, 22, GPIO_EMC_36, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_37 = PIN(GPIO3, 23, GPIO_EMC_37, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_38 = PIN(GPIO3, 24, GPIO_EMC_38, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_39 = PIN(GPIO3, 25, GPIO_EMC_39, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_40 = PIN(GPIO3, 26, GPIO_EMC_40, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_41 = PIN(GPIO3, 27, GPIO_EMC_41, NO_ADC, 0); + +const mcu_pin_obj_t pin_GPIO_AD_B0_00 = PIN(GPIO1, 0, GPIO_AD_B0_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_01 = PIN(GPIO1, 1, GPIO_AD_B0_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_02 = PIN(GPIO1, 2, GPIO_AD_B0_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_03 = PIN(GPIO1, 3, GPIO_AD_B0_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_04 = PIN(GPIO1, 4, GPIO_AD_B0_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_05 = PIN(GPIO1, 5, GPIO_AD_B0_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_06 = PIN(GPIO1, 6, GPIO_AD_B0_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_07 = PIN(GPIO1, 7, GPIO_AD_B0_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_08 = PIN(GPIO1, 8, GPIO_AD_B0_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_09 = PIN(GPIO1, 9, GPIO_AD_B0_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_10 = PIN(GPIO1, 10, GPIO_AD_B0_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_11 = PIN(GPIO1, 11, GPIO_AD_B0_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_12 = PIN(GPIO1, 12, GPIO_AD_B0_12, ADC1, 1); +const mcu_pin_obj_t pin_GPIO_AD_B0_13 = PIN(GPIO1, 13, GPIO_AD_B0_13, ADC1, 2); +const mcu_pin_obj_t pin_GPIO_AD_B0_14 = PIN(GPIO1, 14, GPIO_AD_B0_14, ADC1, 3); +const mcu_pin_obj_t pin_GPIO_AD_B0_15 = PIN(GPIO1, 15, GPIO_AD_B0_15, ADC1, 4); + +const mcu_pin_obj_t pin_GPIO_AD_B1_00 = PIN(GPIO1, 16, GPIO_AD_B1_00, ADC1, 5); +const mcu_pin_obj_t pin_GPIO_AD_B1_01 = PIN(GPIO1, 17, GPIO_AD_B1_01, ADC1, 6); +const mcu_pin_obj_t pin_GPIO_AD_B1_02 = PIN(GPIO1, 18, GPIO_AD_B1_02, ADC1, 7); +const mcu_pin_obj_t pin_GPIO_AD_B1_03 = PIN(GPIO1, 19, GPIO_AD_B1_03, ADC1, 8); +const mcu_pin_obj_t pin_GPIO_AD_B1_04 = PIN(GPIO1, 20, GPIO_AD_B1_04, ADC1, 9); +const mcu_pin_obj_t pin_GPIO_AD_B1_05 = PIN(GPIO1, 21, GPIO_AD_B1_05, ADC1, 10); +const mcu_pin_obj_t pin_GPIO_AD_B1_06 = PIN(GPIO1, 22, GPIO_AD_B1_06, ADC1, 11); +const mcu_pin_obj_t pin_GPIO_AD_B1_07 = PIN(GPIO1, 23, GPIO_AD_B1_07, ADC1, 12); +const mcu_pin_obj_t pin_GPIO_AD_B1_08 = PIN(GPIO1, 24, GPIO_AD_B1_08, ADC1, 13); +const mcu_pin_obj_t pin_GPIO_AD_B1_09 = PIN(GPIO1, 25, GPIO_AD_B1_09, ADC1, 14); +const mcu_pin_obj_t pin_GPIO_AD_B1_10 = PIN(GPIO1, 26, GPIO_AD_B1_10, ADC1, 15); +const mcu_pin_obj_t pin_GPIO_AD_B1_11 = PIN(GPIO1, 27, GPIO_AD_B1_11, ADC1, 0); +const mcu_pin_obj_t pin_GPIO_AD_B1_12 = PIN(GPIO1, 28, GPIO_AD_B1_12, ADC2, 1); +const mcu_pin_obj_t pin_GPIO_AD_B1_13 = PIN(GPIO1, 29, GPIO_AD_B1_13, ADC2, 2); +const mcu_pin_obj_t pin_GPIO_AD_B1_14 = PIN(GPIO1, 30, GPIO_AD_B1_14, ADC2, 3); +const mcu_pin_obj_t pin_GPIO_AD_B1_15 = PIN(GPIO1, 31, GPIO_AD_B1_15, ADC2, 4); + +const mcu_pin_obj_t pin_GPIO_B0_00 = PIN(GPIO2, 0, GPIO_B0_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_01 = PIN(GPIO2, 1, GPIO_B0_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_02 = PIN(GPIO2, 2, GPIO_B0_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_03 = PIN(GPIO2, 3, GPIO_B0_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_04 = PIN(GPIO2, 4, GPIO_B0_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_05 = PIN(GPIO2, 5, GPIO_B0_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_06 = PIN(GPIO2, 6, GPIO_B0_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_07 = PIN(GPIO2, 7, GPIO_B0_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_08 = PIN(GPIO2, 8, GPIO_B0_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_09 = PIN(GPIO2, 9, GPIO_B0_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_10 = PIN(GPIO2, 10, GPIO_B0_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_11 = PIN(GPIO2, 11, GPIO_B0_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_12 = PIN(GPIO2, 12, GPIO_B0_12, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_13 = PIN(GPIO2, 13, GPIO_B0_13, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_14 = PIN(GPIO2, 14, GPIO_B0_14, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B0_15 = PIN(GPIO2, 15, GPIO_B0_15, NO_ADC, 0); + +const mcu_pin_obj_t pin_GPIO_B1_00 = PIN(GPIO2, 16, GPIO_B1_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_01 = PIN(GPIO2, 17, GPIO_B1_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_02 = PIN(GPIO2, 18, GPIO_B1_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_03 = PIN(GPIO2, 19, GPIO_B1_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_04 = PIN(GPIO2, 20, GPIO_B1_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_05 = PIN(GPIO2, 21, GPIO_B1_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_06 = PIN(GPIO2, 22, GPIO_B1_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_07 = PIN(GPIO2, 23, GPIO_B1_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_08 = PIN(GPIO2, 24, GPIO_B1_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_09 = PIN(GPIO2, 25, GPIO_B1_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_10 = PIN(GPIO2, 26, GPIO_B1_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_11 = PIN(GPIO2, 27, GPIO_B1_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_12 = PIN(GPIO2, 28, GPIO_B1_12, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_13 = PIN(GPIO2, 29, GPIO_B1_13, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_14 = PIN(GPIO2, 30, GPIO_B1_14, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_B1_15 = PIN(GPIO2, 31, GPIO_B1_15, NO_ADC, 0); + +const mcu_pin_obj_t pin_GPIO_SD_B0_00 = PIN(GPIO3, 12, GPIO_SD_B0_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_01 = PIN(GPIO3, 13, GPIO_SD_B0_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_02 = PIN(GPIO3, 14, GPIO_SD_B0_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_03 = PIN(GPIO3, 15, GPIO_SD_B0_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_04 = PIN(GPIO3, 16, GPIO_SD_B0_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_05 = PIN(GPIO3, 17, GPIO_SD_B0_05, NO_ADC, 0); + +const mcu_pin_obj_t pin_GPIO_SD_B1_00 = PIN(GPIO3, 0, GPIO_B1_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_01 = PIN(GPIO3, 1, GPIO_B1_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_02 = PIN(GPIO3, 2, GPIO_B1_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_03 = PIN(GPIO3, 3, GPIO_B1_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_04 = PIN(GPIO3, 4, GPIO_B1_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_05 = PIN(GPIO3, 5, GPIO_B1_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_06 = PIN(GPIO3, 6, GPIO_B1_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_07 = PIN(GPIO3, 7, GPIO_B1_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_08 = PIN(GPIO3, 8, GPIO_B1_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_09 = PIN(GPIO3, 9, GPIO_B1_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_10 = PIN(GPIO3, 10, GPIO_B1_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_11 = PIN(GPIO3, 11, GPIO_B1_11, NO_ADC, 0); diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h new file mode 100644 index 0000000000..1e69224595 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h @@ -0,0 +1,161 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1062_PINS_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1062_PINS_H + +extern const mcu_pin_obj_t pin_GPIO_EMC_00; +extern const mcu_pin_obj_t pin_GPIO_EMC_01; +extern const mcu_pin_obj_t pin_GPIO_EMC_02; +extern const mcu_pin_obj_t pin_GPIO_EMC_03; +extern const mcu_pin_obj_t pin_GPIO_EMC_04; +extern const mcu_pin_obj_t pin_GPIO_EMC_05; +extern const mcu_pin_obj_t pin_GPIO_EMC_06; +extern const mcu_pin_obj_t pin_GPIO_EMC_07; +extern const mcu_pin_obj_t pin_GPIO_EMC_08; +extern const mcu_pin_obj_t pin_GPIO_EMC_09; +extern const mcu_pin_obj_t pin_GPIO_EMC_10; +extern const mcu_pin_obj_t pin_GPIO_EMC_11; +extern const mcu_pin_obj_t pin_GPIO_EMC_12; +extern const mcu_pin_obj_t pin_GPIO_EMC_13; +extern const mcu_pin_obj_t pin_GPIO_EMC_14; +extern const mcu_pin_obj_t pin_GPIO_EMC_15; +extern const mcu_pin_obj_t pin_GPIO_EMC_16; +extern const mcu_pin_obj_t pin_GPIO_EMC_17; +extern const mcu_pin_obj_t pin_GPIO_EMC_18; +extern const mcu_pin_obj_t pin_GPIO_EMC_19; +extern const mcu_pin_obj_t pin_GPIO_EMC_20; +extern const mcu_pin_obj_t pin_GPIO_EMC_21; +extern const mcu_pin_obj_t pin_GPIO_EMC_22; +extern const mcu_pin_obj_t pin_GPIO_EMC_23; +extern const mcu_pin_obj_t pin_GPIO_EMC_24; +extern const mcu_pin_obj_t pin_GPIO_EMC_25; +extern const mcu_pin_obj_t pin_GPIO_EMC_26; +extern const mcu_pin_obj_t pin_GPIO_EMC_27; +extern const mcu_pin_obj_t pin_GPIO_EMC_28; +extern const mcu_pin_obj_t pin_GPIO_EMC_29; +extern const mcu_pin_obj_t pin_GPIO_EMC_30; +extern const mcu_pin_obj_t pin_GPIO_EMC_31; +extern const mcu_pin_obj_t pin_GPIO_EMC_32; +extern const mcu_pin_obj_t pin_GPIO_EMC_33; +extern const mcu_pin_obj_t pin_GPIO_EMC_34; +extern const mcu_pin_obj_t pin_GPIO_EMC_35; +extern const mcu_pin_obj_t pin_GPIO_EMC_36; +extern const mcu_pin_obj_t pin_GPIO_EMC_37; +extern const mcu_pin_obj_t pin_GPIO_EMC_38; +extern const mcu_pin_obj_t pin_GPIO_EMC_39; +extern const mcu_pin_obj_t pin_GPIO_EMC_40; +extern const mcu_pin_obj_t pin_GPIO_EMC_41; + +extern const mcu_pin_obj_t pin_GPIO_AD_B0_00; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_01; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_02; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_03; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_04; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_05; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_06; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_07; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_08; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_09; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_10; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_11; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_12; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_13; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_14; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_15; + +extern const mcu_pin_obj_t pin_GPIO_AD_B1_00; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_01; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_02; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_03; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_04; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_05; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_06; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_07; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_08; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_09; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_10; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_11; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_12; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_13; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_14; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_15; + +extern const mcu_pin_obj_t pin_GPIO_B0_00; +extern const mcu_pin_obj_t pin_GPIO_B0_01; +extern const mcu_pin_obj_t pin_GPIO_B0_02; +extern const mcu_pin_obj_t pin_GPIO_B0_03; +extern const mcu_pin_obj_t pin_GPIO_B0_04; +extern const mcu_pin_obj_t pin_GPIO_B0_05; +extern const mcu_pin_obj_t pin_GPIO_B0_06; +extern const mcu_pin_obj_t pin_GPIO_B0_07; +extern const mcu_pin_obj_t pin_GPIO_B0_08; +extern const mcu_pin_obj_t pin_GPIO_B0_09; +extern const mcu_pin_obj_t pin_GPIO_B0_10; +extern const mcu_pin_obj_t pin_GPIO_B0_11; +extern const mcu_pin_obj_t pin_GPIO_B0_12; +extern const mcu_pin_obj_t pin_GPIO_B0_13; +extern const mcu_pin_obj_t pin_GPIO_B0_14; +extern const mcu_pin_obj_t pin_GPIO_B0_15; + +extern const mcu_pin_obj_t pin_GPIO_B1_00; +extern const mcu_pin_obj_t pin_GPIO_B1_01; +extern const mcu_pin_obj_t pin_GPIO_B1_02; +extern const mcu_pin_obj_t pin_GPIO_B1_03; +extern const mcu_pin_obj_t pin_GPIO_B1_04; +extern const mcu_pin_obj_t pin_GPIO_B1_05; +extern const mcu_pin_obj_t pin_GPIO_B1_06; +extern const mcu_pin_obj_t pin_GPIO_B1_07; +extern const mcu_pin_obj_t pin_GPIO_B1_08; +extern const mcu_pin_obj_t pin_GPIO_B1_09; +extern const mcu_pin_obj_t pin_GPIO_B1_10; +extern const mcu_pin_obj_t pin_GPIO_B1_11; +extern const mcu_pin_obj_t pin_GPIO_B1_12; +extern const mcu_pin_obj_t pin_GPIO_B1_13; +extern const mcu_pin_obj_t pin_GPIO_B1_14; +extern const mcu_pin_obj_t pin_GPIO_B1_15; + +extern const mcu_pin_obj_t pin_GPIO_SD_B0_00; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_01; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_02; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_03; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_04; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_05; + +extern const mcu_pin_obj_t pin_GPIO_SD_B1_00; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_01; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_02; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_03; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_04; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_05; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_06; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_07; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_08; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_09; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_10; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_11; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1062_PINS_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/clocks.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/clocks.h new file mode 100644 index 0000000000..ccbba2edd4 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/clocks.h @@ -0,0 +1,29 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +extern uint32_t SystemCoreClock; + +void clocks_init(void); diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h new file mode 100644 index 0000000000..301eb0db47 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h @@ -0,0 +1,77 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_PERIPH_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_PERIPH_H + +#include "pins.h" + +typedef struct { + uint8_t bank_idx:4; + uint8_t mux_mode:4; + uint32_t input_reg; + uint8_t input_idx; + const mcu_pin_obj_t *pin; +} mcu_periph_obj_t; + +#define PERIPH_PIN(p_bank_idx, p_mux_mode, p_input_reg, p_input_idx, p_pin) \ +{ \ + .bank_idx = p_bank_idx, \ + .mux_mode = p_mux_mode, \ + .input_reg = p_input_reg == 0 ? 0 : (uint32_t)&(IOMUXC->SELECT_INPUT[p_input_reg]), \ + .input_idx = p_input_idx, \ + .pin = p_pin, \ +} + +typedef struct { + PWM_Type *pwm; + pwm_submodule_t submodule:4; + pwm_channels_t channel:4; + uint8_t mux_mode; + const mcu_pin_obj_t *pin; +} mcu_pwm_obj_t; + +#define PWM_PIN(p_pwm, p_submodule, p_channel, p_mux_mode, p_pin) \ +{ \ + .pwm = p_pwm, \ + .submodule = p_submodule, \ + .channel = p_channel, \ + .mux_mode = p_mux_mode, \ + .pin = p_pin, \ +} + +extern LPI2C_Type *mcu_i2c_banks[]; +extern LPSPI_Type *mcu_spi_banks[]; +extern LPUART_Type *mcu_uart_banks[]; + +#ifdef MIMXRT1011_SERIES +#include "MIMXRT1011/periph.h" +#elif defined(MIMXRT1062_SERIES) +#include "MIMXRT1062/periph.h" +#endif + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_PERIPH_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h new file mode 100644 index 0000000000..64a8324bd0 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h @@ -0,0 +1,75 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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. + */ + +// DO NOT include this file directly. Use shared-bindings/microcontroller/Pin.h instead to ensure +// that all necessary includes are already included. + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_PINS_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_PINS_H + +#include +#include + +#include "fsl_iomuxc.h" +#include "fsl_pwm.h" +#include "py/obj.h" + +extern const mp_obj_type_t mcu_pin_type; + +// Use illegal pin value to mark unassigned pins. +#define NO_PIN 0xff +#define NO_ADC NULL +#define NO_PWM NULL + +typedef struct { + mp_obj_base_t base; + GPIO_Type *gpio; + uint8_t number; + uint32_t mux_reg; + uint32_t cfg_reg; + ADC_Type *adc; + uint8_t adc_channel; +} mcu_pin_obj_t; + +#define PIN(p_gpio, p_number, p_enum, p_adc, p_adc_channel) \ +{ \ + { &mcu_pin_type }, \ + .gpio = p_gpio, \ + .number = p_number, \ + .mux_reg = (uint32_t)&(IOMUXC->SW_MUX_CTL_PAD[kIOMUXC_SW_MUX_CTL_PAD_ ## p_enum]), \ + .cfg_reg = (uint32_t)&(IOMUXC->SW_PAD_CTL_PAD[kIOMUXC_SW_PAD_CTL_PAD_ ## p_enum]), \ + .adc = p_adc, \ + .adc_channel = p_adc_channel, \ +} + +#ifdef MIMXRT1011_SERIES +#include "MIMXRT1011/pins.h" +#elif defined(MIMXRT1062_SERIES) +#include "MIMXRT1062/pins.h" +#endif + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_PINS_H diff --git a/ports/mimxrt10xx/qstrdefsport.h b/ports/mimxrt10xx/qstrdefsport.h new file mode 100644 index 0000000000..3ba897069b --- /dev/null +++ b/ports/mimxrt10xx/qstrdefsport.h @@ -0,0 +1 @@ +// qstrs specific to this port diff --git a/ports/mimxrt10xx/reset.c b/ports/mimxrt10xx/reset.c new file mode 100644 index 0000000000..dc4a1dce11 --- /dev/null +++ b/ports/mimxrt10xx/reset.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "reset.h" +#include "supervisor/filesystem.h" + +#include "fsl_common.h" + +void reset(void) { + filesystem_flush(); + NVIC_SystemReset(); +} + +bool bootloader_available(void) { + return &_bootloader_dbl_tap >= 0; +} diff --git a/ports/mimxrt10xx/reset.h b/ports/mimxrt10xx/reset.h new file mode 100644 index 0000000000..b6dfc38cc2 --- /dev/null +++ b/ports/mimxrt10xx/reset.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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. + */ +#ifndef MICROPY_INCLUDED_MIMXRT10XX_RESET_H +#define MICROPY_INCLUDED_MIMXRT10XX_RESET_H + +#include +#include + +// Copied from inc/uf2.h in https://github.com/Microsoft/uf2-samd21 +#define DBL_TAP_MAGIC 0xf01669ef // Randomly selected, adjusted to have first and last bit set +#define DBL_TAP_MAGIC_QUICK_BOOT 0xf02669ef + +extern volatile uint32_t _bootloader_dbl_tap; + +void reset_to_bootloader(void); +void reset(void); +bool bootloader_available(void); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_RESET_H diff --git a/ports/mimxrt10xx/sdk b/ports/mimxrt10xx/sdk new file mode 160000 index 0000000000..2251c7b793 --- /dev/null +++ b/ports/mimxrt10xx/sdk @@ -0,0 +1 @@ +Subproject commit 2251c7b79343966a57a0f36d897873dd40b692b9 diff --git a/ports/mimxrt10xx/supervisor/cpu.S b/ports/mimxrt10xx/supervisor/cpu.S new file mode 100755 index 0000000000..9e6807a5e2 --- /dev/null +++ b/ports/mimxrt10xx/supervisor/cpu.S @@ -0,0 +1,27 @@ +.syntax unified +.cpu cortex-m4 +.thumb +.text +.align 2 + +@ uint cpu_get_regs_and_sp(r0=uint regs[10]) +.global cpu_get_regs_and_sp +.thumb +.thumb_func +.type cpu_get_regs_and_sp, %function +cpu_get_regs_and_sp: +@ store registers into given array +str r4, [r0], #4 +str r5, [r0], #4 +str r6, [r0], #4 +str r7, [r0], #4 +str r8, [r0], #4 +str r9, [r0], #4 +str r10, [r0], #4 +str r11, [r0], #4 +str r12, [r0], #4 +str r13, [r0], #4 + +@ return the sp +mov r0, sp +bx lr diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c new file mode 100644 index 0000000000..e20c67fa34 --- /dev/null +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2019 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi.h" +#include "internal_flash.h" + +#define FLASH_QUAD_ENABLE 0x02 +#define FLASH_BUSY_STATUS_POL 1 +#define FLASH_BUSY_STATUS_OFFSET 0 + +static inline void flexspi_clock_init(void) +{ +#if defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1) + /* Switch to PLL2 for XIP to avoid hardfault during re-initialize clock. */ + CLOCK_InitSysPfd(kCLOCK_Pfd2, 24); /* Set PLL2 PFD2 clock 396MHZ. */ + CLOCK_SetMux(kCLOCK_FlexspiMux, 0x2); /* Choose PLL2 PFD2 clock as flexspi source clock. */ + CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2); /* flexspi clock 133M. */ +#else + const clock_usb_pll_config_t g_ccmConfigUsbPll = {.loopDivider = 0U}; + + CLOCK_InitUsb1Pll(&g_ccmConfigUsbPll); + CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 24); /* Set PLL3 PFD0 clock 360MHZ. */ + CLOCK_SetMux(kCLOCK_FlexspiMux, 0x3); /* Choose PLL3 PFD0 clock as flexspi source clock. */ + CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2); /* flexspi clock 120M. */ +#endif +} + +extern flexspi_device_config_t deviceconfig; +extern const uint32_t customLUT[CUSTOM_LUT_LENGTH]; + +status_t flexspi_nor_write_enable(FLEXSPI_Type *base, uint32_t baseAddr) +{ + flexspi_transfer_t flashXfer; + status_t status; + + /* Write enable */ + flashXfer.deviceAddress = baseAddr; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Command; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_WRITEENABLE; + + status = FLEXSPI_TransferBlocking(base, &flashXfer); + + return status; +} + +status_t flexspi_nor_wait_bus_busy(FLEXSPI_Type *base) +{ + /* Wait status ready. */ + bool isBusy; + uint32_t readValue; + status_t status; + flexspi_transfer_t flashXfer; + + flashXfer.deviceAddress = 0; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Read; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_READSTATUSREG; + flashXfer.data = &readValue; + flashXfer.dataSize = 1; + + do + { + status = FLEXSPI_TransferBlocking(base, &flashXfer); + + if (status != kStatus_Success) + { + return status; + } + if (FLASH_BUSY_STATUS_POL) + { + if (readValue & (1U << FLASH_BUSY_STATUS_OFFSET)) + { + isBusy = true; + } + else + { + isBusy = false; + } + } + else + { + if (readValue & (1U << FLASH_BUSY_STATUS_OFFSET)) + { + isBusy = false; + } + else + { + isBusy = true; + } + } + + } while (isBusy); + + return status; +} + +status_t flexspi_nor_enable_quad_mode(FLEXSPI_Type *base) +{ + flexspi_transfer_t flashXfer; + status_t status; + uint32_t writeValue = FLASH_QUAD_ENABLE; + + /* Write enable */ + status = flexspi_nor_write_enable(base, 0); + + if (status != kStatus_Success) + { + return status; + } + + /* Enable quad mode. */ + flashXfer.deviceAddress = 0; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Write; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_WRITESTATUSREG; + flashXfer.data = &writeValue; + flashXfer.dataSize = 1; + + status = FLEXSPI_TransferBlocking(base, &flashXfer); + if (status != kStatus_Success) + { + return status; + } + + status = flexspi_nor_wait_bus_busy(base); + + /* Do software reset. */ + FLEXSPI_SoftwareReset(base); + + return status; +} + +status_t flexspi_nor_flash_erase_sector(FLEXSPI_Type *base, uint32_t address) +{ + status_t status; + flexspi_transfer_t flashXfer; + + /* Write enable */ + flashXfer.deviceAddress = address; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Command; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_WRITEENABLE; + + status = FLEXSPI_TransferBlocking(base, &flashXfer); + + if (status != kStatus_Success) + { + return status; + } + + flashXfer.deviceAddress = address; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Command; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_ERASESECTOR; + status = FLEXSPI_TransferBlocking(base, &flashXfer); + + if (status != kStatus_Success) + { + return status; + } + + status = flexspi_nor_wait_bus_busy(base); + + /* Do software reset. */ + FLEXSPI_SoftwareReset(base); + + return status; +} + +status_t flexspi_nor_flash_program(FLEXSPI_Type *base, uint32_t dstAddr, const uint32_t *src, uint32_t length) +{ + status_t status; + flexspi_transfer_t flashXfer; + + /* Write enable */ + status = flexspi_nor_write_enable(base, dstAddr); + + if (status != kStatus_Success) + { + return status; + } + + /* Prepare page program command */ + flashXfer.deviceAddress = dstAddr; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Write; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD; + flashXfer.data = (uint32_t *)src; + flashXfer.dataSize = length; + status = FLEXSPI_TransferBlocking(base, &flashXfer); + + if (status != kStatus_Success) + { + return status; + } + + status = flexspi_nor_wait_bus_busy(base); + + /* Do software reset. */ +#if defined(FSL_FEATURE_SOC_OTFAD_COUNT) + base->AHBCR |= FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK; + base->AHBCR &= ~(FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK); +#else + FLEXSPI_SoftwareReset(base); +#endif + + return status; +} + +status_t flexspi_nor_flash_page_program(FLEXSPI_Type *base, uint32_t dstAddr, const uint32_t *src) +{ + status_t status; + flexspi_transfer_t flashXfer; + + /* Write enable */ + status = flexspi_nor_write_enable(base, dstAddr); + + if (status != kStatus_Success) + { + return status; + } + + /* Prepare page program command */ + flashXfer.deviceAddress = dstAddr; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Write; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD; + flashXfer.data = (uint32_t *)src; + flashXfer.dataSize = FLASH_PAGE_SIZE; + status = FLEXSPI_TransferBlocking(base, &flashXfer); + + if (status != kStatus_Success) + { + return status; + } + + status = flexspi_nor_wait_bus_busy(base); + + /* Do software reset. */ +#if defined(FSL_FEATURE_SOC_OTFAD_COUNT) + base->AHBCR |= FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK; + base->AHBCR &= ~(FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK); +#else + FLEXSPI_SoftwareReset(base); +#endif + + return status; +} + +status_t flexspi_nor_get_vendor_id(FLEXSPI_Type *base, uint8_t *vendorId) +{ + uint32_t temp; + flexspi_transfer_t flashXfer; + flashXfer.deviceAddress = 0; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Read; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_READID; + flashXfer.data = &temp; + flashXfer.dataSize = 1; + + status_t status = FLEXSPI_TransferBlocking(base, &flashXfer); + + *vendorId = temp; + + /* Do software reset. */ +#if defined(FSL_FEATURE_SOC_OTFAD_COUNT) + base->AHBCR |= FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK; + base->AHBCR &= ~(FLEXSPI_AHBCR_CLRAHBRXBUF_MASK | FLEXSPI_AHBCR_CLRAHBTXBUF_MASK); +#else + FLEXSPI_SoftwareReset(base); +#endif + + return status; +} + +status_t flexspi_nor_erase_chip(FLEXSPI_Type *base) +{ + status_t status; + flexspi_transfer_t flashXfer; + + /* Write enable */ + status = flexspi_nor_write_enable(base, 0); + + if (status != kStatus_Success) + { + return status; + } + + flashXfer.deviceAddress = 0; + flashXfer.port = kFLEXSPI_PortA1; + flashXfer.cmdType = kFLEXSPI_Command; + flashXfer.SeqNumber = 1; + flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_ERASECHIP; + + status = FLEXSPI_TransferBlocking(base, &flashXfer); + + if (status != kStatus_Success) + { + return status; + } + + status = flexspi_nor_wait_bus_busy(base); + + return status; +} + +void flexspi_nor_flash_init(FLEXSPI_Type *base) +{ + flexspi_config_t config; + + flexspi_clock_init(); + + /*Get FLEXSPI default settings and configure the flexspi. */ + FLEXSPI_GetDefaultConfig(&config); + + /*Set AHB buffer size for reading data through AHB bus. */ + config.ahbConfig.enableAHBPrefetch = true; + config.ahbConfig.enableAHBBufferable = true; + config.ahbConfig.enableReadAddressOpt = true; + config.ahbConfig.enableAHBCachable = true; + config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackFromDqsPad; + FLEXSPI_Init(base, &config); + + /* Configure flash settings according to serial flash feature. */ + FLEXSPI_SetFlashConfig(base, &deviceconfig, kFLEXSPI_PortA1); + + /* Update LUT table. */ + FLEXSPI_UpdateLUT(base, 0, customLUT, CUSTOM_LUT_LENGTH); + + /* Do software reset. */ + FLEXSPI_SoftwareReset(base); +} diff --git a/ports/mimxrt10xx/supervisor/internal_flash.c b/ports/mimxrt10xx/supervisor/internal_flash.c new file mode 100644 index 0000000000..e15b4962ef --- /dev/null +++ b/ports/mimxrt10xx/supervisor/internal_flash.c @@ -0,0 +1,255 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * 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/flash.h" + +#include +#include +#include + +#include "extmod/vfs.h" +#include "extmod/vfs_fat.h" +#include "py/mphal.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "lib/oofatfs/ff.h" + +#include "fsl_cache.h" +#include "fsl_flexspi.h" +#include "fsl_iomuxc.h" + +// defined in linker +extern uint32_t __fatfs_flash_start_addr[]; +extern uint32_t __fatfs_flash_length[]; + +#define NO_CACHE 0xffffffff +#define SECTOR_SIZE 0x1000 /* 4K */ + +uint8_t _flash_cache[SECTOR_SIZE] __attribute__((aligned(4))); +uint32_t _flash_page_addr = NO_CACHE; +static bool init_done = false; + +flexspi_device_config_t deviceconfig = { + .flexspiRootClk = 133000000, + .flashSize = (BOARD_FLASH_SIZE / 1024), + .CSIntervalUnit = kFLEXSPI_CsIntervalUnit1SckCycle, + .CSInterval = 2, + .CSHoldTime = 3, + .CSSetupTime = 3, + .dataValidTime = 0, + .columnspace = 0, + .enableWordAddress = 0, + .AWRSeqIndex = 0, + .AWRSeqNumber = 0, + .ARDSeqIndex = NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD, + .ARDSeqNumber = 1, + .AHBWriteWaitUnit = kFLEXSPI_AhbWriteWaitUnit2AhbCycle, + .AHBWriteWaitInterval = 0, +}; + +const uint32_t customLUT[CUSTOM_LUT_LENGTH] = { + /* Normal read mode -SDR */ + /* Normal read mode -SDR */ + [4 * NOR_CMD_LUT_SEQ_IDX_READ_NORMAL] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x03, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18), + [4 * NOR_CMD_LUT_SEQ_IDX_READ_NORMAL + 1] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0), + + /* Fast read mode - SDR */ + [4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x0B, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18), + [4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST + 1] = FLEXSPI_LUT_SEQ( + kFLEXSPI_Command_DUMMY_SDR, kFLEXSPI_1PAD, 0x08, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04), + + /* Fast read quad mode - SDR */ + [4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xEB, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 0x18), + [4 * NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD + 1] = FLEXSPI_LUT_SEQ( + kFLEXSPI_Command_DUMMY_SDR, kFLEXSPI_4PAD, 0x06, kFLEXSPI_Command_READ_SDR, kFLEXSPI_4PAD, 0x04), + + /* Read extend parameters */ + [4 * NOR_CMD_LUT_SEQ_IDX_READSTATUS] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x81, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04), + + /* Write Enable */ + [4 * NOR_CMD_LUT_SEQ_IDX_WRITEENABLE] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x06, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0), + + /* Erase Sector */ + [4 * NOR_CMD_LUT_SEQ_IDX_ERASESECTOR] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x20, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18), + + /* Page Program - single mode */ + [4 * NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_SINGLE] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x02, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18), + [4 * NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_SINGLE + 1] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_WRITE_SDR, kFLEXSPI_1PAD, 0x04, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0), + + /* Page Program - quad mode */ + [4 * NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x32, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18), + [4 * NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD + 1] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_WRITE_SDR, kFLEXSPI_4PAD, 0x04, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0), + + /* Read ID */ + [4 * NOR_CMD_LUT_SEQ_IDX_READID] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x9F, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04), + + /* Enable Quad mode */ + [4 * NOR_CMD_LUT_SEQ_IDX_WRITESTATUSREG] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x31, kFLEXSPI_Command_WRITE_SDR, kFLEXSPI_1PAD, 0x04), + + /* Read status register */ + [4 * NOR_CMD_LUT_SEQ_IDX_READSTATUSREG] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x05, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04), + + /* Erase whole chip */ + [4 * NOR_CMD_LUT_SEQ_IDX_ERASECHIP] = + FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xC7, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0), +}; + +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_get_vendor_id(FLEXSPI_Type *base, uint8_t *vendorId); +extern status_t flexspi_nor_enable_quad_mode(FLEXSPI_Type *base); +extern status_t flexspi_nor_erase_chip(FLEXSPI_Type *base); +extern void flexspi_nor_flash_init(FLEXSPI_Type *base); + +void supervisor_flash_init(void) { + if (init_done) + return; + + SCB_DisableDCache(); + + status_t status; + uint8_t vendorID = 0; + + flexspi_nor_flash_init(FLEXSPI); + + /* Get vendor ID. */ + status = flexspi_nor_get_vendor_id(FLEXSPI, &vendorID); + if (status != kStatus_Success) { + printf("flexspi_nor_get_vendor_id fail %ld\r\n", status); + return; + } + + /* Enter quad mode. */ + __disable_irq(); + status = flexspi_nor_enable_quad_mode(FLEXSPI); + if (status != kStatus_Success) + { + printf("flexspi_nor_enable_quad_mode fail %ld\r\n", status); + return; + } + __enable_irq(); + + init_done = true; +} + +static inline uint32_t lba2addr(uint32_t block) { + return ((uint32_t)__fatfs_flash_start_addr) + block * FILESYSTEM_BLOCK_SIZE; +} + +uint32_t supervisor_flash_get_block_size(void) { + return FILESYSTEM_BLOCK_SIZE; +} + +uint32_t supervisor_flash_get_block_count(void) { + return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE; +} + +void supervisor_flash_flush(void) { + if (_flash_page_addr == NO_CACHE) return; + status_t status; + + // Skip if data is the same + if (memcmp(_flash_cache, (void *)_flash_page_addr, SECTOR_SIZE) != 0) { + volatile uint32_t sector_addr = (_flash_page_addr - FlexSPI_AMBA_BASE); + + __disable_irq(); + status = flexspi_nor_flash_erase_sector(FLEXSPI, sector_addr); + if (status != kStatus_Success) { + printf("Page erase failure %ld!\r\n", status); + return; + } + __enable_irq(); + + for (int i = 0; i < SECTOR_SIZE / FLASH_PAGE_SIZE; ++i) { + __disable_irq(); + status = flexspi_nor_flash_page_program(FLEXSPI, sector_addr + i * FLASH_PAGE_SIZE, (void *)_flash_cache + i * FLASH_PAGE_SIZE); + if (status != kStatus_Success) { + printf("Page program failure %ld!\r\n", status); + return; + } + __enable_irq(); + } + + DCACHE_CleanInvalidateByRange(_flash_page_addr, SECTOR_SIZE); + } +} + +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(); + + uint32_t src = lba2addr(block); + memcpy(dest, (uint8_t*)src, FILESYSTEM_BLOCK_SIZE * num_blocks); + return 0; // success +} + +mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32_t num_blocks) { + while (num_blocks) { + uint32_t const addr = lba2addr(lba); + uint32_t const page_addr = addr & ~(SECTOR_SIZE - 1); + + uint32_t count = 8 - (lba % 8); // up to page boundary + count = MIN(num_blocks, count); + + if (page_addr != _flash_page_addr) { + // Write out anything in cache before overwriting it. + supervisor_flash_flush(); + + _flash_page_addr = page_addr; + + // Copy the current contents of the entire page into the cache. + memcpy(_flash_cache, (void *)page_addr, SECTOR_SIZE); + } + + // Overwrite part or all of the page cache with the src data. + memcpy(_flash_cache + (addr & (SECTOR_SIZE - 1)), src, count * FILESYSTEM_BLOCK_SIZE); + + // adjust for next run + lba += count; + src += count * FILESYSTEM_BLOCK_SIZE; + num_blocks -= count; + } + + return 0; // success +} + +void supervisor_flash_release_cache(void) { +} + diff --git a/ports/mimxrt10xx/supervisor/internal_flash.h b/ports/mimxrt10xx/supervisor/internal_flash.h new file mode 100644 index 0000000000..dfbfe1d4b4 --- /dev/null +++ b/ports/mimxrt10xx/supervisor/internal_flash.h @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef MICROPY_INCLUDED_MIMXRT10XX_INTERNAL_FLASH_H +#define MICROPY_INCLUDED_MIMXRT10XX_INTERNAL_FLASH_H + +#include +#include + +#include "py/mpconfig.h" + +#define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms +#define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2) + +#define CUSTOM_LUT_LENGTH 60 +#define FLASH_PAGE_SIZE 256 + +#define NOR_CMD_LUT_SEQ_IDX_READ_NORMAL 7 +#define NOR_CMD_LUT_SEQ_IDX_READ_FAST 13 +#define NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD 0 +#define NOR_CMD_LUT_SEQ_IDX_READSTATUS 1 +#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE 2 +#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 3 +#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_SINGLE 6 +#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD 4 +#define NOR_CMD_LUT_SEQ_IDX_READID 8 +#define NOR_CMD_LUT_SEQ_IDX_WRITESTATUSREG 9 +#define NOR_CMD_LUT_SEQ_IDX_READSTATUSREG 12 +#define NOR_CMD_LUT_SEQ_IDX_ERASECHIP 5 + +#endif // MICROPY_INCLUDED_MIMXRT10XX_INTERNAL_FLASH_H diff --git a/ports/mimxrt10xx/supervisor/internal_flash_root_pointers.h b/ports/mimxrt10xx/supervisor/internal_flash_root_pointers.h new file mode 100644 index 0000000000..c8173175eb --- /dev/null +++ b/ports/mimxrt10xx/supervisor/internal_flash_root_pointers.h @@ -0,0 +1,31 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef MICROPY_INCLUDED_MIMXRT10XX_INTERNAL_FLASH_ROOT_POINTERS_H +#define MICROPY_INCLUDED_MIMXRT10XX_INTERNAL_FLASH_ROOT_POINTERS_H + +#define FLASH_ROOT_POINTERS + +#endif // MICROPY_INCLUDED_MIMXRT10XX_INTERNAL_FLASH_ROOT_POINTERS_H diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c new file mode 100644 index 0000000000..3573074279 --- /dev/null +++ b/ports/mimxrt10xx/supervisor/port.c @@ -0,0 +1,168 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2017 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 "boards/board.h" +#include "supervisor/port.h" + +#include "fsl_device_registers.h" + +#include "common-hal/microcontroller/Pin.h" +#include "common-hal/pulseio/PulseIn.h" +#include "common-hal/pulseio/PulseOut.h" +#include "common-hal/pulseio/PWMOut.h" +#include "common-hal/rtc/RTC.h" + +#include "reset.h" +#include "tick.h" + +#include "tusb.h" + +#if CIRCUITPY_GAMEPAD +#include "shared-module/gamepad/__init__.h" +#endif +#if CIRCUITPY_GAMEPADSHIFT +#include "shared-module/gamepadshift/__init__.h" +#endif +#include "shared-module/_pew/PewPew.h" + +#include "clocks.h" + +#include "fsl_gpio.h" +#include "fsl_lpuart.h" + +void mpu_init(void) +{ + ARM_MPU_Disable(); + + SCB_EnableDCache(); + SCB_EnableICache(); +} + +safe_mode_t port_init(void) { + mpu_init(); + clocks_init(); + + // Configure millisecond timer initialization. + tick_init(); + +#if CIRCUITPY_RTC + rtc_init(); +#endif + + // Reset everything into a known state before board_init. + reset_port(); + + // Init the board last so everything else is ready + board_init(); + + if (board_requests_safe_mode()) { + return USER_SAFE_MODE; + } + + return NO_SAFE_MODE; +} + +void reset_port(void) { + //reset_sercoms(); + +#if CIRCUITPY_AUDIOIO + audio_dma_reset(); + audioout_reset(); +#endif +#if CIRCUITPY_AUDIOBUSIO + i2sout_reset(); + //pdmin_reset(); +#endif + +#if CIRCUITPY_TOUCHIO && CIRCUITPY_TOUCHIO_USE_NATIVE + touchin_reset(); +#endif + +// eic_reset(); + +#if CIRCUITPY_PULSEIO + pulseout_reset(); + pwmout_reset(); +#endif + +#if CIRCUITPY_RTC + rtc_reset(); +#endif + +#if CIRCUITPY_GAMEPAD + gamepad_reset(); +#endif +#if CIRCUITPY_GAMEPADSHIFT + gamepadshift_reset(); +#endif +#if CIRCUITPY_PEW + pew_reset(); +#endif + + //reset_event_system(); + + reset_all_pins(); +} + +void reset_to_bootloader(void) { + _bootloader_dbl_tap = DBL_TAP_MAGIC; + reset(); +} + +void reset_cpu(void) { + reset(); +} + +extern uint32_t _heap_start, _estack; +uint32_t *port_stack_get_limit(void) { + return &_heap_start; +} + +uint32_t *port_stack_get_top(void) { + return &_estack; +} + +extern uint32_t __bss_end__; +// Place the word to save just after our BSS section that gets blanked. +void port_set_saved_word(uint32_t value) { + __bss_end__ = value; +} + +uint32_t port_get_saved_word(void) { + return __bss_end__; +} + +/** + * \brief Default interrupt handler for unused IRQs. + */ +__attribute__((used)) void HardFault_Handler(void) +{ + reset_into_safe_mode(HARD_CRASH); + while (true) { + asm("nop;"); + } +} diff --git a/ports/mimxrt10xx/supervisor/serial.c b/ports/mimxrt10xx/supervisor/serial.c new file mode 100644 index 0000000000..22c979cf9a --- /dev/null +++ b/ports/mimxrt10xx/supervisor/serial.c @@ -0,0 +1,93 @@ +/* + * 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 "py/mphal.h" +#include +#include "supervisor/serial.h" + +#include "fsl_clock.h" +#include "fsl_lpuart.h" + +// 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 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 serial_connected(void) { + return true; +} + +char serial_read(void) { + uint8_t data; + + LPUART_ReadBlocking(uart_instance, &data, sizeof(data)); + + return data; +} + +bool serial_bytes_available(void) { + return LPUART_GetStatusFlags(uart_instance) & kLPUART_RxDataRegFullFlag; +} + +void serial_write(const char* text) { + LPUART_WriteBlocking(uart_instance, (uint8_t*)text, strlen(text)); +} + +void serial_write_substring(const char *text, uint32_t len) { + if (len == 0) { + return; + } + + LPUART_WriteBlocking(uart_instance, (uint8_t*)text, len); +} + diff --git a/ports/mimxrt10xx/supervisor/usb.c b/ports/mimxrt10xx/supervisor/usb.c new file mode 100644 index 0000000000..c38dd55b9d --- /dev/null +++ b/ports/mimxrt10xx/supervisor/usb.c @@ -0,0 +1,56 @@ +/* + * 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 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 "fsl_clock.h" +#include "tusb.h" + +void init_usb_hardware(void) { + CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U); + CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U); + +#ifdef USBPHY + USBPHY_Type *usb_phy = USBPHY; +#else + USBPHY_Type *usb_phy = USBPHY1; +#endif + + // Enable PHY support for Low speed device + LS via FS Hub + usb_phy->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK; + + // Enable all power for normal operation + usb_phy->PWD = 0; + + // TX Timing + uint32_t phytx = usb_phy->TX; + phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK); + phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06); + usb_phy->TX = phytx; +} + +void USB_OTG1_IRQHandler(void) { + tud_isr(0); +} diff --git a/ports/mimxrt10xx/tick.c b/ports/mimxrt10xx/tick.c new file mode 100644 index 0000000000..c19ce796ed --- /dev/null +++ b/ports/mimxrt10xx/tick.c @@ -0,0 +1,92 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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 "tick.h" + +#include "fsl_common.h" + +#include "supervisor/shared/tick.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Processor.h" + +void SysTick_Handler(void) { + // SysTick interrupt handler called when the SysTick timer reaches zero + // (every millisecond). + common_hal_mcu_disable_interrupts(); + + // Read the control register to reset the COUNTFLAG. + (void) SysTick->CTRL; + + common_hal_mcu_enable_interrupts(); + + // Do things common to all ports when the tick occurs + supervisor_tick(); +} + +void tick_init() { + uint32_t ticks_per_ms = common_hal_mcu_processor_get_frequency() / 1000; + SysTick_Config(ticks_per_ms-1); +} + +void tick_delay(uint32_t us) { + uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; + uint32_t us_until_next_tick = SysTick->VAL / ticks_per_us; + uint32_t start_tick; + while (us >= us_until_next_tick) { + start_tick = SysTick->VAL; // wait for SysTick->VAL to RESET + while (SysTick->VAL < start_tick) {} + us -= us_until_next_tick; + us_until_next_tick = 1000; + } + while (SysTick->VAL > ((us_until_next_tick - us) * ticks_per_us)) {} +} + +// us counts down! +void current_tick(uint64_t* ms, uint32_t* us_until_ms) { + uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; + + // We disable interrupts to prevent ticks_ms from changing while we grab it. + common_hal_mcu_disable_interrupts(); + uint32_t tick_status = SysTick->CTRL; + uint32_t current_us = SysTick->VAL; + uint32_t tick_status2 = SysTick->CTRL; + uint64_t current_ms = supervisor_ticks_ms64(); + // The second clause ensures our value actually rolled over. Its possible it hit zero between + // the VAL read and CTRL read. + if ((tick_status & SysTick_CTRL_COUNTFLAG_Msk) != 0 || + ((tick_status2 & SysTick_CTRL_COUNTFLAG_Msk) != 0 && current_us > ticks_per_us)) { + current_ms++; + } + common_hal_mcu_enable_interrupts(); + *ms = current_ms; + *us_until_ms = current_us / ticks_per_us; +} + +void wait_until(uint64_t ms, uint32_t us_until_ms) { + uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; + while (supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} +} diff --git a/ports/mimxrt10xx/tick.h b/ports/mimxrt10xx/tick.h new file mode 100644 index 0000000000..6660d5b4ae --- /dev/null +++ b/ports/mimxrt10xx/tick.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft 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. + */ +#ifndef MICROPY_INCLUDED_MIMXRT10XX_TICK_H +#define MICROPY_INCLUDED_MIMXRT10XX_TICK_H + +#include "py/mpconfig.h" + +extern struct timer_descriptor ms_timer; + +void tick_init(void); + +void tick_delay(uint32_t us); + +void current_tick(uint64_t* ms, uint32_t* us_until_ms); +// Do not call this with interrupts disabled because it may be waiting for +// ticks_ms to increment. +void wait_until(uint64_t ms, uint32_t us_until_ms); + +#endif // MICROPY_INCLUDED_MIMXRT10XX_TICK_H diff --git a/tools/uf2 b/tools/uf2 index 968716efd3..84da66ce62 160000 --- a/tools/uf2 +++ b/tools/uf2 @@ -1 +1 @@ -Subproject commit 968716efd30600984139d706bcbd8ec1a1b2336d +Subproject commit 84da66ce62215c1daa62204f2c3fa83c05143a42 From 0068bafbb63290eb17db78e81759fa4aa1799951 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Mon, 6 Jan 2020 21:33:44 +0100 Subject: [PATCH 289/531] Add MIMXRT10XX port to release build --- tools/build_board_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 7c4484a659..d583fc63f2 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -12,7 +12,7 @@ from sh.contrib import git sys.path.append("adabot") import adabot.github_requests as github -SUPPORTED_PORTS = ["nrf", "atmel-samd", "stm32f4", "cxd56"] +SUPPORTED_PORTS = ["nrf", "atmel-samd", "stm32f4", "cxd56", "mimxrt10xx"] BIN = ('bin',) UF2 = ('uf2',) @@ -26,6 +26,7 @@ extension_by_port = { "atmel-samd": UF2, "stm32f4": BIN, "cxd56": SPK, + "mimxrt10xx": UF2, } # Per board overrides From 0bbeae1786ed4c1527733ed625c0ec0dd3bb2838 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 6 Jan 2020 15:37:37 -0500 Subject: [PATCH 290/531] WIP edits --- ports/stm32f4/Makefile | 4 ++-- ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 6c5190668f..93cde67371 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -22,7 +22,7 @@ # 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. -#DEBUG = 1 +DEBUG = 1 # Select the board to build for. ifeq ($(BOARD),) @@ -256,7 +256,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(ECHO) "Create $@" - $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b 0x08010000 -c -o "$(BUILD)/firmware.uf2" $^ + $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b 0x08000000 -c -o "$(BUILD)/firmware.uf2" $^ include $(TOP)/py/mkrules.mk diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index e40f9d80ca..73f1d722af 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -2,7 +2,7 @@ USB_VID = 0x239A USB_PID = 0x805A USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" -USB_DEVICES = "CDC" +USB_DEVICES = "CDC,MSC" SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 @@ -17,6 +17,7 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401_boot.ld #STM32F401_fs.ld +# LD_FILE = boards/STM32F401_boot.ld +LD_FILE = boards/STM32F401_fs.ld TEXT0_ADDR = 0x08010000 TEXT1_ADDR = 0x08040000 \ No newline at end of file From b778aee21d7facb8ced147086a2bc5225a319d80 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 6 Jan 2020 17:08:52 -0500 Subject: [PATCH 291/531] Make inclusion non-conditional --- ports/stm32f4/mpconfigport.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk index 42f3905723..48bd3ad612 100644 --- a/ports/stm32f4/mpconfigport.mk +++ b/ports/stm32f4/mpconfigport.mk @@ -69,9 +69,7 @@ ifndef CIRCUITPY_DISPLAYIO CIRCUITPY_DISPLAYIO = 1 endif -ifndef MICROPY_CPYTHON_COMPAT MICROPY_CPYTHON_COMPAT = 1 -endif #ifeq ($(MCU_SUB_VARIANT), stm32f412zx) #endif From ff6d9d8a521d3d693a1996e6696b3dc30ff0fd93 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Tue, 7 Jan 2020 09:29:47 +0100 Subject: [PATCH 292/531] mimxrt10xx: Use the correct error for not implemented functionality Co-Authored-By: Scott Shawcroft --- ports/mimxrt10xx/common-hal/analogio/AnalogOut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c index 6e34a72178..3d072627a4 100644 --- a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c @@ -32,7 +32,7 @@ #include "supervisor/shared/translate.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin) { - mp_raise_RuntimeError(translate("AnalogOut functionality not supported")); + mp_raise_NotImplementedError(translate("AnalogOut functionality not supported")); } bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) { From 6ab75fe8c5e2e4ca930323f0e1e8ef0fcf009627 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 7 Jan 2020 13:19:00 -0500 Subject: [PATCH 293/531] Allow MOSI/MISO exclusion --- ports/stm32f4/common-hal/busio/SPI.c | 143 ++++++++++++++++++--------- 1 file changed, 95 insertions(+), 48 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index 32089887f9..fe20416833 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -36,6 +36,9 @@ #include "supervisor/shared/translate.h" #include "common-hal/microcontroller/Pin.h" +// Note that any bugs introduced in this file can cause crashes at startup +// for chips using external SPI flash. + #define MAX_SPI 6 //TODO; replace this as part of periph cleanup #define ALL_CLOCKS 0xFF @@ -79,38 +82,80 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, uint8_t sck_len = sizeof(mcu_spi_sck_list)/sizeof(*mcu_spi_sck_list); uint8_t mosi_len = sizeof(mcu_spi_mosi_list)/sizeof(*mcu_spi_mosi_list); uint8_t miso_len = sizeof(mcu_spi_miso_list)/sizeof(*mcu_spi_miso_list); - bool spi_taken = false; - //sck + + //sck is not optional. MOSI and MISO are for(uint i=0; isck = &mcu_spi_sck_list[i]; + self->mosi = &mcu_spi_mosi_list[j]; + self->miso = &mcu_spi_miso_list[k]; + break; } - //store pins if not - self->sck = &mcu_spi_sck_list[i]; - self->mosi = &mcu_spi_mosi_list[j]; - self->miso = &mcu_spi_miso_list[k]; - break; - } - } + } + } } + // if just miso, reduce search + } else if (miso != mp_const_none) { + for(uint j=0; jsck = &mcu_spi_sck_list[i]; + self->mosi = NULL; + self->miso = &mcu_spi_miso_list[j]; + break; + } + } + // if just mosi, reduce search + } else if (mosi != mp_const_none) { + for(uint j=0; jsck = &mcu_spi_sck_list[i]; + self->mosi = &mcu_spi_mosi_list[j]; + self->miso = NULL; + break; + } + } + } else { + //throw an error immediately + mp_raise_ValueError(translate("Must provide MISO or MOSI pin")); } } } //handle typedef selection, errors - if(self->sck!=NULL && self->mosi!=NULL && self->miso!=NULL ) { + if( (self->sck!=NULL && self->mosi!=NULL && self->miso != NULL) || + (self->sck!=NULL && self->mosi!=NULL && miso == mp_const_none) || + (self->sck!=NULL && self->miso!=NULL && mosi == mp_const_none)) { SPIx = mcu_spi_banks[self->sck->spi_index-1]; } else { if (spi_taken) { @@ -129,26 +174,31 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, GPIO_InitStruct.Alternate = self->sck->altfn_index; HAL_GPIO_Init(pin_port(sck->port), &GPIO_InitStruct); - GPIO_InitStruct.Pin = pin_mask(mosi->number); - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = self->mosi->altfn_index; - HAL_GPIO_Init(pin_port(mosi->port), &GPIO_InitStruct); + if (self->mosi != NULL) { + GPIO_InitStruct.Pin = pin_mask(mosi->number); + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = self->mosi->altfn_index; + HAL_GPIO_Init(pin_port(mosi->port), &GPIO_InitStruct); + } - GPIO_InitStruct.Pin = pin_mask(miso->number); - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = self->miso->altfn_index; - HAL_GPIO_Init(pin_port(miso->port), &GPIO_InitStruct); + if (self->miso != NULL) { + GPIO_InitStruct.Pin = pin_mask(miso->number); + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = self->miso->altfn_index; + HAL_GPIO_Init(pin_port(miso->port), &GPIO_InitStruct); + } spi_clock_enable(1<<(self->sck->spi_index - 1)); reserved_spi[self->sck->spi_index - 1] = true; self->handle.Instance = SPIx; self->handle.Init.Mode = SPI_MODE_MASTER; - self->handle.Init.Direction = SPI_DIRECTION_2LINES; + // Direction change only required for RX only, see RefMan RM0090:884 + self->handle.Init.Direction = (self->mosi == NULL) ? SPI_CR1_RXONLY : SPI_DIRECTION_2LINES; self->handle.Init.DataSize = SPI_DATASIZE_8BIT; self->handle.Init.CLKPolarity = SPI_POLARITY_LOW; self->handle.Init.CLKPhase = SPI_PHASE_1EDGE; @@ -169,8 +219,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, self->bits = 8; claim_pin(sck); - claim_pin(mosi); - claim_pin(miso); + if (self->mosi != NULL) claim_pin(mosi); + if (self->miso != NULL) claim_pin(miso); } void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { @@ -178,8 +228,8 @@ void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { if (mcu_spi_banks[i] == self->handle.Instance) { never_reset_spi[i] = true; never_reset_pin_number(self->sck->pin->port, self->sck->pin->number); - never_reset_pin_number(self->mosi->pin->port, self->mosi->pin->number); - never_reset_pin_number(self->miso->pin->port, self->miso->pin->number); + if (self->mosi != NULL) never_reset_pin_number(self->mosi->pin->port, self->mosi->pin->number); + if (self->miso != NULL) never_reset_pin_number(self->miso->pin->port, self->miso->pin->number); break; } } @@ -195,8 +245,8 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { never_reset_spi[self->sck->spi_index - 1] = false; reset_pin_number(self->sck->pin->port,self->sck->pin->number); - reset_pin_number(self->mosi->pin->port,self->mosi->pin->number); - reset_pin_number(self->miso->pin->port,self->miso->pin->number); + if (self->mosi != NULL) reset_pin_number(self->mosi->pin->port,self->mosi->pin->number); + if (self->miso != NULL) reset_pin_number(self->miso->pin->port,self->miso->pin->number); self->sck = mp_const_none; self->mosi = mp_const_none; self->miso = mp_const_none; @@ -243,13 +293,6 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, self->handle.Init.BaudRatePrescaler = stm32_baud_to_spi_div(baudrate, &self->prescaler, get_busclock(self->handle.Instance)); - self->handle.Init.Mode = SPI_MODE_MASTER; - self->handle.Init.Direction = SPI_DIRECTION_2LINES; - self->handle.Init.NSS = SPI_NSS_SOFT; - self->handle.Init.FirstBit = SPI_FIRSTBIT_MSB; - self->handle.Init.TIMode = SPI_TIMODE_DISABLE; - self->handle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - self->handle.Init.CRCPolynomial = 10; if (HAL_SPI_Init(&self->handle) != HAL_OK) { @@ -292,18 +335,22 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { + if (self->mosi == NULL) mp_raise_ValueError(translate("No MOSI Pin")); HAL_StatusTypeDef result = HAL_SPI_Transmit (&self->handle, (uint8_t *)data, (uint16_t)len, HAL_MAX_DELAY); return result == HAL_OK; } bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { + if (self->miso == NULL) mp_raise_ValueError(translate("No MISO Pin")); HAL_StatusTypeDef result = HAL_SPI_Receive (&self->handle, data, (uint16_t)len, HAL_MAX_DELAY); return result == HAL_OK; } bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) { + if (self->miso == NULL) mp_raise_ValueError(translate("No MISO Pin")); + if (self->mosi == NULL) mp_raise_ValueError(translate("No MOSI Pin")); HAL_StatusTypeDef result = HAL_SPI_TransmitReceive (&self->handle, data_out, data_in, (uint16_t)len,HAL_MAX_DELAY); return result == HAL_OK; From d645ea222d121fef0d82be309f917ea856eef030 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 7 Jan 2020 13:25:24 -0500 Subject: [PATCH 294/531] Text fixes for consistency --- ports/stm32f4/common-hal/busio/SPI.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index fe20416833..d1218c9abb 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -84,15 +84,15 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, uint8_t miso_len = sizeof(mcu_spi_miso_list)/sizeof(*mcu_spi_miso_list); bool spi_taken = false; - //sck is not optional. MOSI and MISO are + //SCK is not optional. MOSI and MISO are for(uint i=0; ihandle.Instance = SPIx; self->handle.Init.Mode = SPI_MODE_MASTER; - // Direction change only required for RX only, see RefMan RM0090:884 + // Direction change only required for RX-only, see RefMan RM0090:884 self->handle.Init.Direction = (self->mosi == NULL) ? SPI_CR1_RXONLY : SPI_DIRECTION_2LINES; self->handle.Init.DataSize = SPI_DATASIZE_8BIT; self->handle.Init.CLKPolarity = SPI_POLARITY_LOW; From 19803c664fbea167bb91bd1e0da4d8566354e3dd Mon Sep 17 00:00:00 2001 From: arturo182 Date: Tue, 7 Jan 2020 20:05:57 +0100 Subject: [PATCH 295/531] mimxrt10xx: Add info on clock config source --- .../peripherals/mimxrt10xx/MIMXRT1011/clocks.c | 12 ++---------- .../peripherals/mimxrt10xx/MIMXRT1062/clocks.c | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c index 59f7bcd24a..fa86b967a1 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c @@ -66,16 +66,6 @@ #define BOARD_BOOTCLOCKRUN_UART_CLK_ROOT 80000000UL #define BOARD_BOOTCLOCKRUN_USBPHY_CLK 0UL -/*! @brief Usb1 PLL set for BOARD_BootClockRUN configuration. - */ -//extern const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN; -/*! @brief Sys PLL for BOARD_BootClockRUN configuration. - */ -//extern const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN; -/*! @brief Enet PLL set for BOARD_BootClockRUN configuration. - */ -//extern const clock_enet_pll_config_t enetPllConfig_BOARD_BootClockRUN; - const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN = { .loopDivider = 1, /* PLL loop divider, Fout = Fin * ( 20 + loopDivider*2 + numerator / denominator ) */ .numerator = 0, /* 30 bit numerator of fractional loop divider */ @@ -90,6 +80,8 @@ const clock_enet_pll_config_t enetPllConfig_BOARD_BootClockRUN = { .enableClkOutput500M = true, /* Enable the PLL providing the ENET 500MHz reference clock */ .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ }; + +// Based on the hello_world example in the SDK void clocks_init(void) { /* Init RTC OSC clock frequency. */ CLOCK_SetRtcXtalFreq(32768U); diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c index 422834529d..7f54ced0fe 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c @@ -33,16 +33,6 @@ #define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32k frequency in Hz */ #define BOARD_BOOTCLOCKRUN_CORE_CLOCK 600000000U /*!< Core clock frequency: 600000000Hz */ -/*! @brief Usb1 PLL set for BOARD_BootClockRUN configuration. - */ -//extern const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN; -/*! @brief Sys PLL for BOARD_BootClockRUN configuration. - */ -//extern const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN; -/*! @brief Enet PLL set for BOARD_BootClockRUN configuration. - */ -//extern const clock_enet_pll_config_t enetPllConfig_BOARD_BootClockRUN; - const clock_arm_pll_config_t armPllConfig_BOARD_BootClockRUN = { .loopDivider = 100, /* PLL loop divider, Fout = Fin * 50 */ @@ -60,6 +50,8 @@ const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN = .loopDivider = 0, /* PLL loop divider, Fout = Fin * 20 */ .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ }; + +// Based on the hello_world example in the SDK void clocks_init(void) { /* Init RTC OSC clock frequency. */ CLOCK_SetRtcXtalFreq(32768U); From cc7b57c8d414ea60fcdf10d57b0e887655fbbc3b Mon Sep 17 00:00:00 2001 From: arturo182 Date: Tue, 7 Jan 2020 22:07:27 +0100 Subject: [PATCH 296/531] mimxrt10xx: Add license for NXP code --- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c | 6 ++++++ ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c index fa86b967a1..c039917856 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c @@ -23,6 +23,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +/* + * Copyright 2019 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ #include "mpconfigport.h" diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c index 7f54ced0fe..cafc8efc3b 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c @@ -23,6 +23,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +/* + * Copyright 2019 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ #include "mpconfigport.h" From 5531253c7659007d14c92c34bee2fa977a37af0b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 7 Jan 2020 14:25:27 -0800 Subject: [PATCH 297/531] Update submodules including BusDevice and HID. HID's API has changed to take in devices explicitly so that both USB and BLE work. --- frozen/Adafruit_CircuitPython_BusDevice | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- tools/uf2 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 2000ae3a7c..805d41a021 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 2000ae3a7c5d60b850c9546a16425aee279e2a36 +Subproject commit 805d41a021c70df7609da772a6f6131810e5d6ba diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index a23b80569f..2d1dce6ad6 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit a23b80569f23ef109667dd8c595d319e8a30d620 +Subproject commit 2d1dce6ad6ca7e091fd8b5c3f102693c24af8b88 diff --git a/tools/uf2 b/tools/uf2 index 84da66ce62..968716efd3 160000 --- a/tools/uf2 +++ b/tools/uf2 @@ -1 +1 @@ -Subproject commit 84da66ce62215c1daa62204f2c3fa83c05143a42 +Subproject commit 968716efd30600984139d706bcbd8ec1a1b2336d From 11a8fc726dc13f829d339e87e74966c22863bb88 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 7 Jan 2020 14:31:58 -0800 Subject: [PATCH 298/531] Update translations --- locale/ID.po | 15 ++++++++++++--- locale/circuitpython.pot | 15 ++++++++++++--- locale/de_DE.po | 15 ++++++++++++--- locale/en_US.po | 15 ++++++++++++--- locale/en_x_pirate.po | 15 ++++++++++++--- locale/es.po | 15 ++++++++++++--- locale/fil.po | 15 ++++++++++++--- locale/fr.po | 15 ++++++++++++--- locale/it_IT.po | 15 ++++++++++++--- locale/ko.po | 15 ++++++++++++--- locale/pl.po | 15 ++++++++++++--- locale/pt_BR.po | 15 ++++++++++++--- locale/zh_Latn_pinyin.po | 15 ++++++++++++--- 13 files changed, 156 insertions(+), 39 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 20662ae9db..e6d19cc2c4 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -66,7 +66,8 @@ msgid "%q indices must be integers, not %s" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c #, fuzzy msgid "%q must be >= 1" msgstr "buffers harus mempunyai panjang yang sama" @@ -377,6 +378,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, fuzzy, c-format @@ -596,7 +601,7 @@ msgid "Expected a %q" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "" @@ -1325,6 +1330,10 @@ msgstr "" "\n" "Untuk menampilkan modul built-in silahkan ketik `help(\"modules\")`.\n" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 5cf44cc356..085101ff15 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -66,7 +66,8 @@ msgid "%q indices must be integers, not %s" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "" @@ -373,6 +374,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -585,7 +590,7 @@ msgid "Expected a %q" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "" @@ -1302,6 +1307,10 @@ msgid "" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 17f2e38280..f38a036899 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -68,7 +68,8 @@ msgid "%q indices must be integers, not %s" msgstr "%q Indizes müssen ganze Zahlen sein, nicht %s" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "%q muss >= 1 sein" @@ -377,6 +378,10 @@ msgstr "Die Pufferlänge %d ist zu groß. Sie muss kleiner als %d sein." msgid "Buffer must be at least length 1" msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -589,7 +594,7 @@ msgid "Expected a %q" msgstr "Erwartet ein(e) %q" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "Characteristic wird erwartet" @@ -1330,6 +1335,10 @@ msgstr "" "Um die integrierten Module aufzulisten, führe bitte `help(\"modules\")` " "aus.\n" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index e6fbfc471b..136d0699de 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -66,7 +66,8 @@ msgid "%q indices must be integers, not %s" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "" @@ -373,6 +374,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -585,7 +590,7 @@ msgid "Expected a %q" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "" @@ -1302,6 +1307,10 @@ msgid "" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 5635102301..81e05f7dc3 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -68,7 +68,8 @@ msgid "%q indices must be integers, not %s" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "" @@ -377,6 +378,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -589,7 +594,7 @@ msgid "Expected a %q" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "" @@ -1306,6 +1311,10 @@ msgid "" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/es.po b/locale/es.po index c9688a41b1..a8f6afb2a1 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -68,7 +68,8 @@ msgid "%q indices must be integers, not %s" msgstr "%q indices deben ser enteros, no %s" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "%q debe ser >= 1" @@ -379,6 +380,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "Buffer debe ser de longitud 1 como minimo" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -591,7 +596,7 @@ msgid "Expected a %q" msgstr "Se espera un %q" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "Se esperaba una Característica." @@ -1327,6 +1332,10 @@ msgstr "" "\n" "Para listar los módulos incorporados por favor haga `help(\"modules\")`.\n" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/fil.po b/locale/fil.po index 94f39f4064..3c1d13fa85 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -66,7 +66,8 @@ msgid "%q indices must be integers, not %s" msgstr "%q indeks ay dapat integers, hindi %s" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c #, fuzzy msgid "%q must be >= 1" msgstr "aarehas na haba dapat ang buffer slices" @@ -379,6 +380,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "Buffer dapat ay hindi baba sa 1 na haba" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, fuzzy, c-format @@ -597,7 +602,7 @@ msgid "Expected a %q" msgstr "Umasa ng %q" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c #, fuzzy msgid "Expected a Characteristic" msgstr "Hindi mabasa and Characteristic." @@ -1336,6 +1341,10 @@ msgstr "" "\n" "Para makita ang listahan ng modules, `help(“modules”)`.\n" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 42209a045e..df189306c9 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -68,7 +68,8 @@ msgid "%q indices must be integers, not %s" msgstr "les indices %q doivent être des entiers, pas %s" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c #, fuzzy msgid "%q must be >= 1" msgstr "%d doit être >=1" @@ -383,6 +384,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "Le tampon doit être de longueur au moins 1" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, fuzzy, c-format @@ -600,7 +605,7 @@ msgid "Expected a %q" msgstr "Attendu un %q" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c #, fuzzy msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" @@ -1353,6 +1358,10 @@ msgstr "" "\n" "Pour lister les modules inclus, tapez `help(\"modules\")`.\n" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 684e2a90b9..3a6a710063 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -66,7 +66,8 @@ msgid "%q indices must be integers, not %s" msgstr "gli indici %q devono essere interi, non %s" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c #, fuzzy msgid "%q must be >= 1" msgstr "slice del buffer devono essere della stessa lunghezza" @@ -379,6 +380,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "Il buffer deve essere lungo almeno 1" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, fuzzy, c-format @@ -597,7 +602,7 @@ msgid "Expected a %q" msgstr "Atteso un %q" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c #, fuzzy msgid "Expected a Characteristic" msgstr "Non è possibile aggiungere Characteristic." @@ -1339,6 +1344,10 @@ msgid "" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 7b4240800b..d8c9cbfba5 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -68,7 +68,8 @@ msgid "%q indices must be integers, not %s" msgstr "%q 인덱스는 %s 가 아닌 정수 여야합니다" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "%q 는 >=1이어야합니다" @@ -377,6 +378,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "잘못된 크기의 버퍼. >1 여야합니다" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -589,7 +594,7 @@ msgid "Expected a %q" msgstr "%q 이 예상되었습니다." #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "특성(Characteristic)이 예상되었습니다." @@ -1307,6 +1312,10 @@ msgid "" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 1ef686e451..6a16b2437a 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -67,7 +67,8 @@ msgid "%q indices must be integers, not %s" msgstr "%q indeks musi być liczbą całkowitą, a nie %s" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "%q musi być >= 1" @@ -376,6 +377,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "Bufor musi mieć długość 1 lub więcej" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -588,7 +593,7 @@ msgid "Expected a %q" msgstr "Oczekiwano %q" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "Oczekiwano charakterystyki" @@ -1310,6 +1315,10 @@ msgstr "" "Podręczniki dostępne na learn.adafruit.com/category/circuitpyhon.\n" "Aby zobaczyć wbudowane moduły, wpisz `help(\"modules\")`.\n" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 9d36696ce7..7fb8fe9d7f 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -66,7 +66,8 @@ msgid "%q indices must be integers, not %s" msgstr "" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c #, fuzzy msgid "%q must be >= 1" msgstr "buffers devem ser o mesmo tamanho" @@ -376,6 +377,10 @@ msgstr "" msgid "Buffer must be at least length 1" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, fuzzy, c-format @@ -592,7 +597,7 @@ msgid "Expected a %q" msgstr "Esperado um" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c #, fuzzy msgid "Expected a Characteristic" msgstr "Não é possível adicionar Característica." @@ -1320,6 +1325,10 @@ msgid "" "To list built-in modules please do `help(\"modules\")`.\n" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index cb907e0a1f..9f1c0ea5b6 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-01 17:29-0500\n" +"POT-Creation-Date: 2020-01-07 14:31-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -68,7 +68,8 @@ msgid "%q indices must be integers, not %s" msgstr "%q suǒyǐn bìxū shì zhěngshù, ér bùshì %s" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c msgid "%q must be >= 1" msgstr "%q bìxū dàyú huò děngyú 1" @@ -377,6 +378,10 @@ msgstr "Huǎnchōng qū chángdù%d tài dà. Tā bìxū xiǎoyú%d" msgid "Buffer must be at least length 1" msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Buffer too large and unable to allocate" +msgstr "" + #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format @@ -589,7 +594,7 @@ msgid "Expected a %q" msgstr "Yùqí %q" #: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c +#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c msgid "Expected a Characteristic" msgstr "Yùqí de tèdiǎn" @@ -1319,6 +1324,10 @@ msgstr "" "\n" "Ruò yào liè chū nèizài de mókuài, qǐng qǐng zuò yǐxià `help(\"modules\")`.\n" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" msgstr "" From c4a64ae7a073e8dae3a2e8ee1f093f91f8dd740b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 7 Jan 2020 16:52:17 -0800 Subject: [PATCH 299/531] Don't change uf2 --- tools/uf2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/uf2 b/tools/uf2 index 968716efd3..84da66ce62 160000 --- a/tools/uf2 +++ b/tools/uf2 @@ -1 +1 @@ -Subproject commit 968716efd30600984139d706bcbd8ec1a1b2336d +Subproject commit 84da66ce62215c1daa62204f2c3fa83c05143a42 From 5baaac55ce2b9fb89c1f395e92f67abb5276ce6f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 8 Jan 2020 09:42:44 -0600 Subject: [PATCH 300/531] vstr_init_len: Don't crash if (size_t)-1 is passed In this unusual case, (len + 1) is zero, the allocation in vstr_init succeeds (allocating 1 byte), and then the caller is likely to erroneously access outside the allocated region, for instance with a memset(). This could be triggered with os.urandom(-1) after it was converted to use mp_obj_new_bytes_of_zeros. --- py/vstr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/vstr.c b/py/vstr.c index 869b278057..888f7069bb 100644 --- a/py/vstr.c +++ b/py/vstr.c @@ -50,6 +50,8 @@ void vstr_init(vstr_t *vstr, size_t alloc) { // Init the vstr so it allocs exactly enough ram to hold a null-terminated // string of the given length, and set the length. void vstr_init_len(vstr_t *vstr, size_t len) { + if(len == SIZE_MAX) + m_malloc_fail(len); vstr_init(vstr, len + 1); vstr->len = len; } From 6735283d8f6e352626d6ad7c4ee48b472ea65476 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 8 Jan 2020 09:43:13 -0600 Subject: [PATCH 301/531] os: Don't require an on-stack buffer This allows urandom requests of even 100k bytes to succeed on a fresh VM session on a Metro M4 express. --- shared-bindings/os/__init__.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 55ebd6f59f..c2b63bbcee 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -33,6 +33,7 @@ #include "lib/oofatfs/diskio.h" #include "py/mpstate.h" #include "py/obj.h" +#include "py/objstr.h" #include "py/runtime.h" #include "shared-bindings/os/__init__.h" @@ -195,11 +196,11 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync); //| STATIC mp_obj_t os_urandom(mp_obj_t size_in) { mp_int_t size = mp_obj_get_int(size_in); - uint8_t tmp[size]; - if (!common_hal_os_urandom(tmp, size)) { + mp_obj_str_t *result = MP_OBJ_TO_PTR(mp_obj_new_bytes_of_zeros(size)); + if (!common_hal_os_urandom((uint8_t*) result->data, size)) { mp_raise_NotImplementedError(translate("No hardware random available")); } - return mp_obj_new_bytes(tmp, size); + return result; } MP_DEFINE_CONST_FUN_OBJ_1(os_urandom_obj, os_urandom); From 3d5528b88f07b3ebb621d2c525bff3cadc3232b4 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 8 Jan 2020 10:53:53 -0500 Subject: [PATCH 302/531] style edits --- ports/stm32f4/common-hal/busio/SPI.c | 65 ++++++++++++++++++---------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index d1218c9abb..deacedb507 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -52,10 +52,10 @@ STATIC void spi_clock_disable(uint8_t mask); STATIC uint32_t get_busclock(SPI_TypeDef * instance) { //SPI2 and 3 are on PCLK1, if they exist. #ifdef SPI2 - if(instance == SPI2) return HAL_RCC_GetPCLK1Freq(); + if (instance == SPI2) return HAL_RCC_GetPCLK1Freq(); #endif #ifdef SPI3 - if(instance == SPI3) return HAL_RCC_GetPCLK1Freq(); + if (instance == SPI3) return HAL_RCC_GetPCLK1Freq(); #endif return HAL_RCC_GetPCLK2Freq(); } @@ -85,20 +85,20 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, bool spi_taken = false; //SCK is not optional. MOSI and MISO are - for(uint i=0; isck!=NULL && self->mosi!=NULL && self->miso != NULL) || + if ( (self->sck!=NULL && self->mosi!=NULL && self->miso != NULL) || (self->sck!=NULL && self->mosi!=NULL && miso == mp_const_none) || (self->sck!=NULL && self->miso!=NULL && mosi == mp_const_none)) { SPIx = mcu_spi_banks[self->sck->spi_index-1]; @@ -219,17 +219,25 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, self->bits = 8; claim_pin(sck); - if (self->mosi != NULL) claim_pin(mosi); - if (self->miso != NULL) claim_pin(miso); + if (self->mosi != NULL) { + claim_pin(mosi); + } + if (self->miso != NULL) { + claim_pin(miso); + } } void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { - for(size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_spi_banks); i++) { + for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_spi_banks); i++) { if (mcu_spi_banks[i] == self->handle.Instance) { never_reset_spi[i] = true; never_reset_pin_number(self->sck->pin->port, self->sck->pin->number); - if (self->mosi != NULL) never_reset_pin_number(self->mosi->pin->port, self->mosi->pin->number); - if (self->miso != NULL) never_reset_pin_number(self->miso->pin->port, self->miso->pin->number); + if (self->mosi != NULL) { + never_reset_pin_number(self->mosi->pin->port, self->mosi->pin->number); + } + if (self->miso != NULL) { + never_reset_pin_number(self->miso->pin->port, self->miso->pin->number); + } break; } } @@ -245,8 +253,12 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { never_reset_spi[self->sck->spi_index - 1] = false; reset_pin_number(self->sck->pin->port,self->sck->pin->number); - if (self->mosi != NULL) reset_pin_number(self->mosi->pin->port,self->mosi->pin->number); - if (self->miso != NULL) reset_pin_number(self->miso->pin->port,self->miso->pin->number); + if (self->mosi != NULL) { + reset_pin_number(self->mosi->pin->port,self->mosi->pin->number); + } + if (self->miso != NULL) { + reset_pin_number(self->miso->pin->port,self->miso->pin->number); + } self->sck = mp_const_none; self->mosi = mp_const_none; self->miso = mp_const_none; @@ -282,7 +294,9 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t bits) { //This resets the SPI, so check before updating it redundantly if (baudrate == self->baudrate && polarity== self->polarity - && phase == self->phase && bits == self->bits) return true; + && phase == self->phase && bits == self->bits) { + return true; + } //Deinit SPI HAL_SPI_DeInit(&self->handle); @@ -335,22 +349,27 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { - if (self->mosi == NULL) mp_raise_ValueError(translate("No MOSI Pin")); + if (self->mosi == NULL) { + mp_raise_ValueError(translate("No MOSI Pin")); + } HAL_StatusTypeDef result = HAL_SPI_Transmit (&self->handle, (uint8_t *)data, (uint16_t)len, HAL_MAX_DELAY); return result == HAL_OK; } bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { - if (self->miso == NULL) mp_raise_ValueError(translate("No MISO Pin")); + if (self->miso == NULL) { + mp_raise_ValueError(translate("No MISO Pin")); + } HAL_StatusTypeDef result = HAL_SPI_Receive (&self->handle, data, (uint16_t)len, HAL_MAX_DELAY); return result == HAL_OK; } bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) { - if (self->miso == NULL) mp_raise_ValueError(translate("No MISO Pin")); - if (self->mosi == NULL) mp_raise_ValueError(translate("No MOSI Pin")); + if (self->miso == NULL || self->mosi == NULL) { + mp_raise_ValueError(translate("Missing MISO or MOSI Pin")); + } HAL_StatusTypeDef result = HAL_SPI_TransmitReceive (&self->handle, data_out, data_in, (uint16_t)len,HAL_MAX_DELAY); return result == HAL_OK; From b3fb0243011a2797ef41c3014c7fcdaca4331765 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 8 Jan 2020 10:06:55 -0600 Subject: [PATCH 303/531] nrf: Call into sd as many times as necessary to fill urandom request Generating 51200 bytes in one go takes 4.966s, so that's a rate of about 10KiB/s. --- ports/nrf/common-hal/os/__init__.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/os/__init__.c b/ports/nrf/common-hal/os/__init__.c index e38226f94e..1d89c73b62 100644 --- a/ports/nrf/common-hal/os/__init__.c +++ b/ports/nrf/common-hal/os/__init__.c @@ -31,6 +31,7 @@ #ifdef BLUETOOTH_SD #include "nrf_sdm.h" +#include "tick.h" #endif #include "nrf_rng.h" @@ -66,8 +67,25 @@ bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); - if (sd_en) - return NRF_SUCCESS == sd_rand_application_vector_get(buffer, length); + if (sd_en) { + while (length != 0) { + uint8_t available = 0; + sd_rand_application_bytes_available_get(&available); + if (available) { + uint32_t request = MIN(length, available); + uint32_t result = sd_rand_application_vector_get(buffer, request); + if (result != NRF_SUCCESS) { + return false; + } + buffer += request; + length -= request; + } else { + RUN_BACKGROUND_TASKS; + tick_delay(500); + } + } + return true; + } #endif nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); From b0f08ba465f2585d03e445b920a86ceda1a20ea5 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 8 Jan 2020 12:32:43 -0500 Subject: [PATCH 304/531] Close algorithm edge case to match SPI --- ports/stm32f4/common-hal/busio/I2C.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index d2292845ea..dc82c19a01 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -66,20 +66,26 @@ void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { } } - void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) { //match pins to I2C objects I2C_TypeDef * I2Cx; - uint8_t sda_len = sizeof(mcu_i2c_sda_list)/sizeof(*mcu_i2c_sda_list); uint8_t scl_len = sizeof(mcu_i2c_scl_list)/sizeof(*mcu_i2c_scl_list); + bool i2c_taken = false; + for(uint i=0; iscl = &mcu_i2c_scl_list[j]; self->sda = &mcu_i2c_sda_list[i]; break; @@ -92,11 +98,11 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if(self->sda!=NULL && self->scl!=NULL ) { I2Cx = mcu_i2c_banks[self->sda->i2c_index-1]; } else { - mp_raise_RuntimeError(translate("Invalid I2C pin selection")); - } - - if(reserved_i2c[self->sda->i2c_index-1]) { - mp_raise_RuntimeError(translate("Hardware busy, try alternative pins")); + if (i2c_taken) { + mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + } else { + mp_raise_ValueError(translate("Invalid I2C pin selection")); + } } //Start GPIO for each pin From 90613aa5fb97344004bd59601dde927d7804702b Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 8 Jan 2020 13:03:25 -0500 Subject: [PATCH 305/531] more cleanup and style syncing --- ports/stm32f4/common-hal/busio/I2C.c | 80 +++++++++++++++-------- ports/stm32f4/common-hal/busio/SPI.c | 62 ++++++++++-------- ports/stm32f4/common-hal/busio/UART.c | 22 +++++-- ports/stm32f4/common-hal/pulseio/PWMOut.c | 46 +++++++------ 4 files changed, 131 insertions(+), 79 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index dc82c19a01..4aff3b822c 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -35,35 +35,28 @@ #include "supervisor/shared/translate.h" #include "common-hal/microcontroller/Pin.h" -STATIC bool reserved_i2c[3]; -STATIC bool never_reset[3]; +#define MAX_I2C 3 +STATIC bool reserved_i2c[MAX_I2C]; +STATIC bool never_reset_i2c[MAX_I2C]; + +#define ALL_CLOCKS 0xFF +STATIC void i2c_clock_enable(uint8_t mask); +STATIC void i2c_clock_disable(uint8_t mask); + +//-------- +//COMMON HAL +//-------- void i2c_reset(void) { - //Note: I2Cs are also forcibly reset in construct, due to silicon error - #ifdef I2C1 - reserved_i2c[0] = false; - __HAL_RCC_I2C1_CLK_DISABLE(); - #endif - #ifdef I2C2 - reserved_i2c[1] = false; - __HAL_RCC_I2C2_CLK_DISABLE(); - #endif - #ifdef I2C3 - reserved_i2c[2] = false; - __HAL_RCC_I2C3_CLK_DISABLE(); - #endif -} - -void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { - for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) { - if (self->handle.Instance == mcu_i2c_banks[i]) { - never_reset[i] = true; - - never_reset_pin_number(self->scl->pin->port, self->scl->pin->number); - never_reset_pin_number(self->sda->pin->port, self->scl->pin->number); - break; + uint16_t never_reset_mask = 0x00; + for(int i=0;iscl = &mcu_i2c_scl_list[j]; self->sda = &mcu_i2c_sda_list[i]; break; @@ -176,6 +168,18 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, claim_pin(scl); } +void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { + for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) { + if (self->handle.Instance == mcu_i2c_banks[i]) { + never_reset[i] = true; + + never_reset_pin_number(self->scl->pin->port, self->scl->pin->number); + never_reset_pin_number(self->sda->pin->port, self->scl->pin->number); + break; + } + } +} + bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) { return self->sda->pin == mp_const_none; } @@ -252,3 +256,27 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { return HAL_I2C_Master_Receive(&(self->handle), (uint16_t)(addr<<1), data, (uint16_t)len, 500) == HAL_OK ? 0 : MP_EIO; } + +STATIC void i2c_clock_enable(uint8_t mask) { + #ifdef I2C1 + if (mask & 1<<0) __HAL_RCC_I2C1_CLK_ENABLE(); + #endif + #ifdef I2C2 + if (mask & 1<<1) __HAL_RCC_I2C2_CLK_ENABLE(); + #endif + #ifdef I2C3 + if (mask & 1<<2) __HAL_RCC_I2C3_CLK_ENABLE(); + #endif +} + +STATIC void i2c_clock_disable(uint8_t mask) { + #ifdef I2C1 + if (mask & 1<<0) __HAL_RCC_I2C1_CLK_DISABLE(); + #endif + #ifdef I2C2 + if (mask & 1<<1) __HAL_RCC_I2C2_CLK_DISABLE(); + #endif + #ifdef I2C3 + if (mask & 1<<2) __HAL_RCC_I2C3_CLK_DISABLE(); + #endif +} diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index 32089887f9..09d382bc0b 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -46,6 +46,10 @@ STATIC bool never_reset_spi[MAX_SPI]; STATIC void spi_clock_enable(uint8_t mask); STATIC void spi_clock_disable(uint8_t mask); +//-------- +//STATICS +//-------- + STATIC uint32_t get_busclock(SPI_TypeDef * instance) { //SPI2 and 3 are on PCLK1, if they exist. #ifdef SPI2 @@ -57,11 +61,41 @@ STATIC uint32_t get_busclock(SPI_TypeDef * instance) { return HAL_RCC_GetPCLK2Freq(); } +STATIC uint32_t stm32_baud_to_spi_div(uint32_t baudrate, uint16_t * prescaler, uint32_t busclock) { + static const uint32_t baud_map[8][2] = { + {2,SPI_BAUDRATEPRESCALER_2}, + {4,SPI_BAUDRATEPRESCALER_4}, + {8,SPI_BAUDRATEPRESCALER_8}, + {16,SPI_BAUDRATEPRESCALER_16}, + {32,SPI_BAUDRATEPRESCALER_32}, + {64,SPI_BAUDRATEPRESCALER_64}, + {128,SPI_BAUDRATEPRESCALER_128}, + {256,SPI_BAUDRATEPRESCALER_256} + }; + size_t i = 0; + uint16_t divisor; + do { + divisor = baud_map[i][0]; + if (baudrate >= (busclock/divisor)) { + *prescaler = divisor; + return baud_map[i][1]; + } + i++; + } while (divisor != 256); + //only gets here if requested baud is lower than minimum + *prescaler = 256; + return SPI_BAUDRATEPRESCALER_256; +} + +//-------- +//COMMON HAL +//-------- + void spi_reset(void) { uint16_t never_reset_mask = 0x00; for(int i=0;imiso = mp_const_none; } -STATIC uint32_t stm32_baud_to_spi_div(uint32_t baudrate, uint16_t * prescaler, uint32_t busclock) { - static const uint32_t baud_map[8][2] = { - {2,SPI_BAUDRATEPRESCALER_2}, - {4,SPI_BAUDRATEPRESCALER_4}, - {8,SPI_BAUDRATEPRESCALER_8}, - {16,SPI_BAUDRATEPRESCALER_16}, - {32,SPI_BAUDRATEPRESCALER_32}, - {64,SPI_BAUDRATEPRESCALER_64}, - {128,SPI_BAUDRATEPRESCALER_128}, - {256,SPI_BAUDRATEPRESCALER_256} - }; - size_t i = 0; - uint16_t divisor; - do { - divisor = baud_map[i][0]; - if (baudrate >= (busclock/divisor)) { - *prescaler = divisor; - return baud_map[i][1]; - } - i++; - } while (divisor != 256); - //only gets here if requested baud is lower than minimum - *prescaler = 256; - return SPI_BAUDRATEPRESCALER_256; -} - bool common_hal_busio_spi_configure(busio_spi_obj_t *self, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t bits) { //This resets the SPI, so check before updating it redundantly diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index aa792dae18..71867ac636 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -47,13 +47,9 @@ STATIC void uart_clock_enable(uint16_t mask); STATIC void uart_clock_disable(uint16_t mask); STATIC void uart_assign_irq(busio_uart_obj_t* self, USART_TypeDef* USARTx); -void uart_reset(void) { - for (uint8_t i = 0; i < MAX_UART; i++) { - reserved_uart[i] = false; - MP_STATE_PORT(cpy_uart_obj_all)[i] = NULL; - } - uart_clock_disable(ALL_UARTS); -} +//-------- +//STATICS +//-------- STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eval, int uart_index, bool uart_taken) { @@ -70,6 +66,18 @@ STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eva } } +//-------- +//COMMON HAL +//-------- + +void uart_reset(void) { + for (uint8_t i = 0; i < MAX_UART; i++) { + reserved_uart[i] = false; + MP_STATE_PORT(cpy_uart_obj_all)[i] = NULL; + } + uart_clock_disable(ALL_UARTS); +} + void common_hal_busio_uart_construct(busio_uart_obj_t* self, const mcu_pin_obj_t* tx, const mcu_pin_obj_t* rx, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 16b1b5b896..2a071d0784 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -44,6 +44,10 @@ STATIC bool never_reset_tim[TIM_BANK_ARRAY_LEN]; STATIC void tim_clock_enable(uint16_t mask); STATIC void tim_clock_disable(uint16_t mask); +//-------- +//STATICS +//-------- + // Get the frequency (in Hz) of the source clock for the given timer. // On STM32F405/407/415/417 there are 2 cases for how the clock freq is set. // If the APB prescaler is 1, then the timer clock is equal to its respective @@ -87,6 +91,10 @@ STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, } } +//-------- +//COMMON HAL +//-------- + void pwmout_reset(void) { uint16_t never_reset_mask = 0x00; for(int i=0;ihandle.Instance) { - never_reset_tim[i] = true; - never_reset_pin_number(self->tim->pin->port, self->tim->pin->number); - break; - } - } -} - -void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) { - for(size_t i = 0 ; i < TIM_BANK_ARRAY_LEN; i++) { - if (mcu_tim_banks[i] == self->handle.Instance) { - never_reset_tim[i] = false; - break; - } - } -} - pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, const mcu_pin_obj_t* pin, uint16_t duty, @@ -241,6 +230,25 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, return PWMOUT_OK; } +void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) { + for(size_t i = 0 ; i < TIM_BANK_ARRAY_LEN; i++) { + if (mcu_tim_banks[i] == self->handle.Instance) { + never_reset_tim[i] = true; + never_reset_pin_number(self->tim->pin->port, self->tim->pin->number); + break; + } + } +} + +void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) { + for(size_t i = 0 ; i < TIM_BANK_ARRAY_LEN; i++) { + if (mcu_tim_banks[i] == self->handle.Instance) { + never_reset_tim[i] = false; + break; + } + } +} + bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) { return self->tim == mp_const_none; } From 7a94940c89398ac8a68b988bad498955001783cd Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 8 Jan 2020 11:01:43 -0800 Subject: [PATCH 306/531] Replace magic number and add comment. --- ports/nrf/common-hal/_bleio/PacketBuffer.c | 6 +++++- ports/nrf/common-hal/_bleio/PacketBuffer.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c index fbcc72a6aa..27dacb4938 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.c +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c @@ -65,6 +65,10 @@ STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, uint8_t *data, uin } STATIC uint32_t queue_next_write(bleio_packet_buffer_obj_t *self) { + // Queue up the next outgoing buffer. We use two, one that has been passed to the SD for + // transmission (when packet_queued is true) and the other is `pending` and can still be + // modified. By primarily appending to the `pending` buffer we can reduce the protocol overhead + // of the lower level link and ATT layers. self->packet_queued = false; if (self->pending_size > 0) { uint16_t conn_handle = self->conn_handle; @@ -311,7 +315,7 @@ uint16_t common_hal_bleio_packet_buffer_get_packet_size(bleio_packet_buffer_obj_ } } if (connection->mtu == 0) { - mtu = 23; + mtu = BLE_GATT_ATT_MTU_DEFAULT; } if (self->characteristic->max_length > mtu) { mtu = self->characteristic->max_length; diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.h b/ports/nrf/common-hal/_bleio/PacketBuffer.h index 7a090f539c..cfccc852ed 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.h +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.h @@ -37,6 +37,8 @@ typedef struct { bleio_characteristic_obj_t *characteristic; // Ring buffer storing consecutive incoming values. ringbuf_t ringbuf; + // Two outgoing buffers to alternate between. One will be queued for transmission by the SD and + // the other is waiting to be queued and can be extended. uint8_t* outgoing[2]; uint16_t pending_size; uint16_t conn_handle; From 34c9e00f08b77f5336db911e376f15512bf0790b Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 8 Jan 2020 15:14:53 -0500 Subject: [PATCH 307/531] try (re)using the buffer in neopixel_write --- .../nrf/common-hal/neopixel_write/__init__.c | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index 3052e908dd..d097f96e3f 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -116,6 +116,8 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout uint32_t pattern_size = PATTERN_SIZE(numBytes); uint16_t* pixels_pattern = NULL; + static uint16_t* pixels_pattern_heap = NULL; + static size_t pixels_pattern_heap_size = 0; bool pattern_on_heap = false; // Use the stack to store 1 pixels worth of PWM data for the status led. uint32_t to ensure alignment. @@ -132,16 +134,29 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout } else { uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); - if (sd_en) { - // If the soft device is enabled then we must use PWM to - // transmit. This takes a bunch of memory to do so raise an - // exception if we can't. - pixels_pattern = (uint16_t *) m_malloc(pattern_size, false); - } else { - pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false); - } - pattern_on_heap = true; + if (!pattern_on_heap || pixels_pattern_heap_size < pattern_size) { + if (pattern_on_heap) { + m_free(pixels_pattern_heap); + pixels_pattern = NULL; + pixels_pattern_heap = NULL; + pixels_pattern_heap_size = 0; + } + + if (sd_en) { + // If the soft device is enabled then we must use PWM to + // transmit. This takes a bunch of memory to do so raise an + // exception if we can't. + pixels_pattern_heap = (uint16_t *) m_malloc(pattern_size, false); + } else { + pixels_pattern_heap = (uint16_t *) m_malloc_maybe(pattern_size, false); + } + if (pixels_pattern_heap) { + pattern_on_heap = true; + pixels_pattern_heap_size = pattern_size; + } + } + pixels_pattern = pixels_pattern_heap; } } @@ -223,10 +238,6 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout nrf_pwm_disable(pwm); nrf_pwm_pins_set(pwm, (uint32_t[]) {0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL} ); - if (pattern_on_heap) { - m_free(pixels_pattern); - } - } // End of DMA implementation // --------------------------------------------------------------------- else { From 4e040b01522ff955cc480489de74e784876680be Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 8 Jan 2020 15:15:27 -0500 Subject: [PATCH 308/531] add reset of heap to board reset for nrf port --- ports/nrf/common-hal/neopixel_write/__init__.c | 14 ++++++++++---- ports/nrf/supervisor/port.c | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index d097f96e3f..cf1b367057 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -97,6 +97,16 @@ static NRF_PWM_Type* find_free_pwm (void) { return NULL; } +static uint16_t* pixels_pattern_heap = NULL; +static size_t pixels_pattern_heap_size = 0; +static bool pattern_on_heap = false; +// Called during reset_port() to free the pattern buffer +void neopixel_write_reset(void) { + pixels_pattern_heap = NULL; + pixels_pattern_heap_size = 0; + pattern_on_heap = false; +} + uint64_t next_start_tick_ms = 0; uint32_t next_start_tick_us = 1000; @@ -113,12 +123,8 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // using DWT #define PATTERN_SIZE(numBytes) (numBytes * 8 * sizeof(uint16_t) + 2 * sizeof(uint16_t)) - uint32_t pattern_size = PATTERN_SIZE(numBytes); uint16_t* pixels_pattern = NULL; - static uint16_t* pixels_pattern_heap = NULL; - static size_t pixels_pattern_heap_size = 0; - bool pattern_on_heap = false; // Use the stack to store 1 pixels worth of PWM data for the status led. uint32_t to ensure alignment. // Make it at least as big as PATTERN_SIZE(3), for one pixel of RGB data. diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index af858aa4a1..d240e3be0d 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -47,6 +47,7 @@ #include "common-hal/pulseio/PulseOut.h" #include "common-hal/pulseio/PulseIn.h" #include "common-hal/rtc/RTC.h" +#include "common-hal/neopixel_write/__init__.h" #include "tick.h" #include "shared-bindings/rtc/__init__.h" @@ -106,6 +107,7 @@ void reset_port(void) { i2c_reset(); spi_reset(); uart_reset(); + neopixel_write_reset(); #if CIRCUITPY_AUDIOBUSIO i2s_reset(); From e1c1e32ceb002fb7b710344a9997f6e2a6f2398b Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 8 Jan 2020 15:17:54 -0500 Subject: [PATCH 309/531] address code review --- ports/nrf/common-hal/neopixel_write/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index cf1b367057..91c68556f5 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -141,7 +141,7 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); - if (!pattern_on_heap || pixels_pattern_heap_size < pattern_size) { + if (pixels_pattern_heap_size < pattern_size) { if (pattern_on_heap) { m_free(pixels_pattern_heap); pixels_pattern = NULL; From 1caf6bd8d3924b2f7861cd8b0af0d16a608bb736 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 8 Jan 2020 15:23:38 -0500 Subject: [PATCH 310/531] add missing .h file --- .../nrf/common-hal/neopixel_write/__init__.h | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ports/nrf/common-hal/neopixel_write/__init__.h diff --git a/ports/nrf/common-hal/neopixel_write/__init__.h b/ports/nrf/common-hal/neopixel_write/__init__.h new file mode 100644 index 0000000000..b8dce85adf --- /dev/null +++ b/ports/nrf/common-hal/neopixel_write/__init__.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_NEOPIXEL_WRITE_INIT_H +#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_NEOPIXEL_WRITE_INIT_H + +void neopixel_write_reset(void); + +#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_NEOPIXEL_WRITE_INIT_H \ No newline at end of file From a9633a3c948bdbfa2c43a67ffb7782236a0eda57 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 8 Jan 2020 15:33:35 -0500 Subject: [PATCH 311/531] Reorganize I2C workaround, style changes --- ports/stm32f4/common-hal/busio/I2C.c | 83 ++++++++++----------------- ports/stm32f4/common-hal/busio/SPI.c | 59 ++++++++++++------- ports/stm32f4/common-hal/busio/UART.c | 48 ++++++++++------ 3 files changed, 98 insertions(+), 92 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index 4aff3b822c..46c9728a8b 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -43,10 +43,6 @@ STATIC bool never_reset_i2c[MAX_I2C]; STATIC void i2c_clock_enable(uint8_t mask); STATIC void i2c_clock_disable(uint8_t mask); -//-------- -//COMMON HAL -//-------- - void i2c_reset(void) { uint16_t never_reset_mask = 0x00; for(int i=0;isda->i2c_index - 1)); + reserved_i2c[self->sda->i2c_index - 1] = true; + //Start GPIO for each pin GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = pin_mask(sda->number); @@ -113,9 +113,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, GPIO_InitStruct.Alternate = self->scl->altfn_index; HAL_GPIO_Init(pin_port(scl->port), &GPIO_InitStruct); - //Fix for HAL error caused by soft reboot GPIO init SDA pin voltage drop. See Eratta. - //Must be in this exact spot or I2C will get stuck in infinite loop. - //TODO: See git issue #2172 + //still needed? #ifdef I2C1 __HAL_RCC_I2C1_FORCE_RESET(); HAL_Delay(2); @@ -126,32 +124,12 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, HAL_Delay(2); __HAL_RCC_I2C2_RELEASE_RESET(); #endif - #ifdef I2C3 + #ifdef I2C2 __HAL_RCC_I2C3_FORCE_RESET(); HAL_Delay(2); __HAL_RCC_I2C3_RELEASE_RESET(); #endif - //Keep separate so above hack can be cleanly replaced - #ifdef I2C1 - if(I2Cx==I2C1) { - reserved_i2c[0] = true; - __HAL_RCC_I2C1_CLK_ENABLE(); - } - #endif - #ifdef I2C2 - if(I2Cx==I2C2) { - reserved_i2c[1] = true; - __HAL_RCC_I2C2_CLK_ENABLE(); - } - #endif - #ifdef I2C3 - if(I2Cx==I2C3) { - reserved_i2c[2] = true; - __HAL_RCC_I2C3_CLK_ENABLE(); - } - #endif - self->handle.Instance = I2Cx; self->handle.Init.ClockSpeed = 100000; self->handle.Init.DutyCycle = I2C_DUTYCYCLE_2; @@ -171,7 +149,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) { if (self->handle.Instance == mcu_i2c_banks[i]) { - never_reset[i] = true; + never_reset_i2c[i] = true; never_reset_pin_number(self->scl->pin->port, self->scl->pin->number); never_reset_pin_number(self->sda->pin->port, self->scl->pin->number); @@ -188,27 +166,11 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { if (common_hal_busio_i2c_deinited(self)) { return; } - #ifdef I2C1 - if(self->handle.Instance==I2C1) { - never_reset[0] = false; - reserved_i2c[0] = false; - __HAL_RCC_I2C1_CLK_DISABLE(); - } - #endif - #ifdef I2C2 - if(self->handle.Instance==I2C2) { - never_reset[1] = false; - reserved_i2c[1] = false; - __HAL_RCC_I2C2_CLK_DISABLE(); - } - #endif - #ifdef I2C3 - if(self->handle.Instance==I2C3) { - never_reset[2] = false; - reserved_i2c[2] = false; - __HAL_RCC_I2C3_CLK_DISABLE(); - } - #endif + + i2c_clock_disable(1<<(self->sda->i2c_index - 1)); + reserved_i2c[self->sda->i2c_index - 1] = false; + never_reset_i2c[self->sda->i2c_index - 1] = false; + reset_pin_number(self->sda->pin->port,self->sda->pin->number); reset_pin_number(self->scl->pin->port,self->scl->pin->number); self->sda = mp_const_none; @@ -258,14 +220,27 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, } STATIC void i2c_clock_enable(uint8_t mask) { + //Note: hard reset required due to soft reboot issue. #ifdef I2C1 - if (mask & 1<<0) __HAL_RCC_I2C1_CLK_ENABLE(); + if (mask & 1<<0) { + __HAL_RCC_I2C1_CLK_ENABLE(); + __HAL_RCC_I2C1_FORCE_RESET(); + __HAL_RCC_I2C1_RELEASE_RESET(); + } #endif #ifdef I2C2 - if (mask & 1<<1) __HAL_RCC_I2C2_CLK_ENABLE(); + if (mask & 1<<1) { + __HAL_RCC_I2C2_CLK_ENABLE(); + __HAL_RCC_I2C2_FORCE_RESET(); + __HAL_RCC_I2C2_RELEASE_RESET(); + } #endif #ifdef I2C3 - if (mask & 1<<2) __HAL_RCC_I2C3_CLK_ENABLE(); + if (mask & 1<<2) { + __HAL_RCC_I2C3_CLK_ENABLE(); + __HAL_RCC_I2C3_FORCE_RESET(); + __HAL_RCC_I2C3_RELEASE_RESET(); + } #endif } diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index 441b292963..0d1bcb168e 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -49,10 +49,6 @@ STATIC bool never_reset_spi[MAX_SPI]; STATIC void spi_clock_enable(uint8_t mask); STATIC void spi_clock_disable(uint8_t mask); -//-------- -//STATICS -//-------- - STATIC uint32_t get_busclock(SPI_TypeDef * instance) { //SPI2 and 3 are on PCLK1, if they exist. #ifdef SPI2 @@ -90,10 +86,6 @@ STATIC uint32_t stm32_baud_to_spi_div(uint32_t baudrate, uint16_t * prescaler, u return SPI_BAUDRATEPRESCALER_256; } -//-------- -//COMMON HAL -//-------- - void spi_reset(void) { uint16_t never_reset_mask = 0x00; for(int i=0;isck->spi_index - 1)); reserved_spi[self->sck->spi_index - 1] = false; never_reset_spi[self->sck->spi_index - 1] = false; @@ -399,42 +394,66 @@ uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) { STATIC void spi_clock_enable(uint8_t mask) { #ifdef SPI1 - if (mask & 1<<0) __HAL_RCC_SPI1_CLK_ENABLE(); + if (mask & 1<<0) { + __HAL_RCC_SPI1_CLK_ENABLE(); + } #endif #ifdef SPI2 - if (mask & 1<<1) __HAL_RCC_SPI2_CLK_ENABLE(); + if (mask & 1<<1) { + __HAL_RCC_SPI2_CLK_ENABLE(); + } #endif #ifdef SPI3 - if (mask & 1<<2) __HAL_RCC_SPI3_CLK_ENABLE(); + if (mask & 1<<2) { + __HAL_RCC_SPI3_CLK_ENABLE(); + } #endif #ifdef SPI4 - if (mask & 1<<3) __HAL_RCC_SPI4_CLK_ENABLE(); + if (mask & 1<<3) { + __HAL_RCC_SPI4_CLK_ENABLE(); + } #endif #ifdef SPI5 - if (mask & 1<<4) __HAL_RCC_SPI5_CLK_ENABLE(); + if (mask & 1<<4) { + __HAL_RCC_SPI5_CLK_ENABLE(); + } #endif #ifdef SPI6 - if (mask & 1<<5) __HAL_RCC_SPI6_CLK_ENABLE(); + if (mask & 1<<5) { + __HAL_RCC_SPI6_CLK_ENABLE(); + } #endif } STATIC void spi_clock_disable(uint8_t mask) { #ifdef SPI1 - if (mask & 1<<0) __HAL_RCC_SPI1_CLK_DISABLE(); + if (mask & 1<<0) { + __HAL_RCC_SPI1_CLK_DISABLE(); + } #endif #ifdef SPI2 - if (mask & 1<<1) __HAL_RCC_SPI2_CLK_DISABLE(); + if (mask & 1<<1) { + __HAL_RCC_SPI2_CLK_DISABLE(); + } #endif #ifdef SPI3 - if (mask & 1<<2) __HAL_RCC_SPI3_CLK_DISABLE(); + if (mask & 1<<2) { + __HAL_RCC_SPI3_CLK_DISABLE(); + } #endif #ifdef SPI4 - if (mask & 1<<3) __HAL_RCC_SPI4_CLK_DISABLE(); + if (mask & 1<<3) { + __HAL_RCC_SPI4_CLK_DISABLE(); + } #endif #ifdef SPI5 - if (mask & 1<<4) __HAL_RCC_SPI5_CLK_DISABLE(); + if (mask & 1<<4) { + __HAL_RCC_SPI5_CLK_DISABLE(); + } #endif #ifdef SPI6 - if (mask & 1<<5) __HAL_RCC_SPI6_CLK_DISABLE(); + if (mask & 1<<5) { + __HAL_RCC_SPI6_CLK_DISABLE(); + } #endif } diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index 71867ac636..44ef5efdd2 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -47,10 +47,6 @@ STATIC void uart_clock_enable(uint16_t mask); STATIC void uart_clock_disable(uint16_t mask); STATIC void uart_assign_irq(busio_uart_obj_t* self, USART_TypeDef* USARTx); -//-------- -//STATICS -//-------- - STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eval, int uart_index, bool uart_taken) { if (pin_eval) { @@ -66,10 +62,6 @@ STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eva } } -//-------- -//COMMON HAL -//-------- - void uart_reset(void) { for (uint8_t i = 0; i < MAX_UART; i++) { reserved_uart[i] = false; @@ -575,33 +567,53 @@ STATIC void uart_clock_disable(uint16_t mask) { STATIC void uart_assign_irq(busio_uart_obj_t *self, USART_TypeDef * USARTx) { #ifdef USART1 - if (USARTx == USART1) self->irq = USART1_IRQn; + if (USARTx == USART1) { + self->irq = USART1_IRQn; + } #endif #ifdef USART2 - if (USARTx == USART2) self->irq = USART2_IRQn; + if (USARTx == USART2) { + self->irq = USART2_IRQn; + } #endif #ifdef USART3 - if (USARTx == USART3) self->irq = USART3_IRQn; + if (USARTx == USART3) { + self->irq = USART3_IRQn; + } #endif #ifdef UART4 - if (USARTx == UART4) self->irq = UART4_IRQn; + if (USARTx == UART4) { + self->irq = UART4_IRQn; + } #endif #ifdef UART5 - if (USARTx == UART5) self->irq = UART5_IRQn; + if (USARTx == UART5) { + self->irq = UART5_IRQn; + } #endif #ifdef USART6 - if (USARTx == USART6) self->irq = USART6_IRQn; + if (USARTx == USART6) { + self->irq = USART6_IRQn; + } #endif #ifdef UART7 - if (USARTx == UART7) self->irq = UART7_IRQn; + if (USARTx == UART7) { + self->irq = UART7_IRQn; + } #endif #ifdef UART8 - if (USARTx == UART8) self->irq = UART8_IRQn; + if (USARTx == UART8) { + self->irq = UART8_IRQn; + } #endif #ifdef UART9 - if (USARTx == UART9) self->irq = UART9_IRQn; + if (USARTx == UART9) { + self->irq = UART9_IRQn; + } #endif #ifdef UART10 - if (USARTx == UART10) self->irq = UART10_IRQn; + if (USARTx == UART10) { + self->irq = UART10_IRQn; + } #endif } From ae22305869f382c8a1cc088fbf3cb12bcc2d5a6c Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 8 Jan 2020 15:55:53 -0500 Subject: [PATCH 312/531] Corrections to I2C, style --- ports/stm32f4/common-hal/busio/I2C.c | 25 ++---- ports/stm32f4/common-hal/busio/SPI.c | 5 +- ports/stm32f4/common-hal/busio/UART.c | 1 + ports/stm32f4/common-hal/pulseio/PWMOut.c | 104 +++++++++++++++------- 4 files changed, 80 insertions(+), 55 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index 46c9728a8b..37c13a9c4d 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -35,6 +35,7 @@ #include "supervisor/shared/translate.h" #include "common-hal/microcontroller/Pin.h" +//arrays use 0 based numbering: I2C1 is stored at index 0 #define MAX_I2C 3 STATIC bool reserved_i2c[MAX_I2C]; STATIC bool never_reset_i2c[MAX_I2C]; @@ -93,10 +94,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, } } - //Note: clock reset must be before GPIO init, due to I2C soft reboot issue - i2c_clock_enable(1<<(self->sda->i2c_index - 1)); - reserved_i2c[self->sda->i2c_index - 1] = true; - //Start GPIO for each pin GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = pin_mask(sda->number); @@ -113,22 +110,9 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, GPIO_InitStruct.Alternate = self->scl->altfn_index; HAL_GPIO_Init(pin_port(scl->port), &GPIO_InitStruct); - //still needed? - #ifdef I2C1 - __HAL_RCC_I2C1_FORCE_RESET(); - HAL_Delay(2); - __HAL_RCC_I2C1_RELEASE_RESET(); - #endif - #ifdef I2C2 - __HAL_RCC_I2C2_FORCE_RESET(); - HAL_Delay(2); - __HAL_RCC_I2C2_RELEASE_RESET(); - #endif - #ifdef I2C2 - __HAL_RCC_I2C3_FORCE_RESET(); - HAL_Delay(2); - __HAL_RCC_I2C3_RELEASE_RESET(); - #endif + //Note: clock reset must be before GPIO init, due to I2C soft reboot issue + i2c_clock_enable(1<<(self->sda->i2c_index - 1)); + reserved_i2c[self->sda->i2c_index - 1] = true; self->handle.Instance = I2Cx; self->handle.Init.ClockSpeed = 100000; @@ -139,6 +123,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, self->handle.Init.OwnAddress2 = 0; self->handle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; self->handle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; + self->handle.State = HAL_I2C_STATE_RESET; if(HAL_I2C_Init(&(self->handle)) != HAL_OK) { mp_raise_RuntimeError(translate("I2C Init Error")); } diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index 0d1bcb168e..78c6352636 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -39,13 +39,12 @@ // Note that any bugs introduced in this file can cause crashes at startup // for chips using external SPI flash. -#define MAX_SPI 6 //TODO; replace this as part of periph cleanup -#define ALL_CLOCKS 0xFF - //arrays use 0 based numbering: SPI1 is stored at index 0 +#define MAX_SPI 6 STATIC bool reserved_spi[MAX_SPI]; STATIC bool never_reset_spi[MAX_SPI]; +#define ALL_CLOCKS 0xFF STATIC void spi_clock_enable(uint8_t mask); STATIC void spi_clock_disable(uint8_t mask); diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index 44ef5efdd2..a3e2d96beb 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -40,6 +40,7 @@ #define ALL_UARTS 0xFFFF +//arrays use 0 based numbering: UART1 is stored at index 0 STATIC bool reserved_uart[MAX_UART]; int errflag; //Used to restart read halts diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 2a071d0784..309848236d 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -44,10 +44,6 @@ STATIC bool never_reset_tim[TIM_BANK_ARRAY_LEN]; STATIC void tim_clock_enable(uint16_t mask); STATIC void tim_clock_disable(uint16_t mask); -//-------- -//STATICS -//-------- - // Get the frequency (in Hz) of the source clock for the given timer. // On STM32F405/407/415/417 there are 2 cases for how the clock freq is set. // If the APB prescaler is 1, then the timer clock is equal to its respective @@ -91,10 +87,6 @@ STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, } } -//-------- -//COMMON HAL -//-------- - void pwmout_reset(void) { uint16_t never_reset_mask = 0x00; for(int i=0;i Date: Wed, 8 Jan 2020 15:58:20 -0500 Subject: [PATCH 313/531] text fix --- ports/stm32f4/common-hal/busio/I2C.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index 37c13a9c4d..68a27c673f 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -110,7 +110,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, GPIO_InitStruct.Alternate = self->scl->altfn_index; HAL_GPIO_Init(pin_port(scl->port), &GPIO_InitStruct); - //Note: clock reset must be before GPIO init, due to I2C soft reboot issue + //Note: due to I2C soft reboot issue, do not relocate clock init. i2c_clock_enable(1<<(self->sda->i2c_index - 1)); reserved_i2c[self->sda->i2c_index - 1] = true; From f1c2dee1c05227d63e3833cb10d6fe99b9bd5092 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 8 Jan 2020 16:36:43 -0600 Subject: [PATCH 314/531] style --- py/vstr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py/vstr.c b/py/vstr.c index 888f7069bb..91cd7f584f 100644 --- a/py/vstr.c +++ b/py/vstr.c @@ -50,8 +50,9 @@ void vstr_init(vstr_t *vstr, size_t alloc) { // Init the vstr so it allocs exactly enough ram to hold a null-terminated // string of the given length, and set the length. void vstr_init_len(vstr_t *vstr, size_t len) { - if(len == SIZE_MAX) + if(len == SIZE_MAX) { m_malloc_fail(len); + } vstr_init(vstr, len + 1); vstr->len = len; } From 10eed78dd8047f406d3be26f540e39eecba437c7 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 8 Jan 2020 17:37:20 -0500 Subject: [PATCH 315/531] use CFLAG to properly set define --- ports/stm32f4/mpconfigport.mk | 2 +- py/circuitpy_mpconfig.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk index 48bd3ad612..f214282cb8 100644 --- a/ports/stm32f4/mpconfigport.mk +++ b/ports/stm32f4/mpconfigport.mk @@ -69,7 +69,7 @@ ifndef CIRCUITPY_DISPLAYIO CIRCUITPY_DISPLAYIO = 1 endif -MICROPY_CPYTHON_COMPAT = 1 +CFLAGS += -DMICROPY_CPYTHON_COMPAT=1 #ifeq ($(MCU_SUB_VARIANT), stm32f412zx) #endif diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 8c7454cf26..5b705a0883 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -182,7 +182,10 @@ typedef long mp_off_t; // Remove some lesser-used functionality to make small builds fit. #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (CIRCUITPY_FULL_BUILD) -#define MICROPY_CPYTHON_COMPAT (CIRCUITPY_FULL_BUILD) +//TODO: replace this with a rework of the FULL_BUILD system +#if !defined(MICROPY_CPYTHON_COMPAT) + #define MICROPY_CPYTHON_COMPAT (CIRCUITPY_FULL_BUILD) +#endif #define MICROPY_MODULE_WEAK_LINKS (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD) From 1c6efb9e662fcfb59afa9cac6c562082248a7560 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 8 Jan 2020 16:48:17 -0600 Subject: [PATCH 316/531] os.urandom: remove unneeded sleep --- ports/nrf/common-hal/os/__init__.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ports/nrf/common-hal/os/__init__.c b/ports/nrf/common-hal/os/__init__.c index 1d89c73b62..b2ad00a5ca 100644 --- a/ports/nrf/common-hal/os/__init__.c +++ b/ports/nrf/common-hal/os/__init__.c @@ -31,7 +31,6 @@ #ifdef BLUETOOTH_SD #include "nrf_sdm.h" -#include "tick.h" #endif #include "nrf_rng.h" @@ -81,7 +80,6 @@ bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { length -= request; } else { RUN_BACKGROUND_TASKS; - tick_delay(500); } } return true; From 4ec588bb37f1f8a0ed2233863afa85b9f98768e2 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 9 Jan 2020 16:17:57 -0500 Subject: [PATCH 317/531] spacing changes and text fix --- ports/stm32f4/common-hal/busio/I2C.c | 46 ++++++++++------- ports/stm32f4/common-hal/busio/SPI.c | 34 ++++++------- ports/stm32f4/common-hal/busio/UART.c | 4 +- ports/stm32f4/common-hal/pulseio/PWMOut.c | 62 ++++++++++++----------- 4 files changed, 79 insertions(+), 67 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index 68a27c673f..bf843ff5cb 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -46,11 +46,11 @@ STATIC void i2c_clock_disable(uint8_t mask); void i2c_reset(void) { uint16_t never_reset_mask = 0x00; - for(int i=0;isda!=NULL && self->scl!=NULL ) { - I2Cx = mcu_i2c_banks[self->sda->i2c_index-1]; + if (self->sda != NULL && self->scl != NULL ) { + I2Cx = mcu_i2c_banks[self->sda->i2c_index - 1]; } else { if (i2c_taken) { mp_raise_ValueError(translate("Hardware busy, try alternative pins")); @@ -111,7 +111,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, HAL_GPIO_Init(pin_port(scl->port), &GPIO_InitStruct); //Note: due to I2C soft reboot issue, do not relocate clock init. - i2c_clock_enable(1<<(self->sda->i2c_index - 1)); + i2c_clock_enable(1 << (self->sda->i2c_index - 1)); reserved_i2c[self->sda->i2c_index - 1] = true; self->handle.Instance = I2Cx; @@ -124,7 +124,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, self->handle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; self->handle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; self->handle.State = HAL_I2C_STATE_RESET; - if(HAL_I2C_Init(&(self->handle)) != HAL_OK) { + if (HAL_I2C_Init(&(self->handle)) != HAL_OK) { mp_raise_RuntimeError(translate("I2C Init Error")); } claim_pin(sda); @@ -132,7 +132,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, } void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { - for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) { + for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) { if (self->handle.Instance == mcu_i2c_banks[i]) { never_reset_i2c[i] = true; @@ -152,7 +152,7 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { return; } - i2c_clock_disable(1<<(self->sda->i2c_index - 1)); + i2c_clock_disable(1 << (self->sda->i2c_index - 1)); reserved_i2c[self->sda->i2c_index - 1] = false; never_reset_i2c[self->sda->i2c_index - 1] = false; @@ -163,7 +163,7 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { } bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - return HAL_I2C_IsDeviceReady(&(self->handle), (uint16_t)(addr<<1),2,2) == HAL_OK; + return HAL_I2C_IsDeviceReady(&(self->handle), (uint16_t)(addr << 1), 2, 2) == HAL_OK; } bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) { @@ -195,13 +195,15 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { - HAL_StatusTypeDef result = HAL_I2C_Master_Transmit(&(self->handle), (uint16_t)(addr<<1), (uint8_t *)data, (uint16_t)len, 500); + HAL_StatusTypeDef result = HAL_I2C_Master_Transmit(&(self->handle), (uint16_t)(addr << 1), + (uint8_t *)data, (uint16_t)len, 500); return result == HAL_OK ? 0 : MP_EIO; } uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { - return HAL_I2C_Master_Receive(&(self->handle), (uint16_t)(addr<<1), data, (uint16_t)len, 500) == HAL_OK ? 0 : MP_EIO; + return HAL_I2C_Master_Receive(&(self->handle), (uint16_t)(addr<<1), data, (uint16_t)len, 500) + == HAL_OK ? 0 : MP_EIO; } STATIC void i2c_clock_enable(uint8_t mask) { @@ -231,12 +233,18 @@ STATIC void i2c_clock_enable(uint8_t mask) { STATIC void i2c_clock_disable(uint8_t mask) { #ifdef I2C1 - if (mask & 1<<0) __HAL_RCC_I2C1_CLK_DISABLE(); + if (mask & 1<<0) { + __HAL_RCC_I2C1_CLK_DISABLE(); + } #endif #ifdef I2C2 - if (mask & 1<<1) __HAL_RCC_I2C2_CLK_DISABLE(); + if (mask & 1<<1) { + __HAL_RCC_I2C2_CLK_DISABLE(); + } #endif #ifdef I2C3 - if (mask & 1<<2) __HAL_RCC_I2C3_CLK_DISABLE(); + if (mask & 1<<2) { + __HAL_RCC_I2C3_CLK_DISABLE(); + } #endif } diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index 78c6352636..b7d61fbf92 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -87,11 +87,11 @@ STATIC uint32_t stm32_baud_to_spi_div(uint32_t baudrate, uint16_t * prescaler, u void spi_reset(void) { uint16_t never_reset_mask = 0x00; - for(int i=0;isck!=NULL && self->mosi!=NULL && self->miso != NULL) || - (self->sck!=NULL && self->mosi!=NULL && miso == mp_const_none) || - (self->sck!=NULL && self->miso!=NULL && mosi == mp_const_none)) { - SPIx = mcu_spi_banks[self->sck->spi_index-1]; + if ( (self->sck != NULL && self->mosi != NULL && self->miso != NULL) || + (self->sck != NULL && self->mosi != NULL && miso == mp_const_none) || + (self->sck != NULL && self->miso != NULL && mosi == mp_const_none)) { + SPIx = mcu_spi_banks[self->sck->spi_index - 1]; } else { if (spi_taken) { mp_raise_ValueError(translate("Hardware busy, try alternative pins")); @@ -217,7 +217,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, HAL_GPIO_Init(pin_port(miso->port), &GPIO_InitStruct); } - spi_clock_enable(1<<(self->sck->spi_index - 1)); + spi_clock_enable(1 << (self->sck->spi_index - 1)); reserved_spi[self->sck->spi_index - 1] = true; self->handle.Instance = SPIx; @@ -237,7 +237,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, { mp_raise_ValueError(translate("SPI Init Error")); } - self->baudrate = (get_busclock(SPIx)/16); + self->baudrate = (get_busclock(SPIx) / 16); self->prescaler = 16; self->polarity = 0; self->phase = 0; @@ -253,7 +253,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, } void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { - for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_spi_banks); i++) { + for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_spi_banks); i++) { if (mcu_spi_banks[i] == self->handle.Instance) { never_reset_spi[i] = true; never_reset_pin_number(self->sck->pin->port, self->sck->pin->number); diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index a3e2d96beb..44139a642f 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -79,8 +79,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, //match pins to UART objects USART_TypeDef * USARTx; - uint8_t tx_len = sizeof(mcu_uart_tx_list)/sizeof(*mcu_uart_tx_list); - uint8_t rx_len = sizeof(mcu_uart_rx_list)/sizeof(*mcu_uart_rx_list); + uint8_t tx_len = sizeof(mcu_uart_tx_list) / sizeof(*mcu_uart_tx_list); + uint8_t rx_len = sizeof(mcu_uart_rx_list) / sizeof(*mcu_uart_rx_list); bool uart_taken = false; uint8_t uart_index = 0; //origin 0 corrected diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 309848236d..a53bfc4231 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -69,15 +69,15 @@ STATIC uint32_t timer_get_source_freq(uint32_t tim_id) { STATIC uint32_t timer_get_internal_duty(uint16_t duty, uint32_t period) { //duty cycle is duty/0xFFFF fraction x (number of pulses per period) - return (duty*period)/((1<<16)-1); + return (duty*period) / ((1 << 16) - 1); } STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, uint32_t frequency, uint32_t source_freq) { //Find the largest possible period supported by this frequency - for (int i=0; i<(1 << 16);i++) { - *period = source_freq/(i*frequency); - if (*period < (1 << 16) && *period>=2) { + for (int i = 0; i < (1 << 16); i++) { + *period = source_freq / (i * frequency); + if (*period < (1 << 16) && *period >= 2) { *prescaler = i; break; } @@ -89,12 +89,12 @@ STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, void pwmout_reset(void) { uint16_t never_reset_mask = 0x00; - for(int i=0;itim!=NULL) { + if (self->tim != NULL) { //create instance - TIMx = mcu_tim_banks[self->tim->tim_index-1]; + TIMx = mcu_tim_banks[self->tim->tim_index - 1]; //reserve timer/channel if (variable_frequency) { - reserved_tim[self->tim->tim_index-1] = 0x0F; + reserved_tim[self->tim->tim_index - 1] = 0x0F; } else { - reserved_tim[self->tim->tim_index-1] |= 1<<(self->tim->channel_index-1); + reserved_tim[self->tim->tim_index - 1] |= 1 << (self->tim->channel_index - 1); } - tim_frequencies[self->tim->tim_index-1] = frequency; + tim_frequencies[self->tim->tim_index - 1] = frequency; } else { //no match found if (tim_chan_taken) { mp_raise_ValueError(translate("No more timers available on this pin.")); } else if (tim_taken_f_mismatch) { - mp_raise_ValueError(translate("Frequency must be the same as as the existing PWMOut using this timer")); + mp_raise_ValueError(translate("Frequency must match existing PWMOut using this timer")); } else if (var_freq_mismatch) { mp_raise_ValueError(translate("Cannot vary frequency on a timer that is already in use")); } else { @@ -175,14 +175,15 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, GPIO_InitStruct.Alternate = self->tim->altfn_index; HAL_GPIO_Init(pin_port(pin->port), &GPIO_InitStruct); - tim_clock_enable(1<<(self->tim->tim_index - 1)); + tim_clock_enable(1 << (self->tim->tim_index - 1)); //translate channel into handle value self->channel = 4 * (self->tim->channel_index - 1); uint32_t prescaler = 0; //prescaler is 15 bit uint32_t period = 0; //period is 16 bit - timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index)); + timer_get_optimal_divisors(&period, &prescaler, frequency, + timer_get_source_freq(self->tim->tim_index)); //Timer init self->handle.Instance = TIMx; @@ -223,7 +224,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, } void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) { - for(size_t i = 0 ; i < TIM_BANK_ARRAY_LEN; i++) { + for (size_t i = 0; i < TIM_BANK_ARRAY_LEN; i++) { if (mcu_tim_banks[i] == self->handle.Instance) { never_reset_tim[i] = true; never_reset_pin_number(self->tim->pin->port, self->tim->pin->number); @@ -233,7 +234,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) { } void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) { - for(size_t i = 0 ; i < TIM_BANK_ARRAY_LEN; i++) { + for(size_t i = 0; i < TIM_BANK_ARRAY_LEN; i++) { if (mcu_tim_banks[i] == self->handle.Instance) { never_reset_tim[i] = false; break; @@ -251,18 +252,18 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { } //var freq shuts down entire timer, others just their channel if (self->variable_frequency) { - reserved_tim[self->tim->tim_index-1] = 0x00; + reserved_tim[self->tim->tim_index - 1] = 0x00; } else { - reserved_tim[self->tim->tim_index-1] &= ~(1<tim->channel_index); + reserved_tim[self->tim->tim_index - 1] &= ~(1 << self->tim->channel_index); HAL_TIM_PWM_Stop(&self->handle, self->channel); } reset_pin_number(self->tim->pin->port,self->tim->pin->number); self->tim = mp_const_none; //if reserved timer has no active channels, we can disable it - if (!reserved_tim[self->tim->tim_index-1]) { - tim_frequencies[self->tim->tim_index-1] = 0x00; - tim_clock_disable(1<<(self->tim->tim_index-1)); + if (!reserved_tim[self->tim->tim_index - 1]) { + tim_frequencies[self->tim->tim_index - 1] = 0x00; + tim_clock_disable(1 << (self->tim->tim_index - 1)); } } @@ -278,11 +279,14 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) { void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) { //don't halt setup for the same frequency - if (frequency == self->frequency) return; + if (frequency == self->frequency) { + return; + } uint32_t prescaler = 0; uint32_t period = 0; - timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index)); + timer_get_optimal_divisors(&period, &prescaler, frequency, + timer_get_source_freq(self->tim->tim_index)); //shut down HAL_TIM_PWM_Stop(&self->handle, self->channel); @@ -305,7 +309,7 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_ mp_raise_ValueError(translate("Could not restart PWM")); } - tim_frequencies[self->tim->tim_index-1] = frequency; + tim_frequencies[self->tim->tim_index - 1] = frequency; self->frequency = frequency; self->period = period; } From 189f2d5f077cd4c30e6ad0fe6033869b580ea9a6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Jan 2020 17:31:50 -0500 Subject: [PATCH 318/531] Make requiring I2C pullups be optional --- ports/atmel-samd/common-hal/busio/I2C.c | 3 +++ ports/nrf/common-hal/busio/I2C.c | 2 ++ py/circuitpy_mpconfig.mk | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index b0e5714a79..ffe74a2743 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -76,6 +76,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, mp_raise_ValueError(translate("Invalid pins")); } +#if CIRCUITPY_REQUIRE_I2C_PULLUPS // Test that the pins are in a high state. (Hopefully indicating they are pulled up.) gpio_set_pin_function(sda->number, GPIO_PIN_FUNCTION_OFF); gpio_set_pin_function(scl->number, GPIO_PIN_FUNCTION_OFF); @@ -98,6 +99,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, reset_pin_number(scl->number); mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); } +#endif + gpio_set_pin_function(sda->number, sda_pinmux); gpio_set_pin_function(scl->number, scl_pinmux); diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index f6f686cdfe..219fbf4470 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -115,6 +115,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * mp_raise_ValueError(translate("All I2C peripherals are in use")); } +#if CIRCUITPY_REQUIRE_I2C_PULLUPS // Test that the pins are in a high state. (Hopefully indicating they are pulled up.) nrf_gpio_cfg_input(scl->number, NRF_GPIO_PIN_PULLDOWN); nrf_gpio_cfg_input(sda->number, NRF_GPIO_PIN_PULLDOWN); @@ -132,6 +133,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * reset_pin_number(scl->number); mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); } +#endif nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG(scl->number, sda->number); diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index a464583f32..93175e136f 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -310,6 +310,13 @@ CIRCUITPY_BITBANG_APA102 = 0 endif CFLAGS += -DCIRCUITPY_BITBANG_APA102=$(CIRCUITPY_BITBANG_APA102) +# Should busio.I2C() check for pullups? +# Some boards in combination with certain peripherals may not want this. +ifndef CIRCUITPY_REQUIRE_I2C_PULLUPS +CIRCUITPY_REQUIRE_I2C_PULLUPS = 1 +endif +CFLAGS += -DCIRCUITPY_REQUIRE_I2C_PULLUPS=$(CIRCUITPY_REQUIRE_I2C_PULLUPS) + # REPL over BLE ifndef CIRCUITPY_SERIAL_BLE CIRCUITPY_SERIAL_BLE = 0 From 9c167af17a4dd8670a457ab25bda4bba1d9eaa6e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Jan 2020 17:40:02 -0500 Subject: [PATCH 319/531] wip; redid flash writing to be compatible with SD --- ports/nrf/common-hal/_bleio/Adapter.c | 1 - ports/nrf/common-hal/_bleio/Characteristic.c | 8 ++- ports/nrf/common-hal/_bleio/Characteristic.h | 1 + ports/nrf/common-hal/_bleio/__init__.c | 1 + ports/nrf/common-hal/_bleio/bonding.c | 34 +++++++----- ports/nrf/peripherals/nrf/nvm.c | 45 +++++++++++++--- ports/nrf/peripherals/nrf/nvm.h | 5 ++ ports/nrf/sd.c | 54 ++++++++++++++++++++ ports/nrf/sd.h | 46 +++++++++++++++++ shared-bindings/_bleio/Characteristic.c | 12 ++++- shared-bindings/_bleio/Characteristic.h | 1 + 11 files changed, 185 insertions(+), 23 deletions(-) create mode 100644 ports/nrf/sd.c create mode 100644 ports/nrf/sd.h diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 12d5090737..05cd0260b2 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -670,5 +670,4 @@ void bleio_adapter_reset(bleio_adapter_obj_t* adapter) { bleio_connection_internal_t *connection = &connections[i]; connection->connection_obj = mp_const_none; } - bonding_reset(); } diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index 81639898fc..a87cd6e186 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -133,7 +133,8 @@ void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, common_hal_bleio_characteristic_set_value(self, initial_value_bufinfo); } - ble_drv_add_event_handler(characteristic_on_ble_evt, self); + self->handler_entry.next = NULL; +//////////////// ble_drv_add_event_handler_entry(&self->handler_entry, characteristic_on_ble_evt, self); } bleio_descriptor_obj_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self) { @@ -287,3 +288,8 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, } } + +void common_hal_bleio_characteristic_del(bleio_characteristic_obj_t *self) { + // Remove from event handler list, since the evt handler entry is built-in and not a heap object. + ble_drv_remove_event_handler(characteristic_on_ble_evt, self); +} diff --git a/ports/nrf/common-hal/_bleio/Characteristic.h b/ports/nrf/common-hal/_bleio/Characteristic.h index bb8f28495e..5759321aa2 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.h +++ b/ports/nrf/common-hal/_bleio/Characteristic.h @@ -47,6 +47,7 @@ typedef struct _bleio_characteristic_obj { bleio_attribute_security_mode_t read_perm; bleio_attribute_security_mode_t write_perm; bleio_descriptor_obj_t *descriptor_list; + ble_drv_evt_handler_entry_t handler_entry; uint16_t user_desc_handle; uint16_t cccd_handle; uint16_t sccd_handle; diff --git a/ports/nrf/common-hal/_bleio/__init__.c b/ports/nrf/common-hal/_bleio/__init__.c index 4b2780dedc..b9fbaa7c33 100644 --- a/ports/nrf/common-hal/_bleio/__init__.c +++ b/ports/nrf/common-hal/_bleio/__init__.c @@ -94,6 +94,7 @@ void bleio_reset() { common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false); } supervisor_start_bluetooth(); + bonding_reset(); } // The singleton _bleio.Adapter object, bound to _bleio.adapter diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c index 1675ade43d..1175f72e47 100644 --- a/ports/nrf/common-hal/_bleio/bonding.c +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -34,7 +34,7 @@ #include "shared-bindings/_bleio/Adapter.h" #include "shared-bindings/nvm/ByteArray.h" -#include "nrf_nvmc.h" +#include "nrf_soc.h" #include "sd_mutex.h" #include "bonding.h" @@ -68,15 +68,17 @@ STATIC inline size_t compute_block_size(uint16_t data_length) { STATIC void erase_bonding_storage(void) { // Erase all pages in the bonding area. - BONDING_DEBUG_PRINTF("erase_bonding_storage()\n"); for(uint32_t page_address = BONDING_PAGES_START_ADDR; page_address < BONDING_PAGES_END_ADDR; page_address += FLASH_PAGE_SIZE) { - nrf_nvmc_page_erase(page_address); + // Argument is page number, not address. + sd_flash_page_erase_sync(page_address / FLASH_PAGE_SIZE); } // Write marker words at the beginning and the end of the bonding area. - nrf_nvmc_write_word(BONDING_DATA_START_ADDR, BONDING_START_FLAG_ADDR); - nrf_nvmc_write_word(BONDING_DATA_END_ADDR, BONDING_END_FLAG_ADDR); + uint32_t flag = BONDING_START_FLAG; + sd_flash_write_sync((uint32_t *) BONDING_DATA_START_ADDR, &flag, 1); + flag = BONDING_END_FLAG; + sd_flash_write_sync((uint32_t *) BONDING_DATA_END_ADDR, &flag, 1); // First unused block is at the beginning. bonding_unused_block = (bonding_block_t *) BONDING_DATA_START_ADDR; } @@ -135,7 +137,8 @@ STATIC bonding_block_t *find_block(bool is_central, bonding_block_type_t type, u // We don't change data_length, so we can still skip over this block. STATIC void invalidate_block(bonding_block_t *block) { BONDING_DEBUG_PRINTF("invalidate_block()\n"); - nrf_nvmc_write_word((uint32_t) block, 0x00000000); + uint32_t zero = 0; + sd_flash_write_sync((uint32_t *) block, &zero, 1); } STATIC void queue_write_block(bool is_central, bonding_block_type_t type, uint16_t ediv, uint16_t conn_handle, uint8_t *data, uint16_t data_length) { @@ -178,7 +181,7 @@ STATIC void write_block_header(bonding_block_t *block) { erase_bonding_storage(); } - nrf_nvmc_write_words((uint32_t) bonding_unused_block, (uint32_t *) block, sizeof(bonding_block_t) / 4); + sd_flash_write_sync((uint32_t *) bonding_unused_block, (uint32_t *) block, sizeof(bonding_block_t) / 4); } // Write variable-length data at end of bonding block. @@ -190,7 +193,7 @@ STATIC void write_block_data(uint8_t *data, uint16_t data_length) { while (1) { uint32_t word = 0xffffffff; memcpy(&word, data, data_length >= 4 ? 4 : data_length); - nrf_nvmc_write_word((uint32_t) flash_word_p, word); + sd_flash_write_sync(flash_word_p, &word, 1); if (data_length <= 4) { break; } @@ -242,8 +245,9 @@ void bonding_clear_keys(bonding_keys_t *bonding_keys) { memset((uint8_t*) bonding_keys, 0, sizeof(bonding_keys_t)); } +// Call only when SD is enabled. void bonding_reset(void) { - BONDING_DEBUG_PRINTF("bonding_reset()\n"); + MP_STATE_VM(queued_bonding_block_list) = NULL; sd_mutex_new(&queued_bonding_block_list_mutex); if (BONDING_START_FLAG != *((uint32_t *) BONDING_START_FLAG_ADDR) || BONDING_END_FLAG != *((uint32_t *) BONDING_END_FLAG_ADDR)) { @@ -256,18 +260,20 @@ void bonding_reset(void) { // Write bonding blocks to flash. These have been queued during event handlers. // We do one at a time, on each background call. void bonding_background(void) { - + uint8_t sd_en = 0; + (void) sd_softdevice_is_enabled(&sd_en); + if (!sd_en) { + return; + } // Get block at front of list. sd_mutex_acquire_wait(&queued_bonding_block_list_mutex); - bonding_block_t *block = &(MP_STATE_VM(queued_bonding_block_list)->bonding_block); + bonding_block_t *block = (bonding_block_t *) MP_STATE_VM(queued_bonding_block_list); if (block) { - // Remove written block from front of list. + // Remove block from list. MP_STATE_VM(queued_bonding_block_list) = MP_STATE_VM(queued_bonding_block_list)->next_queued_block; } sd_mutex_release(&queued_bonding_block_list_mutex); - if (!block) { - // No blocks in queue. return; } diff --git a/ports/nrf/peripherals/nrf/nvm.c b/ports/nrf/peripherals/nrf/nvm.c index d13775d4dd..2417ec66a9 100644 --- a/ports/nrf/peripherals/nrf/nvm.c +++ b/ports/nrf/peripherals/nrf/nvm.c @@ -38,29 +38,62 @@ #include "ble_drv.h" #include "nrf_sdm.h" +STATIC bool sd_is_enabled(void) { + uint8_t sd_en = 0; + (void) sd_softdevice_is_enabled(&sd_en); + return sd_en; +} + STATIC void sd_flash_operation_start(void) { sd_flash_operation_status = SD_FLASH_OPERATION_IN_PROGRESS; } STATIC sd_flash_operation_status_t sd_flash_operation_wait_until_done(void) { - while (sd_flash_operation_status == SD_FLASH_OPERATION_IN_PROGRESS) { - sd_app_evt_wait(); + // If the SD is not enabled, no events are generated, so just return immediately. + if (sd_is_enabled()) { + while (sd_flash_operation_status == SD_FLASH_OPERATION_IN_PROGRESS) { + sd_app_evt_wait(); + } + } else { + sd_flash_operation_status = SD_FLASH_OPERATION_DONE; } return sd_flash_operation_status; + } + +bool sd_flash_page_erase_sync(uint32_t page_number) { + sd_flash_operation_start(); + if (sd_flash_page_erase(page_number) != NRF_SUCCESS) { + return false; + } + if (sd_flash_operation_wait_until_done() == SD_FLASH_OPERATION_ERROR) { + return false; + } + return true; +} + +bool sd_flash_write_sync(uint32_t *dest_words, uint32_t* src_words, uint32_t num_words) { + sd_flash_operation_start(); + if (sd_flash_write(dest_words, src_words, num_words) != NRF_SUCCESS) { + return false; + } + if (sd_flash_operation_wait_until_done() == SD_FLASH_OPERATION_ERROR) { + return false; + } + return true; +} + #endif // The nRF52840 datasheet specifies a maximum of two writes to a flash // location before an erase is necessary, even if the write is all // ones (erased state). So we can't avoid erases even if the page // appears to be already erased (all ones), unless we keep track of -// writes to a page. +// writes to a page.g bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { #ifdef BLUETOOTH_SD - uint8_t sd_en = 0; - (void) sd_softdevice_is_enabled(&sd_en); - if (sd_en) { + if (sd_is_enabled()) { uint32_t err_code; sd_flash_operation_status_t status; diff --git a/ports/nrf/peripherals/nrf/nvm.h b/ports/nrf/peripherals/nrf/nvm.h index e54e953dfc..8ba95773d6 100644 --- a/ports/nrf/peripherals/nrf/nvm.h +++ b/ports/nrf/peripherals/nrf/nvm.h @@ -27,4 +27,9 @@ #define FLASH_PAGE_SIZE (4096) +#if BLUETOOTH_SD +bool sd_flash_page_erase_sync(uint32_t page_number); +bool sd_flash_write_sync(uint32_t *dest_words, uint32_t* src_words, uint32_t num_words); +#endif + bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data); diff --git a/ports/nrf/sd.c b/ports/nrf/sd.c new file mode 100644 index 0000000000..b3162e6af9 --- /dev/null +++ b/ports/nrf/sd.c @@ -0,0 +1,54 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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. + */ + +#include "py/mpconfig.h" +#include "py/runtime.h" +#include "nrf_soc.h" + +void sd_mutex_acquire_check(nrf_mutex_t* p_mutex) { + uint32_t err_code = sd_mutex_acquire(p_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to acquire mutex, err 0x%04x"), err_code); + } +} + +void sd_mutex_acquire_wait(nrf_mutex_t* p_mutex) { + while (sd_mutex_acquire(p_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { + RUN_BACKGROUND_TASKS; + } +} + +void sd_mutex_acquire_wait_no_vm(nrf_mutex_t* p_mutex) { + while (sd_mutex_acquire(p_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { + } +} + +void sd_mutex_release_check(nrf_mutex_t* p_mutex) { + uint32_t err_code = sd_mutex_release(p_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to release mutex, err 0x%04x"), err_code); + } +} diff --git a/ports/nrf/sd.h b/ports/nrf/sd.h new file mode 100644 index 0000000000..ca46917205 --- /dev/null +++ b/ports/nrf/sd.h @@ -0,0 +1,46 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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. + */ + +#ifndef MICROPY_INCLUDED_NRF_SD_MUTEX_H +#define MICROPY_INCLUDED_NRF_SD_MUTEX_H + +#include "nrf_soc.h" + +// Helpers for common usage of nrf_mutex. + +// Try to acquire a mutex right now. Raise exception if we can't get it. +void sd_mutex_acquire_check(nrf_mutex_t* p_mutex); + +// Wait for a mutex to become available. Run VM background tasks while waiting. +void sd_mutex_acquire_wait(nrf_mutex_t* p_mutex); + +// Wait for a mutex to become available.. Block VM while waiting. +void sd_mutex_acquire_wait_no_vm(nrf_mutex_t* p_mutex); + +// Release a mutex, and raise exception on error. +void sd_mutex_release_check(nrf_mutex_t* p_mutex); + +#endif // MICROPY_INCLUDED_NRF_SD_MUTEX_H diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 7fcf274da0..0434368f24 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -128,7 +128,8 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ } mp_get_buffer_raise(initial_value, &initial_value_bufinfo, MP_BUFFER_READ); - bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); + // There may be some cleanup needed when a characteristic is gc'd, so enable finaliser. + bleio_characteristic_obj_t *characteristic = m_new_obj_with_finaliser(bleio_characteristic_obj_t); characteristic->base.type = &bleio_characteristic_type; // Range checking on max_length arg is done by the common_hal layer, because @@ -292,8 +293,17 @@ STATIC mp_obj_t bleio_characteristic_set_cccd(mp_uint_t n_args, const mp_obj_t * } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_set_cccd_obj, 1, bleio_characteristic_set_cccd); +// Cleanup on gc. +STATIC mp_obj_t bleio_characteristic_del(mp_obj_t self_in) { + bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_bleio_characteristic_del(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_del_obj, bleio_characteristic_del); + STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&bleio_characteristic_del_obj) }, { MP_ROM_QSTR(MP_QSTR_add_to_service), MP_ROM_PTR(&bleio_characteristic_add_to_service_obj) }, { MP_ROM_QSTR(MP_QSTR_properties), MP_ROM_PTR(&bleio_characteristic_properties_obj) }, { MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_characteristic_uuid_obj) }, diff --git a/shared-bindings/_bleio/Characteristic.h b/shared-bindings/_bleio/Characteristic.h index c4356fd4b9..60ab575724 100644 --- a/shared-bindings/_bleio/Characteristic.h +++ b/shared-bindings/_bleio/Characteristic.h @@ -45,5 +45,6 @@ extern bleio_descriptor_obj_t *common_hal_bleio_characteristic_get_descriptor_li extern bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self); extern void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor); extern void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate); +extern void common_hal_bleio_characteristic_del(bleio_characteristic_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H From 2cb8f7b2df2583c9fdb545744adad2386b4ee7f3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 9 Jan 2020 20:13:53 -0500 Subject: [PATCH 320/531] Add test for issue #2465 - tuple subsclass subscript --- tests/basics/subscr_tuple.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/basics/subscr_tuple.py diff --git a/tests/basics/subscr_tuple.py b/tests/basics/subscr_tuple.py new file mode 100644 index 0000000000..85d25366da --- /dev/null +++ b/tests/basics/subscr_tuple.py @@ -0,0 +1,7 @@ +# subscripting a subclassed tuple +class Foo(tuple): + pass + +foo = Foo((1,2)) +foo[0] + From 357506dd9a66060a497d4b38d916511cb1524a57 Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Fri, 10 Jan 2020 13:59:10 +0100 Subject: [PATCH 321/531] Fix board_timerhook --- ports/cxd56/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/cxd56/Makefile b/ports/cxd56/Makefile index d65c2e2666..3355332a81 100644 --- a/ports/cxd56/Makefile +++ b/ports/cxd56/Makefile @@ -131,6 +131,7 @@ LDFLAGS = \ -o $(BUILD)/firmware.elf \ --start-group \ -u spresense_main \ + -u board_timerhook \ $(BUILD)/libmpy.a \ $(SPRESENSE_SDK)/sdk/libs/libapps.a \ $(SPRESENSE_SDK)/sdk/libs/libsdk.a \ From 360c876be406eb039c995e0b31d1c4ebe5e70323 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 10 Jan 2020 09:20:21 -0500 Subject: [PATCH 322/531] add flag to i.mx port --- ports/mimxrt10xx/common-hal/busio/I2C.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.c b/ports/mimxrt10xx/common-hal/busio/I2C.c index 3c555df451..2de996f9a0 100644 --- a/ports/mimxrt10xx/common-hal/busio/I2C.c +++ b/ports/mimxrt10xx/common-hal/busio/I2C.c @@ -98,11 +98,13 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, LPI2C_MasterInit(self->i2c, &config, I2C_CLOCK_FREQ); +#if CIRCUITPY_REQUIRE_I2C_PULLUPS // if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) { // reset_pin_number(sda->number); // reset_pin_number(scl->number); // mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); // } +#endif claim_pin(self->sda_pin->pin); claim_pin(self->scl_pin->pin); From 1229de44995fe25d78b3eb3885f6d9ccfce078d9 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 10 Jan 2020 12:56:22 -0500 Subject: [PATCH 323/531] attempt to get control going again --- .../stm32f4/boards/meowbit_v121/mpconfigboard.h | 8 ++++---- .../stm32f4/boards/meowbit_v121/mpconfigboard.mk | 16 +++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 0371685d8b..e97d793bed 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -39,7 +39,7 @@ #define BOARD_NO_VBUS_SENSE // On-board flash -#define SPI_FLASH_MOSI_PIN (&pin_PB15) -#define SPI_FLASH_MISO_PIN (&pin_PB14) -#define SPI_FLASH_SCK_PIN (&pin_PB13) -#define SPI_FLASH_CS_PIN (&pin_PB01) +// #define SPI_FLASH_MOSI_PIN (&pin_PB15) +// #define SPI_FLASH_MISO_PIN (&pin_PB14) +// #define SPI_FLASH_SCK_PIN (&pin_PB13) +// #define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 73f1d722af..fc9209d15d 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -4,13 +4,13 @@ USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" USB_DEVICES = "CDC,MSC" -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ -LONGINT_IMPL = MPZ +# SPI_FLASH_FILESYSTEM = 1 +# EXTERNAL_FLASH_DEVICE_COUNT = 1 +# EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ +# LONGINT_IMPL = MPZ -# INTERNAL_FLASH_FILESYSTEM = 1 -# LONGINT_IMPL = NONE +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 @@ -18,6 +18,4 @@ MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE # LD_FILE = boards/STM32F401_boot.ld -LD_FILE = boards/STM32F401_fs.ld -TEXT0_ADDR = 0x08010000 -TEXT1_ADDR = 0x08040000 \ No newline at end of file +LD_FILE = boards/STM32F401_fs.ld \ No newline at end of file From 346ce3b73b532d2776e660e0e92c5d79c699880e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 10 Jan 2020 23:55:45 -0500 Subject: [PATCH 324/531] wip: HID bonding works! --- ports/nrf/common-hal/_bleio/Adapter.c | 5 + ports/nrf/common-hal/_bleio/Connection.c | 44 +++++-- ports/nrf/common-hal/_bleio/bonding.c | 160 +++++++++++++---------- ports/nrf/common-hal/_bleio/bonding.h | 13 +- ports/nrf/mpconfigport.h | 2 +- shared-bindings/_bleio/Adapter.c | 25 +++- shared-bindings/_bleio/Adapter.h | 14 +- 7 files changed, 171 insertions(+), 92 deletions(-) diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 05cd0260b2..8c732e73be 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -224,6 +224,7 @@ STATIC bool adapter_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } ble_drv_remove_event_handler(connection_on_ble_evt, connection); connection->conn_handle = BLE_CONN_HANDLE_INVALID; + connection->pair_status = PAIR_NOT_PAIRED; if (connection->connection_obj != mp_const_none) { bleio_connection_obj_t* obj = connection->connection_obj; obj->connection = NULL; @@ -657,6 +658,10 @@ mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self) { return self->connection_objs; } +void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self) { + bonding_erase_storage(); +} + void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter) { gc_collect_root((void**)adapter, sizeof(bleio_adapter_obj_t) / sizeof(size_t)); gc_collect_root((void**)connections, sizeof(connections) / sizeof(size_t)); diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 6c49823c2b..664805b665 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -54,7 +54,7 @@ #define BLE_AD_TYPE_FLAGS_DATA_SIZE 1 static const ble_gap_sec_params_t pairing_sec_params = { - .bond = 0, + .bond = 1, .mitm = 0, .lesc = 0, .keypress = 0, @@ -66,6 +66,13 @@ static const ble_gap_sec_params_t pairing_sec_params = { .kdist_peer = { .enc = 1, .id = 1}, }; +#define CONNECTION_DEBUG (1) +#if CONNECTION_DEBUG + #define CONNECTION_DEBUG_PRINTF(...) printf(__VA_ARGS__) +#else + #define CONNECTION_DEBUG_PRINTF(...) +#endif + static volatile bool m_discovery_in_process; static volatile bool m_discovery_successful; @@ -86,7 +93,10 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { switch (ble_evt->header.evt_id) { case BLE_GAP_EVT_DISCONNECTED: + CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_DISCONNECTED\n"); + // Adapter.c does the work for this event. break; + case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { ble_gap_phys_t const phys = { .rx_phys = BLE_GAP_PHY_AUTO, @@ -173,10 +183,11 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } case BLE_GAP_EVT_SEC_PARAMS_REQUEST: { + CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_SEC_PARAMS_REQUEST\n"); // First time pairing. // 1. Either we or peer initiate the process // 2. Peer asks for security parameters using BLE_GAP_EVT_SEC_PARAMS_REQUEST. - // 3. Pair Key exchange ("just works" implemented now; TODO key pairing) + // 3. Pair Key exchange ("just works" implemented now; TODO: out-of-band key pairing) // 4. Connection is secured: BLE_GAP_EVT_CONN_SEC_UPDATE // 5. Long-term Keys exchanged: BLE_GAP_EVT_AUTH_STATUS @@ -205,43 +216,55 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } case BLE_GAP_EVT_LESC_DHKEY_REQUEST: + CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_LESC_DHKEY_REQUEST\n"); // TODO for LESC pairing: // sd_ble_gap_lesc_dhkey_reply(...); break; case BLE_GAP_EVT_AUTH_STATUS: { // 0x19 + CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_AUTH_STATUS\n"); // Pairing process completed ble_gap_evt_auth_status_t* status = &ble_evt->evt.gap_evt.params.auth_status; self->sec_status = status->auth_status; if (status->auth_status == BLE_GAP_SEC_STATUS_SUCCESS) { self->ediv = self->bonding_keys.own_enc.master_id.ediv; self->pair_status = PAIR_PAIRED; + CONNECTION_DEBUG_PRINTF("PAIR_PAIRED\n"); bonding_save_keys(self->is_central, self->conn_handle, &self->bonding_keys); } else { + // Inform busy-waiter pairing has failed. self->pair_status = PAIR_NOT_PAIRED; + CONNECTION_DEBUG_PRINTF("PAIR_NOT_PAIRED\n"); } break; } case BLE_GAP_EVT_SEC_INFO_REQUEST: { // 0x14 + CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_SEC_INFO_REQUEST\n"); // Peer asks for the stored keys. // - load key and return if bonded previously. // - Else return NULL --> Initiate key exchange ble_gap_evt_sec_info_request_t* sec_info_request = &ble_evt->evt.gap_evt.params.sec_info_request; (void) sec_info_request; if ( bonding_load_keys(self->is_central, sec_info_request->master_id.ediv, &self->bonding_keys) ) { - sd_ble_gap_sec_info_reply(self->conn_handle, - &self->bonding_keys.own_enc.enc_info, - &self->bonding_keys.peer_id.id_info, - NULL); + CONNECTION_DEBUG_PRINTF("keys found\n"); + uint32_t err_code = sd_ble_gap_sec_info_reply( + self->conn_handle, + &self->bonding_keys.own_enc.enc_info, + &self->bonding_keys.peer_id.id_info, + NULL); + CONNECTION_DEBUG_PRINTF("sd_ble_gap_sec_info_reply err_code: %0lx\n", err_code); self->ediv = self->bonding_keys.own_enc.master_id.ediv; } else { + CONNECTION_DEBUG_PRINTF("keys not found\n"); + // We don't have stored keys. Ask for keys. sd_ble_gap_sec_info_reply(self->conn_handle, NULL, NULL, NULL); } break; } case BLE_GAP_EVT_CONN_SEC_UPDATE: { // 0x1a + CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_CONN_SEC_UPDATE\n"); ble_gap_conn_sec_t* conn_sec = &ble_evt->evt.gap_evt.params.conn_sec_update.conn_sec; if (conn_sec->sec_mode.sm <= 1 && conn_sec->sec_mode.lv <= 1) { // Security setup did not succeed: @@ -250,12 +273,13 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { // mode >=1 and/or level >=1 means encryption is set up self->pair_status = PAIR_NOT_PAIRED; } else { - // Does an sd_ble_gatts_sys_attr_set() with the stored values. if (bonding_load_cccd_info(self->is_central, self->conn_handle, self->ediv)) { - // Not quite paired yet: wait for BLE_GAP_EVT_AUTH_STATUS SUCCESS. - self->ediv = self->bonding_keys.own_enc.master_id.ediv; + // Did an sd_ble_gatts_sys_attr_set() with the stored sys_attr values. + // Not quite paired yet: wait for BLE_GAP_EVT_AUTH_STATUS with BLE_GAP_SEC_STATUS_SUCCESS. + CONNECTION_DEBUG_PRINTF("did bonding_load_cccd_info()\n"); } else { // No matching bonding found, so use fresh system attributes. + CONNECTION_DEBUG_PRINTF("bonding_load_cccd_info() failed\n"); sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); } } @@ -263,8 +287,10 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } default: + CONNECTION_DEBUG_PRINTF("Unhandled event: %04x\n", ble_evt->header.evt_id); return false; } + CONNECTION_DEBUG_PRINTF("Handled event: %04x\n", ble_evt->header.evt_id); return true; } diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c index 1175f72e47..0476d722be 100644 --- a/ports/nrf/common-hal/_bleio/bonding.c +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -43,14 +43,12 @@ #define BONDING_PAGES_START_ADDR CIRCUITPY_BLE_CONFIG_START_ADDR #define BONDING_PAGES_END_ADDR (CIRCUITPY_BLE_CONFIG_START_ADDR + CIRCUITPY_BLE_CONFIG_SIZE) -// First and last four bytes are magic bytes for id and version. Start data after that. +// First and last four bytes are magic bytes for id and version. Data is in between. // 'BD01' -const uint32_t BONDING_START_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); -// 'ED01' -const uint32_t BONDING_END_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'E' << 24); +const uint32_t BONDING_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); -#define BONDING_DATA_START_ADDR (BONDING_PAGES_START_ADDR + sizeof(BONDING_START_FLAG)) -#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_END_FLAG)) +#define BONDING_DATA_START_ADDR (BONDING_PAGES_START_ADDR + sizeof(BONDING_FLAG)) +#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_FLAG)) #define BONDING_START_FLAG_ADDR BONDING_PAGES_START_ADDR #define BONDING_END_FLAG_ADDR BONDING_DATA_END_ADDR @@ -59,14 +57,28 @@ const uint32_t BONDING_END_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'E' << 24); #define SYS_ATTR_FLAGS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS) STATIC bonding_block_t *bonding_unused_block = NULL; -nrf_mutex_t queued_bonding_block_list_mutex; +nrf_mutex_t queued_bonding_block_entries_mutex; -STATIC inline size_t compute_block_size(uint16_t data_length) { - // Round data size up to the nearest 32-bit address. - return sizeof(bonding_block_t) + ((data_length + 3) & 0x3); +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *block) { + printf("at 0x%08lx: is_central: %1d, type: 0x%x, ediv: 0x%04x, data_length: %d\n", + (uint32_t) block, block->is_central, block->type, block->ediv, block->data_length); } -STATIC void erase_bonding_storage(void) { +void bonding_print_keys(bonding_keys_t *keys) { + for (size_t i = 0; i < sizeof(bonding_keys_t); i ++) { + printf("%x", ((uint8_t*) keys)[i]); + } + printf("\n"); +} +#endif + +STATIC size_t compute_block_size(uint16_t data_length) { + // Round data size up to the nearest 32-bit address. + return sizeof(bonding_block_t) + ((data_length + 3) & ~0x3); +} + +void bonding_erase_storage(void) { // Erase all pages in the bonding area. for(uint32_t page_address = BONDING_PAGES_START_ADDR; page_address < BONDING_PAGES_END_ADDR; @@ -75,10 +87,9 @@ STATIC void erase_bonding_storage(void) { sd_flash_page_erase_sync(page_address / FLASH_PAGE_SIZE); } // Write marker words at the beginning and the end of the bonding area. - uint32_t flag = BONDING_START_FLAG; - sd_flash_write_sync((uint32_t *) BONDING_DATA_START_ADDR, &flag, 1); - flag = BONDING_END_FLAG; - sd_flash_write_sync((uint32_t *) BONDING_DATA_END_ADDR, &flag, 1); + uint32_t flag = BONDING_FLAG; + sd_flash_write_sync((uint32_t *) BONDING_START_FLAG_ADDR, &flag, 1); + sd_flash_write_sync((uint32_t *) BONDING_END_FLAG_ADDR, &flag, 1); // First unused block is at the beginning. bonding_unused_block = (bonding_block_t *) BONDING_DATA_START_ADDR; } @@ -90,7 +101,6 @@ STATIC bonding_block_t *next_block(bonding_block_t *block) { while (1) { // Advance to next block. if (block == NULL) { - // Return first block (which might be unused if block list is empty). return (bonding_block_t *) BONDING_DATA_START_ADDR; } else if (block->type == BLOCK_UNUSED) { // Already at last block (the unused block). @@ -115,20 +125,26 @@ STATIC bonding_block_t *next_block(bonding_block_t *block) { // Find the block with given type and ediv value. // If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. // If not found, return NULL. -STATIC bonding_block_t *find_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { +STATIC bonding_block_t *find_block_with_keys(bool is_central, bonding_block_type_t type, uint16_t ediv) { bonding_block_t *block = NULL; + BONDING_DEBUG_PRINTF("find_block_with_keys(): looking through blocks:\n"); while (1) { block = next_block(block); if (block == NULL) { return NULL; } - if (block->type == BLOCK_UNUSED) { - return block; + BONDING_DEBUG_PRINT_BLOCK(block); + if (block->type == BLOCK_INVALID) { + // Skip discarded blocks. + continue; } - if (is_central == block->is_central && - type == block->type && - ediv == block->ediv) { + // If types match, and block is unused, just return it. + // Otherwise check that is_central and ediv match. + if (type == block->type) { + if (type == BLOCK_UNUSED || + (is_central == block->is_central && ediv == block->ediv)) { return block; + } } } } @@ -137,6 +153,7 @@ STATIC bonding_block_t *find_block(bool is_central, bonding_block_type_t type, u // We don't change data_length, so we can still skip over this block. STATIC void invalidate_block(bonding_block_t *block) { BONDING_DEBUG_PRINTF("invalidate_block()\n"); + BONDING_DEBUG_PRINT_BLOCK(block); uint32_t zero = 0; sd_flash_write_sync((uint32_t *) block, &zero, 1); } @@ -147,29 +164,28 @@ STATIC void queue_write_block(bool is_central, bonding_block_type_t type, uint16 return; } - queued_bonding_block_list_elt_t* queued_elt = - m_malloc_maybe(sizeof(queued_bonding_block_list_elt_t) + data_length, false); + queued_bonding_block_entry_t* queued_entry = + m_malloc_maybe(sizeof(queued_bonding_block_entry_t) + data_length, false); - if (!queued_elt) { + if (!queued_entry) { // Failed to allocate. Not much we can do, since this might be during an evt handler. return; } - // Add this new element to the front of the list. - sd_mutex_acquire_wait(&queued_bonding_block_list_mutex); - queued_elt->next_queued_block = MP_STATE_VM(queued_bonding_block_list); - MP_STATE_VM(queued_bonding_block_list) = queued_elt; - sd_mutex_release(&queued_bonding_block_list_mutex); - - // - queued_elt->bonding_block.is_central = is_central; - queued_elt->bonding_block.type = type; - queued_elt->bonding_block.ediv = ediv; - queued_elt->bonding_block.conn_handle = conn_handle; - queued_elt->bonding_block.data_length = data_length; + queued_entry->block.is_central = is_central; + queued_entry->block.type = type; + queued_entry->block.ediv = ediv; + queued_entry->block.conn_handle = conn_handle; + queued_entry->block.data_length = data_length; if (data && data_length != 0) { - memcpy(&queued_elt->bonding_block.data, data, data_length); + memcpy(&queued_entry->block.data, data, data_length); } + + // Add this new element to the front of the list. + sd_mutex_acquire_wait(&queued_bonding_block_entries_mutex); + queued_entry->next = MP_STATE_VM(queued_bonding_block_entries); + MP_STATE_VM(queued_bonding_block_entries) = queued_entry; + sd_mutex_release(&queued_bonding_block_entries_mutex); } // Write bonding block header. @@ -178,7 +194,7 @@ STATIC void write_block_header(bonding_block_t *block) { if (bonding_unused_block == NULL || (uint8_t *) bonding_unused_block + compute_block_size(block->data_length) >= (uint8_t *)BONDING_DATA_END_ADDR) { - erase_bonding_storage(); + bonding_erase_storage(); } sd_flash_write_sync((uint32_t *) bonding_unused_block, (uint32_t *) block, sizeof(bonding_block_t) / 4); @@ -198,6 +214,7 @@ STATIC void write_block_data(uint8_t *data, uint16_t data_length) { break; } data_length -= 4; + data += 4; // Increment by word size. flash_word_p++; } @@ -231,10 +248,10 @@ STATIC bool write_keys_block(bonding_block_t *block) { } bonding_keys_t *bonding_keys = (bonding_keys_t *) block->data; + BONDING_DEBUG_PRINT_KEYS(bonding_keys); block->ediv = block->is_central ? bonding_keys->peer_enc.master_id.ediv : bonding_keys->own_enc.master_id.ediv; - write_block_header(block); write_block_data((uint8_t *) bonding_keys, sizeof(bonding_keys_t)); return true; @@ -247,13 +264,13 @@ void bonding_clear_keys(bonding_keys_t *bonding_keys) { // Call only when SD is enabled. void bonding_reset(void) { - MP_STATE_VM(queued_bonding_block_list) = NULL; - sd_mutex_new(&queued_bonding_block_list_mutex); - if (BONDING_START_FLAG != *((uint32_t *) BONDING_START_FLAG_ADDR) || - BONDING_END_FLAG != *((uint32_t *) BONDING_END_FLAG_ADDR)) { - erase_bonding_storage(); + MP_STATE_VM(queued_bonding_block_entries) = NULL; + sd_mutex_new(&queued_bonding_block_entries_mutex); + if (BONDING_FLAG != *((uint32_t *) BONDING_START_FLAG_ADDR) || + BONDING_FLAG != *((uint32_t *) BONDING_END_FLAG_ADDR)) { + bonding_erase_storage(); } else { - bonding_unused_block = find_block(true, BLOCK_UNUSED, EDIV_INVALID); + bonding_unused_block = find_block_with_keys(true, BLOCK_UNUSED, EDIV_INVALID); } } @@ -266,29 +283,34 @@ void bonding_background(void) { return; } // Get block at front of list. - sd_mutex_acquire_wait(&queued_bonding_block_list_mutex); - bonding_block_t *block = (bonding_block_t *) MP_STATE_VM(queued_bonding_block_list); - if (block) { - // Remove block from list. - MP_STATE_VM(queued_bonding_block_list) = MP_STATE_VM(queued_bonding_block_list)->next_queued_block; + bonding_block_t *block = NULL; + sd_mutex_acquire_wait(&queued_bonding_block_entries_mutex); + if (MP_STATE_VM(queued_bonding_block_entries)) { + block = &(MP_STATE_VM(queued_bonding_block_entries)->block); + // Remove entry from list. + MP_STATE_VM(queued_bonding_block_entries) = MP_STATE_VM(queued_bonding_block_entries)->next; } - sd_mutex_release(&queued_bonding_block_list_mutex); + sd_mutex_release(&queued_bonding_block_entries_mutex); if (!block) { return; } // Is there an existing block whose keys match? - bonding_block_t *matching_block = find_block(block->is_central, block->type, block->ediv); - if (matching_block) { - if (block->data_length == matching_block->data_length && - memcmp(block->data, matching_block->data, block->data_length) == 0) { + BONDING_DEBUG_PRINTF("bonding_background(): processing queued block:\n"); + BONDING_DEBUG_PRINT_BLOCK(block); + bonding_block_t *block_with_keys = find_block_with_keys(block->is_central, block->type, block->ediv); + if (block_with_keys) { + BONDING_DEBUG_PRINTF("bonding_background(): block with same keys found:\n"); + BONDING_DEBUG_PRINT_BLOCK(block_with_keys); + if (block->data_length == block_with_keys->data_length && + memcmp(block->data, block_with_keys->data, block->data_length) == 0) { // Identical block found. No need to store again. - BONDING_DEBUG_PRINTF("bonding_background(): identical block found\n"); + BONDING_DEBUG_PRINTF("bonding_background(): block is identical to block_with_keys\n"); return; } // Block keys match but data doesn't. Invalidate block and store a new one. - BONDING_DEBUG_PRINTF("bonding_background(): invalidating block\n"); - invalidate_block(matching_block); + BONDING_DEBUG_PRINTF("bonding_background(): invalidating block_with_keys\n"); + invalidate_block(block_with_keys); } switch (block->type) { @@ -301,26 +323,27 @@ void bonding_background(void) { break; default: + BONDING_DEBUG_PRINTF("unknown block type: %x\n", block->type); break; } } bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { - bonding_block_t *block = find_block(is_central, BLOCK_SYS_ATTR, ediv); + bonding_block_t *block = find_block_with_keys(is_central, BLOCK_SYS_ATTR, ediv); if (block == NULL) { - BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block not found\n"); + BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block not found, ediv: %04x\n", ediv); return false; } - BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block found\n"); + BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block found, ediv: %04x\n", ediv); return NRF_SUCCESS == sd_ble_gatts_sys_attr_set(conn_handle, block->data, block->data_length, SYS_ATTR_FLAGS); } bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { - bonding_block_t *block = find_block(is_central, BLOCK_SYS_ATTR, ediv); + bonding_block_t *block = find_block_with_keys(is_central, BLOCK_KEYS, ediv); if (block == NULL) { - BONDING_DEBUG_PRINTF("bonding_load_keys(): block not found\n"); + BONDING_DEBUG_PRINTF("bonding_load_keys(): block not found, ediv: %04x\n", ediv); return false; } if (sizeof(bonding_keys_t) != block->data_length) { @@ -328,18 +351,23 @@ bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_k return false; } - BONDING_DEBUG_PRINTF("bonding_load_keys(): block found\n"); + BONDING_DEBUG_PRINTF("bonding_load_keys(): block found, ediv: %04x\n", ediv); memcpy(bonding_keys, block->data, block->data_length); + BONDING_DEBUG_PRINT_KEYS(bonding_keys); return true; } void bonding_save_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { - queue_write_block(is_central, ediv, conn_handle, BLOCK_SYS_ATTR, NULL, 0); + BONDING_DEBUG_PRINTF("bonding_save_cccd_info: is_central: %d, conn_handle: %04x, ediv: %04x\n", + is_central, conn_handle, ediv); + queue_write_block(is_central, BLOCK_SYS_ATTR, ediv, conn_handle, NULL, 0); } void bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys) { uint16_t const ediv = is_central ? bonding_keys->peer_enc.master_id.ediv : bonding_keys->own_enc.master_id.ediv; + BONDING_DEBUG_PRINTF("bonding_save_keys: is_central: %d, conn_handle: %04x, ediv: %04x\n", + is_central, conn_handle, ediv); queue_write_block(is_central, BLOCK_KEYS, ediv, conn_handle, (uint8_t *) bonding_keys, sizeof(bonding_keys_t)); } diff --git a/ports/nrf/common-hal/_bleio/bonding.h b/ports/nrf/common-hal/_bleio/bonding.h index 1b0083865f..35347af2a6 100644 --- a/ports/nrf/common-hal/_bleio/bonding.h +++ b/ports/nrf/common-hal/_bleio/bonding.h @@ -40,8 +40,12 @@ #define BONDING_DEBUG (1) #if BONDING_DEBUG #define BONDING_DEBUG_PRINTF(...) printf(__VA_ARGS__) + #define BONDING_DEBUG_PRINT_BLOCK(block) bonding_print_block(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) bonding_print_keys(keys) #else #define BONDING_DEBUG_PRINTF(...) + #define BONDING_DEBUG_PRINT_BLOCK(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) #endif // Bonding data is stored in variable-length blocks consecutively in erased flash. @@ -71,12 +75,13 @@ typedef struct { } bonding_block_t; // Bonding blocks that need to be written are stored in a linked list. -typedef struct _queued_bonding_block_list_elt_t { - struct _queued_bonding_block_list_elt_t *next_queued_block; - bonding_block_t bonding_block; // variable length, based on data_length. -} queued_bonding_block_list_elt_t; +typedef struct _queued_bonding_block_entry_t { + struct _queued_bonding_block_entry_t *next; + bonding_block_t block; // variable length, based on data_length. +} queued_bonding_block_entry_t; void bonding_background(void); +void bonding_erase_storage(void); void bonding_reset(void); void bonding_clear_keys(bonding_keys_t *bonding_keys); bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 14f7632fd1..a480ec1e0d 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -156,7 +156,7 @@ #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS \ ble_drv_evt_handler_entry_t* ble_drv_evt_handler_entries; \ - queued_bonding_block_list_elt_t* queued_bonding_block_list; \ + queued_bonding_block_entry_t* queued_bonding_block_entries; \ #endif // NRF5_MPCONFIGPORT_H__ diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 5d3211b0c4..500055cf31 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -360,22 +360,35 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 2, bleio_adapter_connect); +//| .. method:: erase_bonding() +//| +//| Erase all bonding information stored in flash memory. +STATIC mp_obj_t bleio_adapter_erase_bonding(mp_obj_t self_in) { + bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in); + + common_hal_bleio_adapter_erase_bonding(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_erase_bonding_obj, bleio_adapter_erase_bonding); STATIC const mp_rom_map_elem_t bleio_adapter_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_enabled), MP_ROM_PTR(&bleio_adapter_enabled_obj) }, { MP_ROM_QSTR(MP_QSTR_address), MP_ROM_PTR(&bleio_adapter_address_obj) }, - { MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_adapter_name_obj) }, + { MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_adapter_name_obj) }, - { MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_adapter_start_advertising_obj) }, - { MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_adapter_stop_advertising_obj) }, + { MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_adapter_start_advertising_obj) }, + { MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_adapter_stop_advertising_obj) }, { MP_ROM_QSTR(MP_QSTR_start_scan), MP_ROM_PTR(&bleio_adapter_start_scan_obj) }, - { MP_ROM_QSTR(MP_QSTR_stop_scan), MP_ROM_PTR(&bleio_adapter_stop_scan_obj) }, + { MP_ROM_QSTR(MP_QSTR_stop_scan), MP_ROM_PTR(&bleio_adapter_stop_scan_obj) }, - { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_adapter_connect_obj) }, + { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_adapter_connect_obj) }, - { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_adapter_connected_obj) }, + { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_adapter_connected_obj) }, { MP_ROM_QSTR(MP_QSTR_connections), MP_ROM_PTR(&bleio_adapter_connections_obj) }, + + { MP_ROM_QSTR(MP_QSTR_erase_bonding), MP_ROM_PTR(&bleio_adapter_erase_bonding_obj) }, }; STATIC MP_DEFINE_CONST_DICT(bleio_adapter_locals_dict, bleio_adapter_locals_dict_table); diff --git a/shared-bindings/_bleio/Adapter.h b/shared-bindings/_bleio/Adapter.h index 4340d82c10..9b20a461a8 100644 --- a/shared-bindings/_bleio/Adapter.h +++ b/shared-bindings/_bleio/Adapter.h @@ -48,13 +48,15 @@ extern void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const c extern uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, float interval, uint8_t *advertising_data, uint16_t advertising_data_len, uint8_t *scan_response_data, uint16_t scan_response_data_len); extern void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo); -void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self); +extern void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self); -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); -void common_hal_bleio_adapter_stop_scan(bleio_adapter_obj_t *self); +extern 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); +extern void common_hal_bleio_adapter_stop_scan(bleio_adapter_obj_t *self); -bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self); -mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self); -mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout); +extern bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self); +extern mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self); +extern mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout); + +extern void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADAPTER_H From 73e076a40cc82f1dab83791b2efc547265ae0b92 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 11 Jan 2020 17:37:37 -0500 Subject: [PATCH 325/531] make types that depend on tuple subscr work --- py/objnamedtuple.c | 11 +---------- py/objnamedtuple.h | 1 - py/objtuple.c | 7 ++++++- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index a0a64f9b25..84dcf79097 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -71,15 +71,6 @@ void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t ki mp_obj_attrtuple_print_helper(print, fields, &o->tuple); } -mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_type_t *type = mp_obj_get_type(self_in); - // Check for subclasses of namedtuple and unpack if needed. - if (type->parent != &mp_type_tuple) { - self_in = ((mp_obj_instance_t*) self_in)->subobj[0]; - } - return mp_obj_tuple_subscr(self_in, index, value); -} - void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { if (dest[0] == MP_OBJ_NULL) { // load attribute @@ -177,7 +168,7 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t o->base.unary_op = mp_obj_tuple_unary_op; o->base.binary_op = mp_obj_tuple_binary_op; o->base.attr = namedtuple_attr; - o->base.subscr = namedtuple_subscr; + o->base.subscr = mp_obj_tuple_subscr; o->base.getiter = mp_obj_tuple_getiter; o->base.parent = &mp_type_tuple; return MP_OBJ_FROM_PTR(o); diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h index 5a7512e3a6..0ea0d28622 100644 --- a/py/objnamedtuple.h +++ b/py/objnamedtuple.h @@ -49,7 +49,6 @@ typedef struct _mp_obj_namedtuple_t { void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name); -mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields); mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); diff --git a/py/objtuple.c b/py/objtuple.c index 2b483f8b83..0a2ed6f4c3 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -29,6 +29,7 @@ #include "py/objtuple.h" #include "py/runtime.h" +#include "py/objtype.h" #include "supervisor/shared/translate.h" @@ -178,10 +179,14 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - if (value == MP_OBJ_SENTINEL) { // load mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + // when called with a native type (eg namedtuple) using mp_obj_tuple_subscr, get the native self + if (self->base.type->subscr != &mp_obj_tuple_subscr) { + self = mp_instance_cast_to_native_base(self_in, &mp_type_tuple); + } + #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; From dd4b0f6e9c4fd987b5d971c358e17911696054fd Mon Sep 17 00:00:00 2001 From: Steve Theodore Date: Sat, 11 Jan 2020 21:37:54 -0800 Subject: [PATCH 326/531] Make all `PYTHON` env vars into `PYTHON3` make file contained a mix of references to `PYTHON` and `PYTHON3`, and did not build on a fresh install of Ubuntu (under Windows LXSS) --- py/py.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/py.mk b/py/py.mk index 9031c009f6..a73b47f372 100644 --- a/py/py.mk +++ b/py/py.mk @@ -304,12 +304,12 @@ FORCE: $(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD) $(STEPECHO) "GEN $@" - $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@ + $(Q)$(PYTHON3) $(PY_SRC)/makeversionhdr.py $@ # build a list of registered modules for py/objmodule.c. $(HEADER_BUILD)/moduledefs.h: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)/mpversion.h @$(STEPECHO) "GEN $@" - $(Q)$(PYTHON) $(PY_SRC)/makemoduledefs.py --vpath="., $(TOP), $(USER_C_MODULES)" $(SRC_QSTR) > $@ + $(Q)$(PYTHON3) $(PY_SRC)/makemoduledefs.py --vpath="., $(TOP), $(USER_C_MODULES)" $(SRC_QSTR) > $@ SRC_QSTR += $(HEADER_BUILD)/moduledefs.h From 9e7f8743c2725c1818033e348e8d542ec7539045 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 12 Jan 2020 23:32:51 -0500 Subject: [PATCH 327/531] fix CCCD bonding store; avoid excessive bonding writes --- ports/nrf/common-hal/_bleio/Characteristic.c | 31 ---- ports/nrf/common-hal/_bleio/Characteristic.h | 1 - ports/nrf/common-hal/_bleio/Connection.c | 18 ++- ports/nrf/common-hal/_bleio/bonding.c | 161 +++++++++++-------- py/gc.c | 4 + py/gc.h | 2 + shared-bindings/_bleio/Characteristic.c | 13 +- shared-bindings/_bleio/Characteristic.h | 1 - 8 files changed, 117 insertions(+), 114 deletions(-) diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index a87cd6e186..4d5cab5c5f 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -83,29 +83,6 @@ STATIC void characteristic_gatts_notify_indicate(uint16_t handle, uint16_t conn_ } } -STATIC bool characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) { - bleio_characteristic_obj_t *self = (bleio_characteristic_obj_t *) param; - switch (ble_evt->header.evt_id) { - case BLE_GATTS_EVT_WRITE: { - // A client wrote to this server characteristic. - // If we are bonded, stored the CCCD value. - if (self->service != MP_OBJ_NULL) { - bleio_connection_obj_t *connection = self->service->connection; - uint16_t conn_handle = bleio_connection_get_conn_handle(connection); - if (conn_handle != BLE_CONN_HANDLE_INVALID && - common_hal_bleio_connection_get_paired(connection) && - ble_evt->evt.gatts_evt.params.write.handle == self->cccd_handle) { - bonding_save_cccd_info( - connection->connection->is_central, conn_handle, connection->connection->ediv); - } - } - break; - } - } - - return true; -} - void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_service_obj_t *service, uint16_t handle, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo) { self->service = service; self->uuid = uuid; @@ -132,9 +109,6 @@ void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, if (initial_value_bufinfo != NULL) { common_hal_bleio_characteristic_set_value(self, initial_value_bufinfo); } - - self->handler_entry.next = NULL; -//////////////// ble_drv_add_event_handler_entry(&self->handler_entry, characteristic_on_ble_evt, self); } bleio_descriptor_obj_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self) { @@ -288,8 +262,3 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, } } - -void common_hal_bleio_characteristic_del(bleio_characteristic_obj_t *self) { - // Remove from event handler list, since the evt handler entry is built-in and not a heap object. - ble_drv_remove_event_handler(characteristic_on_ble_evt, self); -} diff --git a/ports/nrf/common-hal/_bleio/Characteristic.h b/ports/nrf/common-hal/_bleio/Characteristic.h index 5759321aa2..bb8f28495e 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.h +++ b/ports/nrf/common-hal/_bleio/Characteristic.h @@ -47,7 +47,6 @@ typedef struct _bleio_characteristic_obj { bleio_attribute_security_mode_t read_perm; bleio_attribute_security_mode_t write_perm; bleio_descriptor_obj_t *descriptor_list; - ble_drv_evt_handler_entry_t handler_entry; uint16_t user_desc_handle; uint16_t cccd_handle; uint16_t sccd_handle; diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 664805b665..b9a9cf2c41 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -123,6 +123,17 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } + case BLE_GATTS_EVT_WRITE: + // A client wrote a value. + // If we are bonded and it's a CCCD (UUID 0x2902), store the CCCD value. + if (self->conn_handle != BLE_CONN_HANDLE_INVALID && + self->pair_status == PAIR_PAIRED && + ble_evt->evt.gatts_evt.params.write.uuid.type == BLE_UUID_TYPE_BLE && + ble_evt->evt.gatts_evt.params.write.uuid.uuid == 0x2902) { + bonding_save_cccd_info(self->is_central, self->conn_handle, self->ediv); + } + break; + case BLE_GATTS_EVT_SYS_ATTR_MISSING: sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); break; @@ -223,7 +234,7 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { case BLE_GAP_EVT_AUTH_STATUS: { // 0x19 CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_AUTH_STATUS\n"); - // Pairing process completed + // Key exchange completed. ble_gap_evt_auth_status_t* status = &ble_evt->evt.gap_evt.params.auth_status; self->sec_status = status->auth_status; if (status->auth_status == BLE_GAP_SEC_STATUS_SUCCESS) { @@ -264,8 +275,10 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } case BLE_GAP_EVT_CONN_SEC_UPDATE: { // 0x1a - CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_CONN_SEC_UPDATE\n"); + // We get this both on first-time pairing and on subsequent pairings using stored keys. ble_gap_conn_sec_t* conn_sec = &ble_evt->evt.gap_evt.params.conn_sec_update.conn_sec; + CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_CONN_SEC_UPDATE, sm: %d, lv: %d\n", + conn_sec->sec_mode.sm, conn_sec->sec_mode.lv); if (conn_sec->sec_mode.sm <= 1 && conn_sec->sec_mode.lv <= 1) { // Security setup did not succeed: // mode 0, level 0 means no access @@ -282,6 +295,7 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { CONNECTION_DEBUG_PRINTF("bonding_load_cccd_info() failed\n"); sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); } + self->pair_status = PAIR_PAIRED; } break; } diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c index 0476d722be..56f77af852 100644 --- a/ports/nrf/common-hal/_bleio/bonding.c +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -33,6 +33,7 @@ #include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/Adapter.h" #include "shared-bindings/nvm/ByteArray.h" +#include "supervisor/shared/tick.h" #include "nrf_soc.h" #include "sd_mutex.h" @@ -56,8 +57,8 @@ const uint32_t BONDING_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); // Save both system and user service info. #define SYS_ATTR_FLAGS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS) -STATIC bonding_block_t *bonding_unused_block = NULL; -nrf_mutex_t queued_bonding_block_entries_mutex; +STATIC nrf_mutex_t queued_bonding_block_entries_mutex; +STATIC uint64_t block_queued_at_ticks_ms = 0; #if BONDING_DEBUG void bonding_print_block(bonding_block_t *block) { @@ -79,6 +80,7 @@ STATIC size_t compute_block_size(uint16_t data_length) { } void bonding_erase_storage(void) { + BONDING_DEBUG_PRINTF("bonding_erase_storage()\n"); // Erase all pages in the bonding area. for(uint32_t page_address = BONDING_PAGES_START_ADDR; page_address < BONDING_PAGES_END_ADDR; @@ -90,8 +92,6 @@ void bonding_erase_storage(void) { uint32_t flag = BONDING_FLAG; sd_flash_write_sync((uint32_t *) BONDING_START_FLAG_ADDR, &flag, 1); sd_flash_write_sync((uint32_t *) BONDING_END_FLAG_ADDR, &flag, 1); - // First unused block is at the beginning. - bonding_unused_block = (bonding_block_t *) BONDING_DATA_START_ADDR; } // Given NULL to start or block address, return the address of the next valid block. @@ -122,18 +122,16 @@ STATIC bonding_block_t *next_block(bonding_block_t *block) { } } -// Find the block with given type and ediv value. +// Find the block with given is_central, type and ediv value. // If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. // If not found, return NULL. -STATIC bonding_block_t *find_block_with_keys(bool is_central, bonding_block_type_t type, uint16_t ediv) { +STATIC bonding_block_t *find_candidate_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { bonding_block_t *block = NULL; - BONDING_DEBUG_PRINTF("find_block_with_keys(): looking through blocks:\n"); while (1) { block = next_block(block); if (block == NULL) { return NULL; } - BONDING_DEBUG_PRINT_BLOCK(block); if (block->type == BLOCK_INVALID) { // Skip discarded blocks. continue; @@ -149,11 +147,22 @@ STATIC bonding_block_t *find_block_with_keys(bool is_central, bonding_block_type } } +// Get an empty block large enough to store data_length data. +STATIC bonding_block_t* find_unused_block(uint16_t data_length) { + bonding_block_t *unused_block = find_candidate_block(true, BLOCK_UNUSED, EDIV_INVALID); + // If no more room, erase all existing blocks and start over. + if (!unused_block || + (uint8_t *) unused_block + compute_block_size(data_length) >= (uint8_t *) BONDING_DATA_END_ADDR) { + bonding_erase_storage(); + unused_block = (bonding_block_t *) BONDING_DATA_START_ADDR; + } + return unused_block; +} + // Set the header word to all 0's, to mark the block as invalid. // We don't change data_length, so we can still skip over this block. STATIC void invalidate_block(bonding_block_t *block) { BONDING_DEBUG_PRINTF("invalidate_block()\n"); - BONDING_DEBUG_PRINT_BLOCK(block); uint32_t zero = 0; sd_flash_write_sync((uint32_t *) block, &zero, 1); } @@ -164,6 +173,10 @@ STATIC void queue_write_block(bool is_central, bonding_block_type_t type, uint16 return; } + // No heap available, so never mind. This might be called between VM instantiations. + if (!gc_alloc_possible()) { + return; + } queued_bonding_block_entry_t* queued_entry = m_malloc_maybe(sizeof(queued_bonding_block_entry_t) + data_length, false); @@ -181,31 +194,35 @@ STATIC void queue_write_block(bool is_central, bonding_block_type_t type, uint16 memcpy(&queued_entry->block.data, data, data_length); } + // Note: blocks are added in LIFO order, for simplicity and speed. + // The assumption is that there won't be stale blocks on the + // list. The sys_attr blocks don't contain sys_attr data, just a + // request to store the latest value. The key blocks are assumed + // not to be superseded quickly. If this assumption becomes + // invalid, the queue should be changed to FIFO. + // Add this new element to the front of the list. sd_mutex_acquire_wait(&queued_bonding_block_entries_mutex); queued_entry->next = MP_STATE_VM(queued_bonding_block_entries); MP_STATE_VM(queued_bonding_block_entries) = queued_entry; sd_mutex_release(&queued_bonding_block_entries_mutex); + + // Remember when we last queued a block, so we avoid excesive + // sys_attr writes. + block_queued_at_ticks_ms = supervisor_ticks_ms64(); } // Write bonding block header. -STATIC void write_block_header(bonding_block_t *block) { - // If no more room, erase all existing blocks and start over. - if (bonding_unused_block == NULL || - (uint8_t *) bonding_unused_block + compute_block_size(block->data_length) >= - (uint8_t *)BONDING_DATA_END_ADDR) { - bonding_erase_storage(); - } - - sd_flash_write_sync((uint32_t *) bonding_unused_block, (uint32_t *) block, sizeof(bonding_block_t) / 4); +STATIC void write_block_header(bonding_block_t *dest_block, bonding_block_t *source_block_header) { + sd_flash_write_sync((uint32_t *) dest_block, (uint32_t *) source_block_header, sizeof(bonding_block_t) / 4); } // Write variable-length data at end of bonding block. -STATIC void write_block_data(uint8_t *data, uint16_t data_length) { +STATIC void write_block_data(bonding_block_t *dest_block, uint8_t *data, uint16_t data_length) { // Minimize the number of writes. Datasheet says no more than two writes per word before erasing again. // Start writing after the current header. - uint32_t *flash_word_p = (uint32_t *) ((uint8_t *) bonding_unused_block + sizeof(bonding_block_t)); + uint32_t *flash_word_p = (uint32_t *) ((uint8_t *) dest_block + sizeof(bonding_block_t)); while (1) { uint32_t word = 0xffffffff; memcpy(&word, data, data_length >= 4 ? 4 : data_length); @@ -218,43 +235,68 @@ STATIC void write_block_data(uint8_t *data, uint16_t data_length) { // Increment by word size. flash_word_p++; } - bonding_unused_block = (bonding_block_t *) flash_word_p; } -STATIC bool write_sys_attr_block(bonding_block_t *block) { - BONDING_DEBUG_PRINTF("write_sys_attr_block()\n"); +STATIC void write_sys_attr_block(bonding_block_t *block) { uint16_t length = 0; // First find out how big a buffer we need, then fetch the data. if(sd_ble_gatts_sys_attr_get(block->conn_handle, NULL, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { - return false; + return; } uint8_t sys_attr[length]; if(sd_ble_gatts_sys_attr_get(block->conn_handle, sys_attr, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { - return false; + return; } // Now we know the data size. block->data_length = length; - write_block_header(block); - write_block_data(sys_attr, length); - return true; + + // Is there an existing sys_attr block that matches the current sys_attr data? + bonding_block_t *candidate_block = find_candidate_block(block->is_central, block->type, block->ediv); + if (candidate_block) { + if (length == candidate_block->data_length && + memcmp(sys_attr, candidate_block->data, block->data_length) == 0) { + BONDING_DEBUG_PRINTF("Identical sys_attr block already stored.\n"); + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(candidate_block); + } + + bonding_block_t *new_block = find_unused_block(length); + write_block_header(new_block, block); + write_block_data(new_block, sys_attr, length); + return; } -STATIC bool write_keys_block(bonding_block_t *block) { - BONDING_DEBUG_PRINTF("write_keys_block()\n"); +STATIC void write_keys_block(bonding_block_t *block) { if (block->data_length != sizeof(bonding_keys_t)) { - return false; + // Bad length. + return; + } + + // Is there an existing keys block that matches? + bonding_block_t *candidate_block = find_candidate_block(block->is_central, block->type, block->ediv); + if (candidate_block) { + if (block->data_length == candidate_block->data_length && + memcmp(block->data, candidate_block->data, block->data_length) == 0) { + BONDING_DEBUG_PRINTF("Identical keys block already stored.\n"); + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(candidate_block); } bonding_keys_t *bonding_keys = (bonding_keys_t *) block->data; - BONDING_DEBUG_PRINT_KEYS(bonding_keys); block->ediv = block->is_central ? bonding_keys->peer_enc.master_id.ediv : bonding_keys->own_enc.master_id.ediv; - write_block_header(block); - write_block_data((uint8_t *) bonding_keys, sizeof(bonding_keys_t)); - return true; + bonding_block_t *new_block = find_unused_block(sizeof(bonding_keys_t)); + write_block_header(new_block, block); + write_block_data(new_block, (uint8_t *) bonding_keys, sizeof(bonding_keys_t)); } @@ -269,8 +311,6 @@ void bonding_reset(void) { if (BONDING_FLAG != *((uint32_t *) BONDING_START_FLAG_ADDR) || BONDING_FLAG != *((uint32_t *) BONDING_END_FLAG_ADDR)) { bonding_erase_storage(); - } else { - bonding_unused_block = find_block_with_keys(true, BLOCK_UNUSED, EDIV_INVALID); } } @@ -282,6 +322,19 @@ void bonding_background(void) { if (!sd_en) { return; } + + if (block_queued_at_ticks_ms == 0) { + // No writes have been queued yet. + return; + } + + // Wait at least one second before writing a block, to consolidate writes + // that will be duplicates. + uint64_t current_ticks_ms = supervisor_ticks_ms64(); + if (current_ticks_ms - block_queued_at_ticks_ms < 1000) { + return; + } + // Get block at front of list. bonding_block_t *block = NULL; sd_mutex_acquire_wait(&queued_bonding_block_entries_mutex); @@ -292,27 +345,10 @@ void bonding_background(void) { } sd_mutex_release(&queued_bonding_block_entries_mutex); if (!block) { + // List is empty. return; } - // Is there an existing block whose keys match? - BONDING_DEBUG_PRINTF("bonding_background(): processing queued block:\n"); - BONDING_DEBUG_PRINT_BLOCK(block); - bonding_block_t *block_with_keys = find_block_with_keys(block->is_central, block->type, block->ediv); - if (block_with_keys) { - BONDING_DEBUG_PRINTF("bonding_background(): block with same keys found:\n"); - BONDING_DEBUG_PRINT_BLOCK(block_with_keys); - if (block->data_length == block_with_keys->data_length && - memcmp(block->data, block_with_keys->data, block->data_length) == 0) { - // Identical block found. No need to store again. - BONDING_DEBUG_PRINTF("bonding_background(): block is identical to block_with_keys\n"); - return; - } - // Block keys match but data doesn't. Invalidate block and store a new one. - BONDING_DEBUG_PRINTF("bonding_background(): invalidating block_with_keys\n"); - invalidate_block(block_with_keys); - } - switch (block->type) { case BLOCK_SYS_ATTR: write_sys_attr_block(block); @@ -323,27 +359,23 @@ void bonding_background(void) { break; default: - BONDING_DEBUG_PRINTF("unknown block type: %x\n", block->type); break; } } bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { - bonding_block_t *block = find_block_with_keys(is_central, BLOCK_SYS_ATTR, ediv); + bonding_block_t *block = find_candidate_block(is_central, BLOCK_SYS_ATTR, ediv); if (block == NULL) { - BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block not found, ediv: %04x\n", ediv); return false; } - BONDING_DEBUG_PRINTF("bonding_load_cccd_info(): block found, ediv: %04x\n", ediv); return NRF_SUCCESS == sd_ble_gatts_sys_attr_set(conn_handle, block->data, block->data_length, SYS_ATTR_FLAGS); } bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { - bonding_block_t *block = find_block_with_keys(is_central, BLOCK_KEYS, ediv); + bonding_block_t *block = find_candidate_block(is_central, BLOCK_KEYS, ediv); if (block == NULL) { - BONDING_DEBUG_PRINTF("bonding_load_keys(): block not found, ediv: %04x\n", ediv); return false; } if (sizeof(bonding_keys_t) != block->data_length) { @@ -351,15 +383,12 @@ bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_k return false; } - BONDING_DEBUG_PRINTF("bonding_load_keys(): block found, ediv: %04x\n", ediv); memcpy(bonding_keys, block->data, block->data_length); - BONDING_DEBUG_PRINT_KEYS(bonding_keys); return true; } void bonding_save_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { - BONDING_DEBUG_PRINTF("bonding_save_cccd_info: is_central: %d, conn_handle: %04x, ediv: %04x\n", - is_central, conn_handle, ediv); + BONDING_DEBUG_PRINTF("bonding_save_cccd_info()\n"); queue_write_block(is_central, BLOCK_SYS_ATTR, ediv, conn_handle, NULL, 0); } @@ -367,7 +396,5 @@ void bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bo uint16_t const ediv = is_central ? bonding_keys->peer_enc.master_id.ediv : bonding_keys->own_enc.master_id.ediv; - BONDING_DEBUG_PRINTF("bonding_save_keys: is_central: %d, conn_handle: %04x, ediv: %04x\n", - is_central, conn_handle, ediv); queue_write_block(is_central, BLOCK_KEYS, ediv, conn_handle, (uint8_t *) bonding_keys, sizeof(bonding_keys_t)); } diff --git a/py/gc.c b/py/gc.c index 5e631f5ed8..fef67f61bb 100755 --- a/py/gc.c +++ b/py/gc.c @@ -464,6 +464,10 @@ void gc_info(gc_info_t *info) { GC_EXIT(); } +bool gc_alloc_possible(void) { + return MP_STATE_MEM(gc_pool_start) != 0; +} + // We place long lived objects at the end of the heap rather than the start. This reduces // fragmentation by localizing the heap churn to one portion of memory (the start of the heap.) void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived) { diff --git a/py/gc.h b/py/gc.h index cd63ba94cf..2a0811f4ed 100644 --- a/py/gc.h +++ b/py/gc.h @@ -58,6 +58,8 @@ void gc_collect_ptr(void *ptr); void gc_collect_root(void **ptrs, size_t len); void gc_collect_end(void); +// Is the gc heap available? +bool gc_alloc_possible(void); void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived); // Use this function to sweep the whole heap and run all finalisers diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 0434368f24..2b1dc1f789 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -128,8 +128,7 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ } mp_get_buffer_raise(initial_value, &initial_value_bufinfo, MP_BUFFER_READ); - // There may be some cleanup needed when a characteristic is gc'd, so enable finaliser. - bleio_characteristic_obj_t *characteristic = m_new_obj_with_finaliser(bleio_characteristic_obj_t); + bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); characteristic->base.type = &bleio_characteristic_type; // Range checking on max_length arg is done by the common_hal layer, because @@ -293,17 +292,7 @@ STATIC mp_obj_t bleio_characteristic_set_cccd(mp_uint_t n_args, const mp_obj_t * } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_set_cccd_obj, 1, bleio_characteristic_set_cccd); -// Cleanup on gc. -STATIC mp_obj_t bleio_characteristic_del(mp_obj_t self_in) { - bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_bleio_characteristic_del(self); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_del_obj, bleio_characteristic_del); - - STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&bleio_characteristic_del_obj) }, { MP_ROM_QSTR(MP_QSTR_add_to_service), MP_ROM_PTR(&bleio_characteristic_add_to_service_obj) }, { MP_ROM_QSTR(MP_QSTR_properties), MP_ROM_PTR(&bleio_characteristic_properties_obj) }, { MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_characteristic_uuid_obj) }, diff --git a/shared-bindings/_bleio/Characteristic.h b/shared-bindings/_bleio/Characteristic.h index 60ab575724..c4356fd4b9 100644 --- a/shared-bindings/_bleio/Characteristic.h +++ b/shared-bindings/_bleio/Characteristic.h @@ -45,6 +45,5 @@ extern bleio_descriptor_obj_t *common_hal_bleio_characteristic_get_descriptor_li extern bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self); extern void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor); extern void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate); -extern void common_hal_bleio_characteristic_del(bleio_characteristic_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H From 402f6f66bd7bd0a22fd6e0a725d356559f4957be Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Thu, 9 Jan 2020 11:01:45 +0100 Subject: [PATCH 328/531] Add mkspk source files --- ports/cxd56/Makefile | 11 +- ports/cxd56/mkspk/.gitignore | 3 + ports/cxd56/mkspk/Makefile | 51 ++++ ports/cxd56/mkspk/clefia.c | 517 +++++++++++++++++++++++++++++++++++ ports/cxd56/mkspk/clefia.h | 65 +++++ ports/cxd56/mkspk/mkspk.c | 383 ++++++++++++++++++++++++++ ports/cxd56/mkspk/mkspk.h | 83 ++++++ 7 files changed, 1109 insertions(+), 4 deletions(-) create mode 100644 ports/cxd56/mkspk/.gitignore create mode 100644 ports/cxd56/mkspk/Makefile create mode 100644 ports/cxd56/mkspk/clefia.c create mode 100644 ports/cxd56/mkspk/clefia.h create mode 100644 ports/cxd56/mkspk/mkspk.c create mode 100644 ports/cxd56/mkspk/mkspk.h diff --git a/ports/cxd56/Makefile b/ports/cxd56/Makefile index 3355332a81..a0782c4e95 100644 --- a/ports/cxd56/Makefile +++ b/ports/cxd56/Makefile @@ -67,13 +67,13 @@ PLATFORM := $(firstword $(subst _, ,$(shell uname -s 2>/dev/null))) ifeq ($(PLATFORM),Darwin) # macOS - MKSPK = $(SPRESENSE_SDK)/sdk/tools/macos/mkspk + MKSPK = mkspk/mkspk else ifeq ($(PLATFORM),Linux) # Linux - MKSPK = $(SPRESENSE_SDK)/sdk/tools/linux/mkspk + MKSPK = mkspk/mkspk else # Cygwin/MSYS2 - MKSPK = $(SPRESENSE_SDK)/sdk/tools/windows/mkspk.exe + MKSPK = mkspk/mkspk.exe endif SERIAL ?= /dev/ttyUSB0 @@ -201,7 +201,10 @@ $(BUILD)/firmware.elf: $(BUILD)/libmpy.a $(ECHO) "LD $@" $(Q)$(LD) $(LDFLAGS) -$(BUILD)/firmware.spk: $(BUILD)/firmware.elf +$(MKSPK): + $(MAKE) -C mkspk + +$(BUILD)/firmware.spk: $(BUILD)/firmware.elf $(MKSPK) $(ECHO) "Creating $@" $(MKSPK) -c 2 $(BUILD)/firmware.elf nuttx $(BUILD)/firmware.spk diff --git a/ports/cxd56/mkspk/.gitignore b/ports/cxd56/mkspk/.gitignore new file mode 100644 index 0000000000..e9a6ab18f8 --- /dev/null +++ b/ports/cxd56/mkspk/.gitignore @@ -0,0 +1,3 @@ +/mkspk +/mkspk.exe + diff --git a/ports/cxd56/mkspk/Makefile b/ports/cxd56/mkspk/Makefile new file mode 100644 index 0000000000..d91d17a3ca --- /dev/null +++ b/ports/cxd56/mkspk/Makefile @@ -0,0 +1,51 @@ +############################################################################ +# tools/mkspk/Makefile +# +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +all: mkspk +default: mkspk +.PHONY: clean + +# Add CFLAGS=-g on the make command line to build debug versions + +CFLAGS = -O2 -Wall -I. + +# mkspk - Convert nuttx.hex image to nuttx.spk image + +mkspk: + @gcc $(CFLAGS) -o mkspk mkspk.c clefia.c + +clean: + @rm -f *.o *.a *.dSYM *~ .*.swp + @rm -f mkspk mkspk.exe diff --git a/ports/cxd56/mkspk/clefia.c b/ports/cxd56/mkspk/clefia.c new file mode 100644 index 0000000000..02a175505d --- /dev/null +++ b/ports/cxd56/mkspk/clefia.c @@ -0,0 +1,517 @@ +/**************************************************************************** + * tools/cxd56/clefia.c + * + * Copyright (C) 2007, 2008 Sony Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "clefia.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define clefiamul4(_x) (clefiamul2(clefiamul2((_x)))) +#define clefiamul6(_x) (clefiamul2((_x)) ^ clefiamul4((_x))) +#define clefiamul8(_x) (clefiamul2(clefiamul4((_x)))) +#define clefiamula(_x) (clefiamul2((_x)) ^ clefiamul8((_x))) + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* S0 (8-bit S-box based on four 4-bit S-boxes) */ + +static const unsigned char clefia_s0[256] = +{ + 0x57u, 0x49u, 0xd1u, 0xc6u, 0x2fu, 0x33u, 0x74u, 0xfbu, + 0x95u, 0x6du, 0x82u, 0xeau, 0x0eu, 0xb0u, 0xa8u, 0x1cu, + 0x28u, 0xd0u, 0x4bu, 0x92u, 0x5cu, 0xeeu, 0x85u, 0xb1u, + 0xc4u, 0x0au, 0x76u, 0x3du, 0x63u, 0xf9u, 0x17u, 0xafu, + 0xbfu, 0xa1u, 0x19u, 0x65u, 0xf7u, 0x7au, 0x32u, 0x20u, + 0x06u, 0xceu, 0xe4u, 0x83u, 0x9du, 0x5bu, 0x4cu, 0xd8u, + 0x42u, 0x5du, 0x2eu, 0xe8u, 0xd4u, 0x9bu, 0x0fu, 0x13u, + 0x3cu, 0x89u, 0x67u, 0xc0u, 0x71u, 0xaau, 0xb6u, 0xf5u, + 0xa4u, 0xbeu, 0xfdu, 0x8cu, 0x12u, 0x00u, 0x97u, 0xdau, + 0x78u, 0xe1u, 0xcfu, 0x6bu, 0x39u, 0x43u, 0x55u, 0x26u, + 0x30u, 0x98u, 0xccu, 0xddu, 0xebu, 0x54u, 0xb3u, 0x8fu, + 0x4eu, 0x16u, 0xfau, 0x22u, 0xa5u, 0x77u, 0x09u, 0x61u, + 0xd6u, 0x2au, 0x53u, 0x37u, 0x45u, 0xc1u, 0x6cu, 0xaeu, + 0xefu, 0x70u, 0x08u, 0x99u, 0x8bu, 0x1du, 0xf2u, 0xb4u, + 0xe9u, 0xc7u, 0x9fu, 0x4au, 0x31u, 0x25u, 0xfeu, 0x7cu, + 0xd3u, 0xa2u, 0xbdu, 0x56u, 0x14u, 0x88u, 0x60u, 0x0bu, + 0xcdu, 0xe2u, 0x34u, 0x50u, 0x9eu, 0xdcu, 0x11u, 0x05u, + 0x2bu, 0xb7u, 0xa9u, 0x48u, 0xffu, 0x66u, 0x8au, 0x73u, + 0x03u, 0x75u, 0x86u, 0xf1u, 0x6au, 0xa7u, 0x40u, 0xc2u, + 0xb9u, 0x2cu, 0xdbu, 0x1fu, 0x58u, 0x94u, 0x3eu, 0xedu, + 0xfcu, 0x1bu, 0xa0u, 0x04u, 0xb8u, 0x8du, 0xe6u, 0x59u, + 0x62u, 0x93u, 0x35u, 0x7eu, 0xcau, 0x21u, 0xdfu, 0x47u, + 0x15u, 0xf3u, 0xbau, 0x7fu, 0xa6u, 0x69u, 0xc8u, 0x4du, + 0x87u, 0x3bu, 0x9cu, 0x01u, 0xe0u, 0xdeu, 0x24u, 0x52u, + 0x7bu, 0x0cu, 0x68u, 0x1eu, 0x80u, 0xb2u, 0x5au, 0xe7u, + 0xadu, 0xd5u, 0x23u, 0xf4u, 0x46u, 0x3fu, 0x91u, 0xc9u, + 0x6eu, 0x84u, 0x72u, 0xbbu, 0x0du, 0x18u, 0xd9u, 0x96u, + 0xf0u, 0x5fu, 0x41u, 0xacu, 0x27u, 0xc5u, 0xe3u, 0x3au, + 0x81u, 0x6fu, 0x07u, 0xa3u, 0x79u, 0xf6u, 0x2du, 0x38u, + 0x1au, 0x44u, 0x5eu, 0xb5u, 0xd2u, 0xecu, 0xcbu, 0x90u, + 0x9au, 0x36u, 0xe5u, 0x29u, 0xc3u, 0x4fu, 0xabu, 0x64u, + 0x51u, 0xf8u, 0x10u, 0xd7u, 0xbcu, 0x02u, 0x7du, 0x8eu +}; + +/* S1 (8-bit S-box based on inverse function) */ + +static const unsigned char clefia_s1[256] = +{ + 0x6cu, 0xdau, 0xc3u, 0xe9u, 0x4eu, 0x9du, 0x0au, 0x3du, + 0xb8u, 0x36u, 0xb4u, 0x38u, 0x13u, 0x34u, 0x0cu, 0xd9u, + 0xbfu, 0x74u, 0x94u, 0x8fu, 0xb7u, 0x9cu, 0xe5u, 0xdcu, + 0x9eu, 0x07u, 0x49u, 0x4fu, 0x98u, 0x2cu, 0xb0u, 0x93u, + 0x12u, 0xebu, 0xcdu, 0xb3u, 0x92u, 0xe7u, 0x41u, 0x60u, + 0xe3u, 0x21u, 0x27u, 0x3bu, 0xe6u, 0x19u, 0xd2u, 0x0eu, + 0x91u, 0x11u, 0xc7u, 0x3fu, 0x2au, 0x8eu, 0xa1u, 0xbcu, + 0x2bu, 0xc8u, 0xc5u, 0x0fu, 0x5bu, 0xf3u, 0x87u, 0x8bu, + 0xfbu, 0xf5u, 0xdeu, 0x20u, 0xc6u, 0xa7u, 0x84u, 0xceu, + 0xd8u, 0x65u, 0x51u, 0xc9u, 0xa4u, 0xefu, 0x43u, 0x53u, + 0x25u, 0x5du, 0x9bu, 0x31u, 0xe8u, 0x3eu, 0x0du, 0xd7u, + 0x80u, 0xffu, 0x69u, 0x8au, 0xbau, 0x0bu, 0x73u, 0x5cu, + 0x6eu, 0x54u, 0x15u, 0x62u, 0xf6u, 0x35u, 0x30u, 0x52u, + 0xa3u, 0x16u, 0xd3u, 0x28u, 0x32u, 0xfau, 0xaau, 0x5eu, + 0xcfu, 0xeau, 0xedu, 0x78u, 0x33u, 0x58u, 0x09u, 0x7bu, + 0x63u, 0xc0u, 0xc1u, 0x46u, 0x1eu, 0xdfu, 0xa9u, 0x99u, + 0x55u, 0x04u, 0xc4u, 0x86u, 0x39u, 0x77u, 0x82u, 0xecu, + 0x40u, 0x18u, 0x90u, 0x97u, 0x59u, 0xddu, 0x83u, 0x1fu, + 0x9au, 0x37u, 0x06u, 0x24u, 0x64u, 0x7cu, 0xa5u, 0x56u, + 0x48u, 0x08u, 0x85u, 0xd0u, 0x61u, 0x26u, 0xcau, 0x6fu, + 0x7eu, 0x6au, 0xb6u, 0x71u, 0xa0u, 0x70u, 0x05u, 0xd1u, + 0x45u, 0x8cu, 0x23u, 0x1cu, 0xf0u, 0xeeu, 0x89u, 0xadu, + 0x7au, 0x4bu, 0xc2u, 0x2fu, 0xdbu, 0x5au, 0x4du, 0x76u, + 0x67u, 0x17u, 0x2du, 0xf4u, 0xcbu, 0xb1u, 0x4au, 0xa8u, + 0xb5u, 0x22u, 0x47u, 0x3au, 0xd5u, 0x10u, 0x4cu, 0x72u, + 0xccu, 0x00u, 0xf9u, 0xe0u, 0xfdu, 0xe2u, 0xfeu, 0xaeu, + 0xf8u, 0x5fu, 0xabu, 0xf1u, 0x1bu, 0x42u, 0x81u, 0xd6u, + 0xbeu, 0x44u, 0x29u, 0xa6u, 0x57u, 0xb9u, 0xafu, 0xf2u, + 0xd4u, 0x75u, 0x66u, 0xbbu, 0x68u, 0x9fu, 0x50u, 0x02u, + 0x01u, 0x3cu, 0x7fu, 0x8du, 0x1au, 0x88u, 0xbdu, 0xacu, + 0xf7u, 0xe4u, 0x79u, 0x96u, 0xa2u, 0xfcu, 0x6du, 0xb2u, + 0x6bu, 0x03u, 0xe1u, 0x2eu, 0x7du, 0x14u, 0x95u, 0x1du +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void bytecpy(unsigned char *dst, const unsigned char *src, int bytelen) +{ + while (bytelen-- > 0) + { + *dst++ = *src++; + } +} + +static unsigned char clefiamul2(unsigned char x) +{ + /* multiplication over GF(2^8) (p(x) = '11d') */ + + if (x & 0x80u) + { + x ^= 0x0eu; + } + + return ((x << 1) | (x >> 7)); +} + +static void clefiaf0xor(unsigned char *dst, const unsigned char *src, + const unsigned char *rk) +{ + unsigned char x[4]; + unsigned char y[4]; + unsigned char z[4]; + + /* F0 */ + + /* Key addition */ + + bytexor(x, src, rk, 4); + + /* Substitution layer */ + + z[0] = clefia_s0[x[0]]; + z[1] = clefia_s1[x[1]]; + z[2] = clefia_s0[x[2]]; + z[3] = clefia_s1[x[3]]; + + /* Diffusion layer (M0) */ + + y[0] = z[0] ^ clefiamul2(z[1]) ^ clefiamul4(z[2]) ^ clefiamul6(z[3]); + y[1] = clefiamul2(z[0]) ^ z[1] ^ clefiamul6(z[2]) ^ clefiamul4(z[3]); + y[2] = clefiamul4(z[0]) ^ clefiamul6(z[1]) ^ z[2] ^ clefiamul2(z[3]); + y[3] = clefiamul6(z[0]) ^ clefiamul4(z[1]) ^ clefiamul2(z[2]) ^ z[3]; + + /* Xoring after F0 */ + + bytecpy(dst + 0, src + 0, 4); + bytexor(dst + 4, src + 4, y, 4); +} + +static void clefiaf1xor(unsigned char *dst, const unsigned char *src, + const unsigned char *rk) +{ + unsigned char x[4]; + unsigned char y[4]; + unsigned char z[4]; + + /* F1 */ + + /* Key addition */ + + bytexor(x, src, rk, 4); + + /* Substitution layer */ + + z[0] = clefia_s1[x[0]]; + z[1] = clefia_s0[x[1]]; + z[2] = clefia_s1[x[2]]; + z[3] = clefia_s0[x[3]]; + + /* Diffusion layer (M1) */ + + y[0] = z[0] ^ clefiamul8(z[1]) ^ clefiamul2(z[2]) ^ clefiamula(z[3]); + y[1] = clefiamul8(z[0]) ^ z[1] ^ clefiamula(z[2]) ^ clefiamul2(z[3]); + y[2] = clefiamul2(z[0]) ^ clefiamula(z[1]) ^ z[2] ^ clefiamul8(z[3]); + y[3] = clefiamula(z[0]) ^ clefiamul2(z[1]) ^ clefiamul8(z[2]) ^ z[3]; + + /* Xoring after F1 */ + + bytecpy(dst + 0, src + 0, 4); + bytexor(dst + 4, src + 4, y, 4); +} + +static void clefiagfn4(unsigned char *y, const unsigned char *x, + const unsigned char *rk, int r) +{ + unsigned char fin[16]; + unsigned char fout[16]; + + bytecpy(fin, x, 16); + while (r-- > 0) + { + clefiaf0xor(fout + 0, fin + 0, rk + 0); + clefiaf1xor(fout + 8, fin + 8, rk + 4); + rk += 8; + if (r) + { + /* swapping for encryption */ + + bytecpy(fin + 0, fout + 4, 12); + bytecpy(fin + 12, fout + 0, 4); + } + } + + bytecpy(y, fout, 16); +} + +#if 0 /* Not used */ +static void clefiagfn8(unsigned char *y, const unsigned char *x, + const unsigned char *rk, int r) +{ + unsigned char fin[32]; + unsigned char fout[32]; + + bytecpy(fin, x, 32); + while (r-- > 0) + { + clefiaf0xor(fout + 0, fin + 0, rk + 0); + clefiaf1xor(fout + 8, fin + 8, rk + 4); + clefiaf0xor(fout + 16, fin + 16, rk + 8); + clefiaf1xor(fout + 24, fin + 24, rk + 12); + rk += 16; + if (r) + { + /* swapping for encryption */ + + bytecpy(fin + 0, fout + 4, 28); + bytecpy(fin + 28, fout + 0, 4); + } + } + + bytecpy(y, fout, 32); +} +#endif + +#if 0 /* Not used */ +static void clefiagfn4inv(unsigned char *y, const unsigned char *x, + const unsigned char *rk, int r) +{ + unsigned char fin[16]; + unsigned char fout[16]; + + rk += (r - 1) * 8; + bytecpy(fin, x, 16); + while (r-- > 0) + { + clefiaf0xor(fout + 0, fin + 0, rk + 0); + clefiaf1xor(fout + 8, fin + 8, rk + 4); + rk -= 8; + if (r) + { + /* swapping for decryption */ + + bytecpy(fin + 0, fout + 12, 4); + bytecpy(fin + 4, fout + 0, 12); + } + } + + bytecpy(y, fout, 16); +} +#endif + +static void clefiadoubleswap(unsigned char *lk) +{ + unsigned char t[16]; + + t[0] = (lk[0] << 7) | (lk[1] >> 1); + t[1] = (lk[1] << 7) | (lk[2] >> 1); + t[2] = (lk[2] << 7) | (lk[3] >> 1); + t[3] = (lk[3] << 7) | (lk[4] >> 1); + t[4] = (lk[4] << 7) | (lk[5] >> 1); + t[5] = (lk[5] << 7) | (lk[6] >> 1); + t[6] = (lk[6] << 7) | (lk[7] >> 1); + t[7] = (lk[7] << 7) | (lk[15] & 0x7fu); + + t[8] = (lk[8] >> 7) | (lk[0] & 0xfeu); + t[9] = (lk[9] >> 7) | (lk[8] << 1); + t[10] = (lk[10] >> 7) | (lk[9] << 1); + t[11] = (lk[11] >> 7) | (lk[10] << 1); + t[12] = (lk[12] >> 7) | (lk[11] << 1); + t[13] = (lk[13] >> 7) | (lk[12] << 1); + t[14] = (lk[14] >> 7) | (lk[13] << 1); + t[15] = (lk[15] >> 7) | (lk[14] << 1); + + bytecpy(lk, t, 16); +} + +static void clefiaconset(unsigned char *con, const unsigned char *iv, int lk) +{ + unsigned char t[2]; + unsigned char tmp; + + bytecpy(t, iv, 2); + while (lk-- > 0) + { + con[0] = t[0] ^ 0xb7u; /* P_16 = 0xb7e1 (natural logarithm) */ + con[1] = t[1] ^ 0xe1u; + con[2] = ~((t[0] << 1) | (t[1] >> 7)); + con[3] = ~((t[1] << 1) | (t[0] >> 7)); + con[4] = ~t[0] ^ 0x24u; /* Q_16 = 0x243f (circle ratio) */ + con[5] = ~t[1] ^ 0x3fu; + con[6] = t[1]; + con[7] = t[0]; + con += 8; + + /* updating T */ + + if (t[1] & 0x01u) + { + t[0] ^= 0xa8u; + t[1] ^= 0x30u; + } + + tmp = t[0] << 7; + t[0] = (t[0] >> 1) | (t[1] << 7); + t[1] = (t[1] >> 1) | tmp; + } +} + +static void left_shift_one(uint8_t * in, uint8_t * out) +{ + int i; + int overflow; + + overflow = 0; + for (i = 15; i >= 0; i--) + { + out[i] = in[i] << 1; + out[i] |= overflow; + overflow = (in[i] >> 7) & 1; + } +} + +static void gen_subkey(struct cipher *c) +{ + uint8_t L[16]; + + memset(L, 0, 16); + clefiaencrypt(L, L, c->rk, c->round); + + left_shift_one(L, c->k1); + if (L[0] & 0x80) + { + c->k1[15] = c->k1[15] ^ 0x87; + } + + left_shift_one(c->k1, c->k2); + if (c->k1[0] & 0x80) + { + c->k2[15] = c->k2[15] ^ 0x87; + } + + memset(L, 0, 16); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +struct cipher *cipher_init(uint8_t * key, uint8_t * iv) +{ + struct cipher *c; + + c = (struct cipher *)malloc(sizeof(*c)); + if (!c) + { + return NULL; + } + + c->round = clefiakeyset(c->rk, key); + + gen_subkey(c); + memset(c->vector, 0, 16); + + return c; +} + +void cipher_deinit(struct cipher *c) +{ + memset(c, 0, sizeof(*c)); + free(c); +} + +int cipher_calc_cmac(struct cipher *c, void *data, int size, void *cmac) +{ + uint8_t m[16]; + uint8_t *p; + + if (size & 0xf) + { + return -1; + } + + p = (uint8_t *) data; + while (size) + { + bytexor(m, c->vector, p, 16); + clefiaencrypt(c->vector, m, c->rk, c->round); + size -= 16; + p += 16; + } + + bytexor(cmac, m, c->k1, 16); + clefiaencrypt(cmac, cmac, c->rk, c->round); + memset(m, 0, 16); + + return 0; +} + +void bytexor(unsigned char *dst, const unsigned char *a, + const unsigned char *b, int bytelen) +{ + while (bytelen-- > 0) + { + *dst++ = *a++ ^ *b++; + } +} + +int clefiakeyset(unsigned char *rk, const unsigned char *skey) +{ + const unsigned char iv[2] = + { + 0x42u, 0x8au /* cubic root of 2 */ + }; + + unsigned char lk[16]; + unsigned char con128[4 * 60]; + int i; + + /* generating CONi^(128) (0 <= i < 60, lk = 30) */ + + clefiaconset(con128, iv, 30); + + /* GFN_{4,12} (generating L from K) */ + + clefiagfn4(lk, skey, con128, 12); + + bytecpy(rk, skey, 8); /* initial whitening key (WK0, WK1) */ + rk += 8; + for (i = 0; i < 9; i++) + { + /* round key (RKi (0 <= i < 36)) */ + + bytexor(rk, lk, con128 + i * 16 + (4 * 24), 16); + if (i % 2) + { + bytexor(rk, rk, skey, 16); /* Xoring K */ + } + + clefiadoubleswap(lk); /* Updating L (DoubleSwap function) */ + rk += 16; + } + + bytecpy(rk, skey + 8, 8); /* final whitening key (WK2, WK3) */ + + return 18; +} + +void clefiaencrypt(unsigned char *ct, const unsigned char *pt, + const unsigned char *rk, const int r) +{ + unsigned char rin[16]; + unsigned char rout[16]; + + bytecpy(rin, pt, 16); + + bytexor(rin + 4, rin + 4, rk + 0, 4); /* initial key whitening */ + bytexor(rin + 12, rin + 12, rk + 4, 4); + rk += 8; + + clefiagfn4(rout, rin, rk, r); /* GFN_{4,r} */ + + bytecpy(ct, rout, 16); + bytexor(ct + 4, ct + 4, rk + r * 8 + 0, 4); /* final key whitening */ + bytexor(ct + 12, ct + 12, rk + r * 8 + 4, 4); +} diff --git a/ports/cxd56/mkspk/clefia.h b/ports/cxd56/mkspk/clefia.h new file mode 100644 index 0000000000..a0e02587da --- /dev/null +++ b/ports/cxd56/mkspk/clefia.h @@ -0,0 +1,65 @@ +/**************************************************************************** + * tools/cxd56/clefia.h + * + * Copyright (C) 2007, 2008 Sony Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef _TOOLS_CXD56_CLEFIA_H_ +#define _TOOLS_CXD56_CLEFIA_H_ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct cipher + { + int mode; + int dir; + uint8_t rk[8 * 26 + 16]; + uint8_t vector[16]; + int round; + uint8_t k1[16]; + uint8_t k2[16]; + }; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +struct cipher *cipher_init(uint8_t * key, uint8_t * iv); +void cipher_deinit(struct cipher *c); +int cipher_calc_cmac(struct cipher *c, void *data, int size, void *cmac); +void bytexor(unsigned char *dst, const unsigned char *a, + const unsigned char *b, int bytelen); +int clefiakeyset(unsigned char *rk, const unsigned char *skey); +void clefiaencrypt(unsigned char *ct, const unsigned char *pt, + const unsigned char *rk, const int r); + +#endif diff --git a/ports/cxd56/mkspk/mkspk.c b/ports/cxd56/mkspk/mkspk.c new file mode 100644 index 0000000000..c447ad7dab --- /dev/null +++ b/ports/cxd56/mkspk/mkspk.c @@ -0,0 +1,383 @@ +/**************************************************************************** + * tools/cxd56/mkspk.c + * + * Copyright (C) 2007, 2008 Sony Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mkspk.h" + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct args +{ + int core; + char *elffile; + char *savename; + char *outputfile; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static uint8_t vmk[16] = + "\x27\xc0\xaf\x1b\x5d\xcb\xc6\xc5\x58\x22\x1c\xdd\xaf\xf3\x20\x21"; + +static struct args g_options = +{ + 0 +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static struct args *parse_args(int argc, char **argv) +{ + int opt; + int show_help; + struct args *args = &g_options; + char *endp; + + show_help = 0; + + if (argc < 2) + { + show_help = 1; + } + + memset(args, 0, sizeof(*args)); + args->core = -1; + + while ((opt = getopt(argc, argv, "h:c:")) != -1) + { + switch (opt) + { + case 'c': + args->core = strtol(optarg, &endp, 0); + if (*endp) + { + fprintf(stderr, "Invalid core number \"%s\"\n", optarg); + show_help = 1; + } + break; + + case 'h': + default: + show_help = 1; + } + } + + argc -= optind; + argv += optind; + + args->elffile = argv[0]; + args->savename = argv[1]; + argc -= 2; + argv += 2; + + if (argc > 0) + { + args->outputfile = strdup(argv[0]); + } + else + { + show_help = 1; + } + + /* Sanity checks for options */ + + if (show_help == 1) + { + fprintf(stderr, + "mkspk [-c ] []\n"); + exit(EXIT_FAILURE); + } + + if (args->core < 0) + { + fprintf(stderr, "Core number is not set. Please use -c option.\n"); + exit(EXIT_FAILURE); + } + + if (strlen(args->savename) > 63) + { + fprintf(stderr, "savename too long.\n"); + exit(EXIT_FAILURE); + } + + return args; +} + +static struct elf_file *load_elf(const char *filename) +{ + size_t fsize; + int pos; + char *buf; + FILE *fp; + struct elf_file *ef; + Elf32_Shdr *sh; + uint16_t i; + int ret; + + fp = fopen(filename, "rb"); + if (!fp) + { + return NULL; + } + + ef = (struct elf_file *)malloc(sizeof(*ef)); + if (!ef) + { + return NULL; + } + + pos = fseek(fp, 0, SEEK_END); + fsize = (size_t) ftell(fp); + fseek(fp, pos, SEEK_SET); + + buf = (char *)malloc(fsize); + if (!buf) + { + return NULL; + } + + ret = fread(buf, fsize, 1, fp); + fclose(fp); + if (ret != 1) + { + return NULL; + } + + ef->data = buf; + + ef->ehdr = (Elf32_Ehdr *) buf; + + Elf32_Ehdr *h = (Elf32_Ehdr *) buf; + + if (!(h->e_ident[EI_MAG0] == 0x7f && + h->e_ident[EI_MAG1] == 'E' && + h->e_ident[EI_MAG2] == 'L' && h->e_ident[EI_MAG3] == 'F')) + { + free(ef); + free(buf); + return NULL; + } + + ef->phdr = (Elf32_Phdr *) (buf + ef->ehdr->e_phoff); + ef->shdr = (Elf32_Shdr *) (buf + ef->ehdr->e_shoff); + ef->shstring = buf + ef->shdr[ef->ehdr->e_shstrndx].sh_offset; + + for (i = 0, sh = ef->shdr; i < ef->ehdr->e_shnum; i++, sh++) + { + if (sh->sh_type == SHT_SYMTAB) + { + ef->symtab = (Elf32_Sym *) (buf + sh->sh_offset); + ef->nsyms = sh->sh_size / sh->sh_entsize; + continue; + } + + if (sh->sh_type == SHT_STRTAB) + { + if (!strcmp(".strtab", ef->shstring + sh->sh_name)) + { + ef->string = buf + sh->sh_offset; + } + } + } + + return ef; +} + +static void *create_image(struct elf_file *elf, int core, char *savename, + int *image_size) +{ + char *img; + struct spk_header *header; + struct spk_prog_info *pi; + Elf32_Phdr *ph; + Elf32_Sym *sym; + char *name; + int snlen; + int nphs, psize, imgsize; + int i; + int j; + uint32_t offset; + uint32_t sp; + + snlen = alignup(strlen(savename) + 1, 16); + + nphs = 0; + psize = 0; + for (i = 0, ph = elf->phdr; i < elf->ehdr->e_phnum; i++, ph++) + { + if (ph->p_type != PT_LOAD || ph->p_filesz == 0) + { + continue; + } + + nphs++; + psize += alignup(ph->p_filesz, 16); + } + + imgsize = sizeof(*header) + snlen + (nphs * 16) + psize; + + img = (char *)malloc(imgsize + 32); + if (!img) + { + return NULL; + } + + *image_size = imgsize; + sym = elf->symtab; + name = elf->string; + sp = 0; + + for (j = 0; j < elf->nsyms; j++, sym++) + { + if (!strcmp("__stack", name + sym->st_name)) + { + sp = sym->st_value; + } + } + + memset(img, 0, imgsize); + + header = (struct spk_header *)img; + header->magic[0] = 0xef; + header->magic[1] = 'M'; + header->magic[2] = 'O'; + header->magic[3] = 'D'; + header->cpu = core; + + header->entry = elf->ehdr->e_entry; + header->stack = sp; + header->core = core; + + header->binaries = nphs; + header->phoffs = sizeof(*header) + snlen; + header->mode = 0777; + + strncpy(img + sizeof(*header), savename, 63); + + ph = elf->phdr; + pi = (struct spk_prog_info *)(img + header->phoffs); + offset = ((char *)pi - img) + (nphs * sizeof(*pi)); + for (i = 0; i < elf->ehdr->e_phnum; i++, ph++) + { + if (ph->p_type != PT_LOAD || ph->p_filesz == 0) + continue; + pi->load_address = ph->p_paddr; + pi->offset = offset; + pi->size = alignup(ph->p_filesz, 16); /* need 16 bytes align for + * decryption */ + pi->memsize = ph->p_memsz; + + memcpy(img + pi->offset, elf->data + ph->p_offset, ph->p_filesz); + + offset += alignup(ph->p_filesz, 16); + pi++; + } + + return img; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv) +{ + struct args *args; + struct elf_file *elf; + struct cipher *c; + uint8_t *spkimage; + int size = 0; + FILE *fp; + char footer[16]; + + args = parse_args(argc, argv); + + elf = load_elf(args->elffile); + if (!elf) + { + fprintf(stderr, "Loading ELF %s failure.\n", args->elffile); + exit(EXIT_FAILURE); + } + + spkimage = create_image(elf, args->core, args->savename, &size); + free(elf); + + c = cipher_init(vmk, NULL); + cipher_calc_cmac(c, spkimage, size, (uint8_t *) spkimage + size); + cipher_deinit(c); + + size += 16; /* Extend CMAC size */ + + snprintf(footer, 16, "MKSPK_BN_HOOTER"); + footer[15] = '\0'; + + fp = fopen(args->outputfile, "wb"); + if (!fp) + { + fprintf(stderr, "Output file open error.\n"); + free(spkimage); + exit(EXIT_FAILURE); + } + + fwrite(spkimage, size, 1, fp); + fwrite(footer, 16, 1, fp); + + fclose(fp); + + printf("File %s is successfully created.\n", args->outputfile); + free(args->outputfile); + + memset(spkimage, 0, size); + free(spkimage); + + exit(EXIT_SUCCESS); +} diff --git a/ports/cxd56/mkspk/mkspk.h b/ports/cxd56/mkspk/mkspk.h new file mode 100644 index 0000000000..5a67bb3dd4 --- /dev/null +++ b/ports/cxd56/mkspk/mkspk.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * tools/cxd56/mkspk.h + * + * Copyright (C) 2007, 2008 Sony Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "clefia.h" +#include "elf.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define alignup(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) +#define swap(a, b) { (a) ^= (b); (b) ^= (a); (a) ^= (b); } + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct spk_header + { + uint8_t magic[4]; + uint8_t cpu; + uint8_t reserved[11]; + uint32_t entry; + uint32_t stack; + uint16_t core; + uint16_t binaries; + uint16_t phoffs; + uint16_t mode; + }; + +struct spk_prog_info + { + uint32_t load_address; + uint32_t offset; + uint32_t size; + uint32_t memsize; + }; + +struct elf_file + { + Elf32_Ehdr *ehdr; + Elf32_Phdr *phdr; + Elf32_Shdr *shdr; + Elf32_Sym *symtab; + int nsyms; + char *shstring; + char *string; + char *data; + }; From cd842d363a1d27f464c616548a95f77d16cda447 Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Mon, 13 Jan 2020 13:33:23 +0100 Subject: [PATCH 329/531] Exclude mkspk from docs --- conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conf.py b/conf.py index abee78aba9..3b29986c06 100644 --- a/conf.py +++ b/conf.py @@ -125,6 +125,7 @@ exclude_patterns = ["**/build*", "ports/cc3200", "ports/cc3200/FreeRTOS", "ports/cc3200/hal", + "ports/cxd56/mkspk", "ports/cxd56/spresense-exported-sdk", "ports/esp32", "ports/esp8266/boards", From de2379bc30534c402836881b2e9b25dada41ca41 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 13 Jan 2020 17:24:52 -0500 Subject: [PATCH 330/531] minor WIP debug edits --- ports/stm32f4/Makefile | 5 ++- .../boards/meowbit_v121/mpconfigboard.mk | 4 +- ports/stm32f4/boards/openocd_stm32f4.cfg | 44 +++++++++++++++++++ ports/stm32f4/supervisor/usb.c | 1 + 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 ports/stm32f4/boards/openocd_stm32f4.cfg diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 93cde67371..c3eb4aa3b0 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -22,7 +22,7 @@ # 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. -DEBUG = 1 +#DEBUG = 1 # Select the board to build for. ifeq ($(BOARD),) @@ -85,6 +85,7 @@ ifeq ($(DEBUG), 1) CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -Os -DNDEBUG + CFLAGS += -ggdb # TODO: Test with -flto ### CFLAGS += -flto endif @@ -256,7 +257,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(ECHO) "Create $@" - $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b 0x08000000 -c -o "$(BUILD)/firmware.uf2" $^ + $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b 0x08010000 -c -o "$(BUILD)/firmware.uf2" $^ include $(TOP)/py/mkrules.mk diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index e8a257983f..c033d1d4bc 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -17,5 +17,5 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -# LD_FILE = boards/STM32F401_boot.ld -LD_FILE = boards/STM32F401_fs.ld \ No newline at end of file +LD_FILE = boards/STM32F401_boot.ld +#LD_FILE = boards/STM32F401_fs.ld \ No newline at end of file diff --git a/ports/stm32f4/boards/openocd_stm32f4.cfg b/ports/stm32f4/boards/openocd_stm32f4.cfg new file mode 100644 index 0000000000..19631a7c8e --- /dev/null +++ b/ports/stm32f4/boards/openocd_stm32f4.cfg @@ -0,0 +1,44 @@ +# This script configures OpenOCD for use with an ST-Link V2 programmer/debugger +# and an STM32F4 target microcontroller. +# +# To flash your firmware: +# +# $ openocd -f openocd_stm32f4.cfg \ +# -c "stm_flash build-BOARD/firmware0.bin 0x08000000 build-BOARD/firmware1.bin 0x08020000" +# +# For a gdb server on port 3333: +# +# $ openocd -f openocd_stm32f4.cfg + + +source [find interface/stlink-v2.cfg] +transport select hla_swd +source [find target/stm32f4x.cfg] +reset_config srst_only +init + +proc stm_flash { BIN0 ADDR0 {BIN1 ""} {ADDR1 ""} } { + reset halt + sleep 100 + wait_halt 2 + flash write_image erase $BIN0 $ADDR0 + sleep 100 + verify_image $BIN0 $ADDR0 + sleep 100 + if {$BIN1 ne ""} { + flash write_image erase $BIN1 $ADDR1 + sleep 100 + verify_image $BIN1 $ADDR1 + sleep 100 + } + reset run + shutdown +} + +proc stm_erase {} { + reset halt + sleep 100 + stm32f4x mass_erase 0 + sleep 100 + shutdown +} diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 5733527c2a..afafe26a90 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -105,6 +105,7 @@ void init_usb_hardware(void) { #endif /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); init_usb_vbus_sense(); From 4ad004f24eb79a382f1e6230f8ff02784d469d87 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 13 Jan 2020 17:52:32 -0500 Subject: [PATCH 331/531] put bonding to-do flags into Connection objects instead of using a heap-allocated queue --- ports/nrf/common-hal/_bleio/Connection.c | 32 ++-- ports/nrf/common-hal/_bleio/Connection.h | 9 +- ports/nrf/common-hal/_bleio/bonding.c | 202 +++++++---------------- ports/nrf/common-hal/_bleio/bonding.h | 21 +-- ports/nrf/mpconfigport.h | 1 - 5 files changed, 83 insertions(+), 182 deletions(-) diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index b9a9cf2c41..ac5c7ecbac 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -46,6 +46,7 @@ #include "shared-bindings/_bleio/Characteristic.h" #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" +#include "supervisor/shared/tick.h" #include "common-hal/_bleio/bonding.h" @@ -93,7 +94,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { switch (ble_evt->header.evt_id) { case BLE_GAP_EVT_DISCONNECTED: - CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_DISCONNECTED\n"); // Adapter.c does the work for this event. break; @@ -130,7 +130,12 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { self->pair_status == PAIR_PAIRED && ble_evt->evt.gatts_evt.params.write.uuid.type == BLE_UUID_TYPE_BLE && ble_evt->evt.gatts_evt.params.write.uuid.uuid == 0x2902) { - bonding_save_cccd_info(self->is_central, self->conn_handle, self->ediv); + // + // Save sys_attr data (CCCD state) in bonding area at + // next opportunity, but also remember time of this + // request, so we can consolidate closely-spaced requests. + self->do_bond_cccds = true; + self->do_bond_cccds_request_time = supervisor_ticks_ms64(); } break; @@ -194,7 +199,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } case BLE_GAP_EVT_SEC_PARAMS_REQUEST: { - CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_SEC_PARAMS_REQUEST\n"); // First time pairing. // 1. Either we or peer initiate the process // 2. Peer asks for security parameters using BLE_GAP_EVT_SEC_PARAMS_REQUEST. @@ -227,47 +231,40 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } case BLE_GAP_EVT_LESC_DHKEY_REQUEST: - CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_LESC_DHKEY_REQUEST\n"); // TODO for LESC pairing: // sd_ble_gap_lesc_dhkey_reply(...); break; case BLE_GAP_EVT_AUTH_STATUS: { // 0x19 - CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_AUTH_STATUS\n"); // Key exchange completed. ble_gap_evt_auth_status_t* status = &ble_evt->evt.gap_evt.params.auth_status; self->sec_status = status->auth_status; if (status->auth_status == BLE_GAP_SEC_STATUS_SUCCESS) { self->ediv = self->bonding_keys.own_enc.master_id.ediv; self->pair_status = PAIR_PAIRED; - CONNECTION_DEBUG_PRINTF("PAIR_PAIRED\n"); - bonding_save_keys(self->is_central, self->conn_handle, &self->bonding_keys); + // Save keys in bonding area at next opportunity. + self->do_bond_keys = true; } else { // Inform busy-waiter pairing has failed. self->pair_status = PAIR_NOT_PAIRED; - CONNECTION_DEBUG_PRINTF("PAIR_NOT_PAIRED\n"); } break; } case BLE_GAP_EVT_SEC_INFO_REQUEST: { // 0x14 - CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_SEC_INFO_REQUEST\n"); // Peer asks for the stored keys. // - load key and return if bonded previously. // - Else return NULL --> Initiate key exchange ble_gap_evt_sec_info_request_t* sec_info_request = &ble_evt->evt.gap_evt.params.sec_info_request; (void) sec_info_request; if ( bonding_load_keys(self->is_central, sec_info_request->master_id.ediv, &self->bonding_keys) ) { - CONNECTION_DEBUG_PRINTF("keys found\n"); - uint32_t err_code = sd_ble_gap_sec_info_reply( + sd_ble_gap_sec_info_reply( self->conn_handle, &self->bonding_keys.own_enc.enc_info, &self->bonding_keys.peer_id.id_info, NULL); - CONNECTION_DEBUG_PRINTF("sd_ble_gap_sec_info_reply err_code: %0lx\n", err_code); self->ediv = self->bonding_keys.own_enc.master_id.ediv; } else { - CONNECTION_DEBUG_PRINTF("keys not found\n"); // We don't have stored keys. Ask for keys. sd_ble_gap_sec_info_reply(self->conn_handle, NULL, NULL, NULL); } @@ -277,8 +274,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { case BLE_GAP_EVT_CONN_SEC_UPDATE: { // 0x1a // We get this both on first-time pairing and on subsequent pairings using stored keys. ble_gap_conn_sec_t* conn_sec = &ble_evt->evt.gap_evt.params.conn_sec_update.conn_sec; - CONNECTION_DEBUG_PRINTF("BLE_GAP_EVT_CONN_SEC_UPDATE, sm: %d, lv: %d\n", - conn_sec->sec_mode.sm, conn_sec->sec_mode.lv); if (conn_sec->sec_mode.sm <= 1 && conn_sec->sec_mode.lv <= 1) { // Security setup did not succeed: // mode 0, level 0 means no access @@ -289,10 +284,8 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { if (bonding_load_cccd_info(self->is_central, self->conn_handle, self->ediv)) { // Did an sd_ble_gatts_sys_attr_set() with the stored sys_attr values. // Not quite paired yet: wait for BLE_GAP_EVT_AUTH_STATUS with BLE_GAP_SEC_STATUS_SUCCESS. - CONNECTION_DEBUG_PRINTF("did bonding_load_cccd_info()\n"); } else { // No matching bonding found, so use fresh system attributes. - CONNECTION_DEBUG_PRINTF("bonding_load_cccd_info() failed\n"); sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); } self->pair_status = PAIR_PAIRED; @@ -301,10 +294,8 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } default: - CONNECTION_DEBUG_PRINTF("Unhandled event: %04x\n", ble_evt->header.evt_id); return false; } - CONNECTION_DEBUG_PRINTF("Handled event: %04x\n", ble_evt->header.evt_id); return true; } @@ -590,8 +581,7 @@ STATIC bool discovery_on_ble_evt(ble_evt_t *ble_evt, mp_obj_t payload) { break; default: - // For debugging. - // mp_printf(&mp_plat_print, "Unhandled discovery event: 0x%04x\n", ble_evt->header.evt_id); + // CONNECTION_DEBUG_PRINTF(&mp_plat_print, "Unhandled discovery event: 0x%04x\n", ble_evt->header.evt_id); return false; break; } diff --git a/ports/nrf/common-hal/_bleio/Connection.h b/ports/nrf/common-hal/_bleio/Connection.h index daa7f64464..a9e82dd394 100644 --- a/ports/nrf/common-hal/_bleio/Connection.h +++ b/ports/nrf/common-hal/_bleio/Connection.h @@ -57,8 +57,8 @@ typedef struct { // The advertising data and scan response buffers are held by us, not by the SD, so we must // maintain them and not change it. If we need to change the contents during advertising, // there are tricks to get the SD to notice (see DevZone - TBS). - // EDIV: Encrypted Diversifier: Identifies LTK during legacy pairing. bonding_keys_t bonding_keys; + // EDIV: Encrypted Diversifier: Identifies LTK during legacy pairing. uint16_t ediv; volatile pair_status_t pair_status; uint8_t sec_status; // Internal security status. @@ -66,6 +66,13 @@ typedef struct { ble_drv_evt_handler_entry_t handler_entry; ble_gap_conn_params_t conn_params; volatile bool conn_params_updating; + // Request that CCCD info for this connection be saved. + volatile bool do_bond_cccds; + // Request that security key info for this connection be saved. + volatile bool do_bond_keys; + // Time of setting do_bond_ccds: we delay a bit to consolidate multiple CCCD changes + // into one write. Time is currently in ticks_ms. + uint64_t do_bond_cccds_request_time; } bleio_connection_internal_t; typedef struct { diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c index 56f77af852..eb30ee8b19 100644 --- a/ports/nrf/common-hal/_bleio/bonding.c +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -36,7 +36,6 @@ #include "supervisor/shared/tick.h" #include "nrf_soc.h" -#include "sd_mutex.h" #include "bonding.h" @@ -57,9 +56,6 @@ const uint32_t BONDING_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); // Save both system and user service info. #define SYS_ATTR_FLAGS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS) -STATIC nrf_mutex_t queued_bonding_block_entries_mutex; -STATIC uint64_t block_queued_at_ticks_ms = 0; - #if BONDING_DEBUG void bonding_print_block(bonding_block_t *block) { printf("at 0x%08lx: is_central: %1d, type: 0x%x, ediv: 0x%04x, data_length: %d\n", @@ -80,7 +76,6 @@ STATIC size_t compute_block_size(uint16_t data_length) { } void bonding_erase_storage(void) { - BONDING_DEBUG_PRINTF("bonding_erase_storage()\n"); // Erase all pages in the bonding area. for(uint32_t page_address = BONDING_PAGES_START_ADDR; page_address < BONDING_PAGES_END_ADDR; @@ -125,7 +120,7 @@ STATIC bonding_block_t *next_block(bonding_block_t *block) { // Find the block with given is_central, type and ediv value. // If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. // If not found, return NULL. -STATIC bonding_block_t *find_candidate_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { +STATIC bonding_block_t *find_existing_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { bonding_block_t *block = NULL; while (1) { block = next_block(block); @@ -149,7 +144,7 @@ STATIC bonding_block_t *find_candidate_block(bool is_central, bonding_block_type // Get an empty block large enough to store data_length data. STATIC bonding_block_t* find_unused_block(uint16_t data_length) { - bonding_block_t *unused_block = find_candidate_block(true, BLOCK_UNUSED, EDIV_INVALID); + bonding_block_t *unused_block = find_existing_block(true, BLOCK_UNUSED, EDIV_INVALID); // If no more room, erase all existing blocks and start over. if (!unused_block || (uint8_t *) unused_block + compute_block_size(data_length) >= (uint8_t *) BONDING_DATA_END_ADDR) { @@ -162,56 +157,10 @@ STATIC bonding_block_t* find_unused_block(uint16_t data_length) { // Set the header word to all 0's, to mark the block as invalid. // We don't change data_length, so we can still skip over this block. STATIC void invalidate_block(bonding_block_t *block) { - BONDING_DEBUG_PRINTF("invalidate_block()\n"); uint32_t zero = 0; sd_flash_write_sync((uint32_t *) block, &zero, 1); } -STATIC void queue_write_block(bool is_central, bonding_block_type_t type, uint16_t ediv, uint16_t conn_handle, uint8_t *data, uint16_t data_length) { - if (compute_block_size(data_length) > BONDING_DATA_END_ADDR - BONDING_DATA_START_ADDR) { - // Ridiculous size. - return; - } - - // No heap available, so never mind. This might be called between VM instantiations. - if (!gc_alloc_possible()) { - return; - } - queued_bonding_block_entry_t* queued_entry = - m_malloc_maybe(sizeof(queued_bonding_block_entry_t) + data_length, false); - - if (!queued_entry) { - // Failed to allocate. Not much we can do, since this might be during an evt handler. - return; - } - - queued_entry->block.is_central = is_central; - queued_entry->block.type = type; - queued_entry->block.ediv = ediv; - queued_entry->block.conn_handle = conn_handle; - queued_entry->block.data_length = data_length; - if (data && data_length != 0) { - memcpy(&queued_entry->block.data, data, data_length); - } - - // Note: blocks are added in LIFO order, for simplicity and speed. - // The assumption is that there won't be stale blocks on the - // list. The sys_attr blocks don't contain sys_attr data, just a - // request to store the latest value. The key blocks are assumed - // not to be superseded quickly. If this assumption becomes - // invalid, the queue should be changed to FIFO. - - // Add this new element to the front of the list. - sd_mutex_acquire_wait(&queued_bonding_block_entries_mutex); - queued_entry->next = MP_STATE_VM(queued_bonding_block_entries); - MP_STATE_VM(queued_bonding_block_entries) = queued_entry; - sd_mutex_release(&queued_bonding_block_entries_mutex); - - // Remember when we last queued a block, so we avoid excesive - // sys_attr writes. - block_queued_at_ticks_ms = supervisor_ticks_ms64(); -} - // Write bonding block header. STATIC void write_block_header(bonding_block_t *dest_block, bonding_block_t *source_block_header) { sd_flash_write_sync((uint32_t *) dest_block, (uint32_t *) source_block_header, sizeof(bonding_block_t) / 4); @@ -237,134 +186,109 @@ STATIC void write_block_data(bonding_block_t *dest_block, uint8_t *data, uint16_ } } -STATIC void write_sys_attr_block(bonding_block_t *block) { +STATIC void write_sys_attr_block(bleio_connection_internal_t *connection) { uint16_t length = 0; // First find out how big a buffer we need, then fetch the data. - if(sd_ble_gatts_sys_attr_get(block->conn_handle, NULL, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + if(sd_ble_gatts_sys_attr_get(connection->conn_handle, NULL, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { return; } - uint8_t sys_attr[length]; - if(sd_ble_gatts_sys_attr_get(block->conn_handle, sys_attr, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + if(sd_ble_gatts_sys_attr_get(connection->conn_handle, sys_attr, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { return; } - // Now we know the data size. - block->data_length = length; - // Is there an existing sys_attr block that matches the current sys_attr data? - bonding_block_t *candidate_block = find_candidate_block(block->is_central, block->type, block->ediv); - if (candidate_block) { - if (length == candidate_block->data_length && - memcmp(sys_attr, candidate_block->data, block->data_length) == 0) { - BONDING_DEBUG_PRINTF("Identical sys_attr block already stored.\n"); + bonding_block_t *existing_block = + find_existing_block(connection->is_central, BLOCK_SYS_ATTR, connection->ediv); + if (existing_block) { + if (length == existing_block->data_length && + memcmp(sys_attr, existing_block->data, length) == 0) { // Identical block found. No need to store again. return; } // Data doesn't match. Invalidate block and store a new one. - invalidate_block(candidate_block); + invalidate_block(existing_block); } + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_SYS_ATTR, + .ediv = connection->ediv, + .conn_handle = connection->conn_handle, + .data_length = length, + }; bonding_block_t *new_block = find_unused_block(length); - write_block_header(new_block, block); + write_block_header(new_block, &block_header); write_block_data(new_block, sys_attr, length); return; } -STATIC void write_keys_block(bonding_block_t *block) { - if (block->data_length != sizeof(bonding_keys_t)) { - // Bad length. - return; - } +STATIC void write_keys_block(bleio_connection_internal_t *connection) { + uint16_t const ediv = connection->is_central + ? connection->bonding_keys.peer_enc.master_id.ediv + : connection->bonding_keys.own_enc.master_id.ediv; // Is there an existing keys block that matches? - bonding_block_t *candidate_block = find_candidate_block(block->is_central, block->type, block->ediv); - if (candidate_block) { - if (block->data_length == candidate_block->data_length && - memcmp(block->data, candidate_block->data, block->data_length) == 0) { - BONDING_DEBUG_PRINTF("Identical keys block already stored.\n"); + bonding_block_t *existing_block = find_existing_block(connection->is_central, BLOCK_KEYS, ediv); + if (existing_block) { + if (existing_block->data_length == sizeof(bonding_keys_t) && + memcmp(existing_block->data, &connection->bonding_keys, sizeof(bonding_keys_t)) == 0) { // Identical block found. No need to store again. return; } // Data doesn't match. Invalidate block and store a new one. - invalidate_block(candidate_block); + invalidate_block(existing_block); } - bonding_keys_t *bonding_keys = (bonding_keys_t *) block->data; - block->ediv = block->is_central - ? bonding_keys->peer_enc.master_id.ediv - : bonding_keys->own_enc.master_id.ediv; + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_KEYS, + .ediv = ediv, + .conn_handle = connection->conn_handle, + .data_length = sizeof(bonding_keys_t), + }; bonding_block_t *new_block = find_unused_block(sizeof(bonding_keys_t)); - write_block_header(new_block, block); - write_block_data(new_block, (uint8_t *) bonding_keys, sizeof(bonding_keys_t)); + write_block_header(new_block, &block_header); + write_block_data(new_block, (uint8_t *) &connection->bonding_keys, sizeof(bonding_keys_t)); } - void bonding_clear_keys(bonding_keys_t *bonding_keys) { memset((uint8_t*) bonding_keys, 0, sizeof(bonding_keys_t)); } -// Call only when SD is enabled. void bonding_reset(void) { - MP_STATE_VM(queued_bonding_block_entries) = NULL; - sd_mutex_new(&queued_bonding_block_entries_mutex); if (BONDING_FLAG != *((uint32_t *) BONDING_START_FLAG_ADDR) || BONDING_FLAG != *((uint32_t *) BONDING_END_FLAG_ADDR)) { bonding_erase_storage(); } } -// Write bonding blocks to flash. These have been queued during event handlers. -// We do one at a time, on each background call. +// Write bonding blocks to flash. Requests have been queued during evt handlers. void bonding_background(void) { - uint8_t sd_en = 0; - (void) sd_softdevice_is_enabled(&sd_en); - if (!sd_en) { - return; - } + // A paired connection will request that its keys and CCCD values be stored. + // The CCCD store whenever a CCCD value is written. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &connections[i]; - if (block_queued_at_ticks_ms == 0) { - // No writes have been queued yet. - return; - } + uint64_t current_ticks_ms = supervisor_ticks_ms64(); + // Wait at least one second before saving CCCD, to consolidate + // writes that involve multiple CCCDs. For instance, for HID, + // three CCCD's are set in short succession by the HID client. + if (connection->do_bond_cccds && + current_ticks_ms - connection->do_bond_cccds_request_time >= 1000) { + write_sys_attr_block(connection); + connection->do_bond_cccds = false; + } - // Wait at least one second before writing a block, to consolidate writes - // that will be duplicates. - uint64_t current_ticks_ms = supervisor_ticks_ms64(); - if (current_ticks_ms - block_queued_at_ticks_ms < 1000) { - return; - } - - // Get block at front of list. - bonding_block_t *block = NULL; - sd_mutex_acquire_wait(&queued_bonding_block_entries_mutex); - if (MP_STATE_VM(queued_bonding_block_entries)) { - block = &(MP_STATE_VM(queued_bonding_block_entries)->block); - // Remove entry from list. - MP_STATE_VM(queued_bonding_block_entries) = MP_STATE_VM(queued_bonding_block_entries)->next; - } - sd_mutex_release(&queued_bonding_block_entries_mutex); - if (!block) { - // List is empty. - return; - } - - switch (block->type) { - case BLOCK_SYS_ATTR: - write_sys_attr_block(block); - break; - - case BLOCK_KEYS: - write_keys_block(block); - break; - - default: - break; + if (connection->do_bond_keys) { + write_keys_block(connection); + connection->do_bond_keys = false; + } } } bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { - bonding_block_t *block = find_candidate_block(is_central, BLOCK_SYS_ATTR, ediv); + bonding_block_t *block = find_existing_block(is_central, BLOCK_SYS_ATTR, ediv); if (block == NULL) { return false; } @@ -374,7 +298,7 @@ bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv } bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { - bonding_block_t *block = find_candidate_block(is_central, BLOCK_KEYS, ediv); + bonding_block_t *block = find_existing_block(is_central, BLOCK_KEYS, ediv); if (block == NULL) { return false; } @@ -386,15 +310,3 @@ bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_k memcpy(bonding_keys, block->data, block->data_length); return true; } - -void bonding_save_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { - BONDING_DEBUG_PRINTF("bonding_save_cccd_info()\n"); - queue_write_block(is_central, BLOCK_SYS_ATTR, ediv, conn_handle, NULL, 0); -} - -void bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys) { - uint16_t const ediv = is_central - ? bonding_keys->peer_enc.master_id.ediv - : bonding_keys->own_enc.master_id.ediv; - queue_write_block(is_central, BLOCK_KEYS, ediv, conn_handle, (uint8_t *) bonding_keys, sizeof(bonding_keys_t)); -} diff --git a/ports/nrf/common-hal/_bleio/bonding.h b/ports/nrf/common-hal/_bleio/bonding.h index 35347af2a6..cb8e7c427b 100644 --- a/ports/nrf/common-hal/_bleio/bonding.h +++ b/ports/nrf/common-hal/_bleio/bonding.h @@ -48,11 +48,12 @@ #define BONDING_DEBUG_PRINT_KEYS(keys) #endif -// Bonding data is stored in variable-length blocks consecutively in erased flash. -// The blocks are 32-bit aligned, though the data may be any number of bytes. -// You can hop through the blocks using the size field to find the next block. -// When you hit a word that is all one's, you have reached the end of the blocks. -// You can write a new block there. +// Bonding data is stored in variable-length blocks consecutively in +// erased flash (all 1's). The blocks are 32-bit aligned, though the +// data may be any number of bytes. We hop through the blocks using +// the size field to find the next block. When we hit a word that is +// all 1's, we have reached the end of the blocks. We can write a new +// block there. typedef enum { BLOCK_INVALID = 0, // Ignore this block @@ -69,24 +70,16 @@ typedef struct { uint16_t conn_handle; // Connection handle: used when a BLOCK_SYS_ATTR is queued to write. // Not used as a key, etc. uint16_t data_length; // Length of data in bytes, including ediv, not including padding. - // 32-bit boundary here. + // End of block header. 32-bit boundary here. uint8_t data[]; // Rest of data in the block. Needs to be 32-bit aligned. // Block is padded to 32-bit alignment. } bonding_block_t; -// Bonding blocks that need to be written are stored in a linked list. -typedef struct _queued_bonding_block_entry_t { - struct _queued_bonding_block_entry_t *next; - bonding_block_t block; // variable length, based on data_length. -} queued_bonding_block_entry_t; - void bonding_background(void); void bonding_erase_storage(void); void bonding_reset(void); void bonding_clear_keys(bonding_keys_t *bonding_keys); bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys); -void bonding_save_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); -void bonding_save_keys(bool is_central, uint16_t conn_handle, bonding_keys_t *bonding_keys); #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BONDING_H diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index a480ec1e0d..70b9ab63e6 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -156,7 +156,6 @@ #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS \ ble_drv_evt_handler_entry_t* ble_drv_evt_handler_entries; \ - queued_bonding_block_entry_t* queued_bonding_block_entries; \ #endif // NRF5_MPCONFIGPORT_H__ From 0367ba7495e209e38ff80934affe9e7fb3f04cff Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 13 Jan 2020 18:29:34 -0500 Subject: [PATCH 332/531] fix some typos and leftovers --- locale/circuitpython.pot | 22 ++++------ ports/nrf/common-hal/_bleio/Connection.c | 3 +- ports/nrf/common-hal/_bleio/Connection.h | 1 + ports/nrf/mpconfigport.h | 1 - ports/nrf/sd.c | 54 ------------------------ ports/nrf/sd.h | 46 -------------------- tools/preprocess_frozen_modules.py | 1 - 7 files changed, 11 insertions(+), 117 deletions(-) delete mode 100644 ports/nrf/sd.c delete mode 100644 ports/nrf/sd.h diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 085101ff15..a60d95aa24 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-13 18:15-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -513,21 +513,21 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "" @@ -620,7 +620,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/sd_mutex.c +#: ports/nrf/sd.c ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "" @@ -643,11 +643,11 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" -#: ports/nrf/sd_mutex.c +#: ports/nrf/sd.c ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "" @@ -660,10 +660,6 @@ msgstr "" msgid "File exists" msgstr "" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" @@ -1776,7 +1772,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index b8fa77cd37..96e8b8fbe9 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -308,7 +308,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } else { if (bonding_load_cccd_info(self->is_central, self->conn_handle, self->ediv)) { // Did an sd_ble_gatts_sys_attr_set() with the stored sys_attr values. - // Not quite paired yet: wait for BLE_GAP_EVT_AUTH_STATUS with BLE_GAP_SEC_STATUS_SUCCESS. } else { // No matching bonding found, so use fresh system attributes. sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); @@ -553,7 +552,7 @@ STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, bleio default: // TODO: sd_ble_gattc_descriptors_discover() can return things that are not descriptors, // so ignore those. - // htts:p//devzone.nordicsemi.com/f/nordic-q-a/49500/sd_ble_gattc_descriptors_discover-is-returning-attributes-that-are-not-descriptors + // https://devzone.nordicsemi.com/f/nordic-q-a/49500/sd_ble_gattc_descriptors_discover-is-returning-attributes-that-are-not-descriptors break; } diff --git a/ports/nrf/common-hal/_bleio/Connection.h b/ports/nrf/common-hal/_bleio/Connection.h index 1f40cc6446..282e0c4b5d 100644 --- a/ports/nrf/common-hal/_bleio/Connection.h +++ b/ports/nrf/common-hal/_bleio/Connection.h @@ -67,6 +67,7 @@ typedef struct { ble_gap_conn_params_t conn_params; volatile bool conn_params_updating; uint16_t mtu; + // Request that CCCD values for this conenction be saved, using sys_attr values. volatile bool do_bond_cccds; // Request that security key info for this connection be saved. volatile bool do_bond_keys; diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 70b9ab63e6..b6635965de 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -29,7 +29,6 @@ #define NRF5_MPCONFIGPORT_H__ #include "ble_drv.h" -#include "common-hal/_bleio/bonding.h" #include "nrf_mbr.h" // for MBR_SIZE #include "nrf_sdm.h" // for SD_FLASH_SIZE diff --git a/ports/nrf/sd.c b/ports/nrf/sd.c deleted file mode 100644 index b3162e6af9..0000000000 --- a/ports/nrf/sd.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 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. - */ - -#include "py/mpconfig.h" -#include "py/runtime.h" -#include "nrf_soc.h" - -void sd_mutex_acquire_check(nrf_mutex_t* p_mutex) { - uint32_t err_code = sd_mutex_acquire(p_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to acquire mutex, err 0x%04x"), err_code); - } -} - -void sd_mutex_acquire_wait(nrf_mutex_t* p_mutex) { - while (sd_mutex_acquire(p_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { - RUN_BACKGROUND_TASKS; - } -} - -void sd_mutex_acquire_wait_no_vm(nrf_mutex_t* p_mutex) { - while (sd_mutex_acquire(p_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { - } -} - -void sd_mutex_release_check(nrf_mutex_t* p_mutex) { - uint32_t err_code = sd_mutex_release(p_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to release mutex, err 0x%04x"), err_code); - } -} diff --git a/ports/nrf/sd.h b/ports/nrf/sd.h deleted file mode 100644 index ca46917205..0000000000 --- a/ports/nrf/sd.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 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. - */ - -#ifndef MICROPY_INCLUDED_NRF_SD_MUTEX_H -#define MICROPY_INCLUDED_NRF_SD_MUTEX_H - -#include "nrf_soc.h" - -// Helpers for common usage of nrf_mutex. - -// Try to acquire a mutex right now. Raise exception if we can't get it. -void sd_mutex_acquire_check(nrf_mutex_t* p_mutex); - -// Wait for a mutex to become available. Run VM background tasks while waiting. -void sd_mutex_acquire_wait(nrf_mutex_t* p_mutex); - -// Wait for a mutex to become available.. Block VM while waiting. -void sd_mutex_acquire_wait_no_vm(nrf_mutex_t* p_mutex); - -// Release a mutex, and raise exception on error. -void sd_mutex_release_check(nrf_mutex_t* p_mutex); - -#endif // MICROPY_INCLUDED_NRF_SD_MUTEX_H diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py index 974ccecd18..7ae20c4d61 100755 --- a/tools/preprocess_frozen_modules.py +++ b/tools/preprocess_frozen_modules.py @@ -48,7 +48,6 @@ def copy_and_process(in_dir, out_dir): output_file_path = Path(out_dir, input_file_path.relative_to(in_dir)) if file.endswith(".py"): - print(file) if not output_file_path.parent.exists(): output_file_path.parent.mkdir(parents=True) with input_file_path.open("r") as input, output_file_path.open("w") as output: From c735289ddfe4c1a87f051d930e149fa93d09535d Mon Sep 17 00:00:00 2001 From: scs217 Date: Mon, 13 Jan 2020 21:19:17 -0500 Subject: [PATCH 333/531] Added Dxx names to analog pins on Feather M4 Express pins.c file --- ports/atmel-samd/boards/feather_m4_express/pins.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ports/atmel-samd/boards/feather_m4_express/pins.c b/ports/atmel-samd/boards/feather_m4_express/pins.c index d9496ecfc7..83b447ea71 100644 --- a/ports/atmel-samd/boards/feather_m4_express/pins.c +++ b/ports/atmel-samd/boards/feather_m4_express/pins.c @@ -2,14 +2,23 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PA05) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_PB09) }, { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_PB23) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_PB22) }, { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB17) }, { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17) }, { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB16) }, From 18957786f24ac2d198a793fcffb02d71b474b401 Mon Sep 17 00:00:00 2001 From: scs217 Date: Mon, 13 Jan 2020 22:00:42 -0500 Subject: [PATCH 334/531] inserted line breaks between different pins (grouping together aliases for legibility) per request by dhalbert --- .../boards/feather_m4_express/pins.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ports/atmel-samd/boards/feather_m4_express/pins.c b/ports/atmel-samd/boards/feather_m4_express/pins.c index 83b447ea71..314b6f1c6c 100644 --- a/ports/atmel-samd/boards/feather_m4_express/pins.c +++ b/ports/atmel-samd/boards/feather_m4_express/pins.c @@ -3,41 +3,66 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB09) }, { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB23) }, { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB22) }, { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB17) }, { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB16) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA21) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 50e718be99f340bcf7ab003d36d920d1de4b0dd3 Mon Sep 17 00:00:00 2001 From: scs217 Date: Mon, 13 Jan 2020 22:13:39 -0500 Subject: [PATCH 335/531] second revision to line breaks for visibility per dhalbert --- ports/atmel-samd/boards/feather_m4_express/pins.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ports/atmel-samd/boards/feather_m4_express/pins.c b/ports/atmel-samd/boards/feather_m4_express/pins.c index 314b6f1c6c..61bd8abadf 100644 --- a/ports/atmel-samd/boards/feather_m4_express/pins.c +++ b/ports/atmel-samd/boards/feather_m4_express/pins.c @@ -35,23 +35,14 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA12) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA13) }, - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA14) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA16) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA18) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA19) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA20) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA21) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB03) }, @@ -60,9 +51,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From c0dacba80f3c7490f36dda3fa2c7b0df842c8bcf Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 14 Jan 2020 13:06:10 -0500 Subject: [PATCH 336/531] remove comment confusing py tools --- ports/stm32f4/boards/STM32F401.ld | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/ports/stm32f4/boards/STM32F401.ld b/ports/stm32f4/boards/STM32F401.ld index be72ecc091..bf1f21cf61 100644 --- a/ports/stm32f4/boards/STM32F401.ld +++ b/ports/stm32f4/boards/STM32F401.ld @@ -35,19 +35,6 @@ _ram_end = ORIGIN(RAM) + LENGTH(RAM); _heap_start = _ebss; /* heap starts just after statically allocated memory */ _heap_end = _sstack; -/* Memory layout for internal flash storage configuration: - - FLASH_ISR .isr_vector - - FLASH_TEXT .text - FLASH_TEXT .data - - RAM .data - RAM .bss - RAM .heap - RAM .stack -*/ - ENTRY(Reset_Handler) /* define output sections */ From 5aae8df5d7cd7edf18f6ff6ac81c16facba178c7 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 14 Jan 2020 13:30:16 -0500 Subject: [PATCH 337/531] style changes, fix i2c typo --- ports/stm32f4/common-hal/busio/I2C.c | 18 ++++---- ports/stm32f4/common-hal/busio/SPI.c | 30 +++++++------- ports/stm32f4/common-hal/busio/UART.c | 4 +- ports/stm32f4/common-hal/pulseio/PWMOut.c | 50 +++++++++++------------ 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index bf843ff5cb..1437e5e784 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -61,8 +61,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, //match pins to I2C objects I2C_TypeDef * I2Cx; - uint8_t sda_len = sizeof(mcu_i2c_sda_list) / sizeof(*mcu_i2c_sda_list); - uint8_t scl_len = sizeof(mcu_i2c_scl_list) / sizeof(*mcu_i2c_scl_list); + uint8_t sda_len = MP_ARRAY_SIZE(mcu_i2c_sda_list); + uint8_t scl_len = MP_ARRAY_SIZE(mcu_i2c_scl_list); bool i2c_taken = false; for (uint i = 0; i < sda_len; i++) { @@ -137,7 +137,7 @@ void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_i2c[i] = true; never_reset_pin_number(self->scl->pin->port, self->scl->pin->number); - never_reset_pin_number(self->sda->pin->port, self->scl->pin->number); + never_reset_pin_number(self->sda->pin->port, self->sda->pin->number); break; } } @@ -209,21 +209,21 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, STATIC void i2c_clock_enable(uint8_t mask) { //Note: hard reset required due to soft reboot issue. #ifdef I2C1 - if (mask & 1<<0) { + if (mask & (1 << 0)) { __HAL_RCC_I2C1_CLK_ENABLE(); __HAL_RCC_I2C1_FORCE_RESET(); __HAL_RCC_I2C1_RELEASE_RESET(); } #endif #ifdef I2C2 - if (mask & 1<<1) { + if (mask & (1 << 1)) { __HAL_RCC_I2C2_CLK_ENABLE(); __HAL_RCC_I2C2_FORCE_RESET(); __HAL_RCC_I2C2_RELEASE_RESET(); } #endif #ifdef I2C3 - if (mask & 1<<2) { + if (mask & (1 << 2)) { __HAL_RCC_I2C3_CLK_ENABLE(); __HAL_RCC_I2C3_FORCE_RESET(); __HAL_RCC_I2C3_RELEASE_RESET(); @@ -233,17 +233,17 @@ STATIC void i2c_clock_enable(uint8_t mask) { STATIC void i2c_clock_disable(uint8_t mask) { #ifdef I2C1 - if (mask & 1<<0) { + if (mask & (1 << 0)) { __HAL_RCC_I2C1_CLK_DISABLE(); } #endif #ifdef I2C2 - if (mask & 1<<1) { + if (mask & (1 << 1)) { __HAL_RCC_I2C2_CLK_DISABLE(); } #endif #ifdef I2C3 - if (mask & 1<<2) { + if (mask & (1 << 2)) { __HAL_RCC_I2C3_CLK_DISABLE(); } #endif diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index b7d61fbf92..afc6cfcbd5 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -104,9 +104,9 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, //match pins to SPI objects SPI_TypeDef * SPIx; - uint8_t sck_len = sizeof(mcu_spi_sck_list)/sizeof(*mcu_spi_sck_list); - uint8_t mosi_len = sizeof(mcu_spi_mosi_list)/sizeof(*mcu_spi_mosi_list); - uint8_t miso_len = sizeof(mcu_spi_miso_list)/sizeof(*mcu_spi_miso_list); + uint8_t sck_len = MP_ARRAY_SIZE(mcu_spi_sck_list); + uint8_t mosi_len = MP_ARRAY_SIZE(mcu_spi_mosi_list); + uint8_t miso_len = MP_ARRAY_SIZE(mcu_spi_miso_list); bool spi_taken = false; //SCK is not optional. MOSI and MISO are @@ -393,32 +393,32 @@ uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) { STATIC void spi_clock_enable(uint8_t mask) { #ifdef SPI1 - if (mask & 1<<0) { + if (mask & (1 << 0)) { __HAL_RCC_SPI1_CLK_ENABLE(); } #endif #ifdef SPI2 - if (mask & 1<<1) { + if (mask & (1 << 1)) { __HAL_RCC_SPI2_CLK_ENABLE(); } #endif #ifdef SPI3 - if (mask & 1<<2) { + if (mask & (1 << 2)) { __HAL_RCC_SPI3_CLK_ENABLE(); } #endif #ifdef SPI4 - if (mask & 1<<3) { + if (mask & (1 << 3)) { __HAL_RCC_SPI4_CLK_ENABLE(); } #endif #ifdef SPI5 - if (mask & 1<<4) { + if (mask & (1 << 4)) { __HAL_RCC_SPI5_CLK_ENABLE(); } #endif #ifdef SPI6 - if (mask & 1<<5) { + if (mask & (1 << 5)) { __HAL_RCC_SPI6_CLK_ENABLE(); } #endif @@ -426,32 +426,32 @@ STATIC void spi_clock_enable(uint8_t mask) { STATIC void spi_clock_disable(uint8_t mask) { #ifdef SPI1 - if (mask & 1<<0) { + if (mask & (1 << 0)) { __HAL_RCC_SPI1_CLK_DISABLE(); } #endif #ifdef SPI2 - if (mask & 1<<1) { + if (mask & (1 << 1)) { __HAL_RCC_SPI2_CLK_DISABLE(); } #endif #ifdef SPI3 - if (mask & 1<<2) { + if (mask & (1 << 2)) { __HAL_RCC_SPI3_CLK_DISABLE(); } #endif #ifdef SPI4 - if (mask & 1<<3) { + if (mask & (1 << 3)) { __HAL_RCC_SPI4_CLK_DISABLE(); } #endif #ifdef SPI5 - if (mask & 1<<4) { + if (mask & (1 << 4)) { __HAL_RCC_SPI5_CLK_DISABLE(); } #endif #ifdef SPI6 - if (mask & 1<<5) { + if (mask & (1 << 5)) { __HAL_RCC_SPI6_CLK_DISABLE(); } #endif diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index 44139a642f..bfa541c17d 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -79,8 +79,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, //match pins to UART objects USART_TypeDef * USARTx; - uint8_t tx_len = sizeof(mcu_uart_tx_list) / sizeof(*mcu_uart_tx_list); - uint8_t rx_len = sizeof(mcu_uart_rx_list) / sizeof(*mcu_uart_rx_list); + uint8_t tx_len = MP_ARRAY_SIZE(mcu_uart_tx_list); + uint8_t rx_len = MP_ARRAY_SIZE(mcu_uart_rx_list); bool uart_taken = false; uint8_t uart_index = 0; //origin 0 corrected diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index a53bfc4231..a750314e1a 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -106,7 +106,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, uint32_t frequency, bool variable_frequency) { TIM_TypeDef * TIMx; - uint8_t tim_num = sizeof(mcu_tim_pin_list) / sizeof(*mcu_tim_pin_list); + uint8_t tim_num = MP_ARRAY_SIZE(mcu_tim_pin_list); bool tim_chan_taken = false; bool tim_taken_f_mismatch = false; bool var_freq_mismatch = false; @@ -324,63 +324,63 @@ bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self STATIC void tim_clock_enable(uint16_t mask) { #ifdef TIM1 - if (mask & 1<<0) { + if (mask & (1 << 0)) { __HAL_RCC_TIM1_CLK_ENABLE(); } #endif #ifdef TIM2 - if (mask & 1<<1) { + if (mask & (1 << 1)) { __HAL_RCC_TIM2_CLK_ENABLE(); } #endif #ifdef TIM3 - if (mask & 1<<2) { + if (mask & (1 << 2)) { __HAL_RCC_TIM3_CLK_ENABLE(); } #endif #ifdef TIM4 - if (mask & 1<<3) { + if (mask & (1 << 3)) { __HAL_RCC_TIM4_CLK_ENABLE(); } #endif #ifdef TIM5 - if (mask & 1<<4) { + if (mask & (1 << 4)) { __HAL_RCC_TIM5_CLK_ENABLE(); } #endif //6 and 7 are reserved ADC timers #ifdef TIM8 - if (mask & 1<<7) { + if (mask & (1 << 7)) { __HAL_RCC_TIM8_CLK_ENABLE(); } #endif #ifdef TIM9 - if (mask & 1<<8) { + if (mask & (1 << 8)) { __HAL_RCC_TIM9_CLK_ENABLE(); } #endif #ifdef TIM10 - if (mask & 1<<9) { + if (mask & (1 << 9)) { __HAL_RCC_TIM10_CLK_ENABLE(); } #endif #ifdef TIM11 - if (mask & 1<<10) { + if (mask & (1 << 10)) { __HAL_RCC_TIM11_CLK_ENABLE(); } #endif #ifdef TIM12 - if (mask & 1<<11) { + if (mask & (1 << 11)) { __HAL_RCC_TIM12_CLK_ENABLE(); } #endif #ifdef TIM13 - if (mask & 1<<12) { + if (mask & (1 << 12)) { __HAL_RCC_TIM13_CLK_ENABLE(); } #endif #ifdef TIM14 - if (mask & 1<<13) { + if (mask & (1 << 13)) { __HAL_RCC_TIM14_CLK_ENABLE(); } #endif @@ -388,63 +388,63 @@ STATIC void tim_clock_enable(uint16_t mask) { STATIC void tim_clock_disable(uint16_t mask) { #ifdef TIM1 - if (mask & 1<<0) { + if (mask & (1 << 0)) { __HAL_RCC_TIM1_CLK_DISABLE(); } #endif #ifdef TIM2 - if (mask & 1<<1) { + if (mask & (1 << 1)) { __HAL_RCC_TIM2_CLK_DISABLE(); } #endif #ifdef TIM3 - if (mask & 1<<2) { + if (mask & (1 << 2)) { __HAL_RCC_TIM3_CLK_DISABLE(); } #endif #ifdef TIM4 - if (mask & 1<<3) { + if (mask & (1 << 3)) { __HAL_RCC_TIM4_CLK_DISABLE(); } #endif #ifdef TIM5 - if (mask & 1<<4) { + if (mask & (1 << 4)) { __HAL_RCC_TIM5_CLK_DISABLE(); } #endif //6 and 7 are reserved ADC timers #ifdef TIM8 - if (mask & 1<<7) { + if (mask & (1 << 7)) { __HAL_RCC_TIM8_CLK_DISABLE(); } #endif #ifdef TIM9 - if (mask & 1<<8) { + if (mask & (1 << 8)) { __HAL_RCC_TIM9_CLK_DISABLE(); } #endif #ifdef TIM10 - if (mask & 1<<9) { + if (mask & (1 << 9)) { __HAL_RCC_TIM10_CLK_DISABLE(); } #endif #ifdef TIM11 - if (mask & 1<<10) { + if (mask & (1 << 10)) { __HAL_RCC_TIM11_CLK_DISABLE(); } #endif #ifdef TIM12 - if (mask & 1<<11) { + if (mask & (1 << 11)) { __HAL_RCC_TIM12_CLK_DISABLE(); } #endif #ifdef TIM13 - if (mask & 1<<12) { + if (mask & (1 << 12)) { __HAL_RCC_TIM13_CLK_DISABLE(); } #endif #ifdef TIM14 - if (mask & 1<<13) { + if (mask & (1 << 13)) { __HAL_RCC_TIM14_CLK_DISABLE(); } #endif From 05093f7f54d5f0a375d120df40e3335fa92e0a22 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 14 Jan 2020 15:50:00 -0500 Subject: [PATCH 338/531] Fix VTOR relocate, add bootloader makefile handling --- ports/stm32f4/Makefile | 6 +++- .../boards/meowbit_v121/mpconfigboard.h | 1 + .../boards/meowbit_v121/mpconfigboard.mk | 2 ++ ports/stm32f4/system_stm32f4xx.c | 35 ++++++++++++++++--- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index c3eb4aa3b0..d948996ea4 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -90,6 +90,10 @@ else ### CFLAGS += -flto endif +ifndef BOOTLOADER_OFFSET + BOOTLOADER_OFFSET := 0x8000000 +endif + C_DEFS = -DMCU_PACKAGE=$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(CMSIS_MCU) CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) @@ -257,7 +261,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(ECHO) "Create $@" - $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b 0x08010000 -c -o "$(BUILD)/firmware.uf2" $^ + $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b $(BOOTLOADER_OFFSET) -c -o "$(BUILD)/firmware.uf2" $^ include $(TOP)/py/mkrules.mk diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 0371685d8b..0de74a946c 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -37,6 +37,7 @@ #define BOARD_OSC_DIV 12 #define BOARD_NO_VBUS_SENSE +#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index c033d1d4bc..1d6f68b13c 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -9,6 +9,8 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ LONGINT_IMPL = MPZ +BOOTLOADER_OFFSET = 0x8010000 + # INTERNAL_FLASH_FILESYSTEM = 1 # LONGINT_IMPL = NONE diff --git a/ports/stm32f4/system_stm32f4xx.c b/ports/stm32f4/system_stm32f4xx.c index 3303f969d9..bce420056d 100644 --- a/ports/stm32f4/system_stm32f4xx.c +++ b/ports/stm32f4/system_stm32f4xx.c @@ -1,3 +1,27 @@ +/* + * Taken from ST Cube library and modified. See below for original header. + * + * Modifications copyright (c) 2019 Lucian Copeland 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. + */ + /** ****************************************************************************** * @file system_stm32f4xx.c @@ -63,6 +87,7 @@ #include "stm32f4xx.h" +#include "py/mpconfig.h" #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ @@ -193,10 +218,12 @@ void SystemInit(void) #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ /* Configure the Vector Table location add offset address ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#if !defined(BOARD_VTOR_DEFER) //only set VTOR if the bootloader hasn't already + #ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ + #else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ + #endif #endif } From eb481c9247fb10e5f34eedcaf5d14eed5598b4a9 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Tue, 14 Jan 2020 15:35:23 -0500 Subject: [PATCH 339/531] add support for the Open Book --- .github/workflows/build.yml | 1 + ports/atmel-samd/boards/openbook_m4/board.c | 107 ++++++++++++++++++ .../boards/openbook_m4/mpconfigboard.h | 28 +++++ .../boards/openbook_m4/mpconfigboard.mk | 14 +++ ports/atmel-samd/boards/openbook_m4/pins.c | 71 ++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 ports/atmel-samd/boards/openbook_m4/board.c create mode 100644 ports/atmel-samd/boards/openbook_m4/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/openbook_m4/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 041b8b27cb..d85d5fc6da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -125,6 +125,7 @@ jobs: - "metro_nrf52840_express" - "mini_sam_m4" - "monster_m4sk" + - "openbook_m4" - "particle_argon" - "particle_boron" - "particle_xenon" diff --git a/ports/atmel-samd/boards/openbook_m4/board.c b/ports/atmel-samd/boards/openbook_m4/board.c new file mode 100644 index 0000000000..2d9b316474 --- /dev/null +++ b/ports/atmel-samd/boards/openbook_m4/board.c @@ -0,0 +1,107 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Joey Castillo + * + * 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 "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/time/__init__.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "tick.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 +#define HEIGHT 400 +#define WIDTH 300 + +uint8_t start_sequence[] = { + 0x01, 0x04, 0x03, 0x00, 0x2b, 0x2b, // power setting + 0x06, 0x03, 0x17, 0x17, 0x17, // booster soft start + 0x04, 0x80, 0xc8, // power on and wait 200 ms + 0x00, 0x01, 0x0f, // panel setting + 0x61, 0x04, (HEIGHT >> 8) & 0xFF, HEIGHT & 0xFF, (WIDTH >> 8) & 0xFF, WIDTH & 0xFF // Resolution +}; + +uint8_t stop_sequence[] = { + 0x50, 0x01, 0xf7, // CDI setting + 0x02, 0x80, 0xf0 // Power off +}; + +void board_init(void) { + busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + 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_PB05, // EPD_DC Command or data + &pin_PB07, // EPD_CS Chip select + &pin_PA00, // EPD_RST Reset + 1000000); + + displayio_epaperdisplay_obj_t* display = &displays[0].epaper_display; + display->base.type = &displayio_epaperdisplay_type; + common_hal_displayio_epaperdisplay_construct(display, + bus, + start_sequence, + sizeof(start_sequence), + stop_sequence, + sizeof(stop_sequence), + 400, // width + 300, // height + 400, // RAM width + 300, // RAM height + 0, // colstart + 0, // rowstart + 0, // rotation + NO_COMMAND, // set_column_window_command + NO_COMMAND, // set_row_window_command + NO_COMMAND, // set_current_column_command + NO_COMMAND, // set_current_row_command + 0x13, // write_black_ram_command + false, // black_bits_inverted + NO_COMMAND, // write_color_ram_command (can add this for grayscale eventually) + false, // color_bits_inverted + 0x000000, // highlight_color + 0x12, // refresh_display_command + 40, // refresh_time + &pin_PA01, // busy_pin + false, // busy_state + 5, // seconds_per_frame + false); // chip_select (don't always toggle chip select) +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/openbook_m4/mpconfigboard.h b/ports/atmel-samd/boards/openbook_m4/mpconfigboard.h new file mode 100644 index 0000000000..6d75c086e9 --- /dev/null +++ b/ports/atmel-samd/boards/openbook_m4/mpconfigboard.h @@ -0,0 +1,28 @@ +#define MICROPY_HW_BOARD_NAME "The Open Book Feather" +#define MICROPY_HW_MCU_NAME "samd51j19" + +#define CIRCUITPY_MCU_FAMILY samd51 + +#define MICROPY_HW_LED_STATUS (&pin_PA23) + +// These are pins not to reset. +// QSPI Data pins +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +// DotStar pins, QSPI CS, and QSPI SCK +#define MICROPY_PORT_B (PORT_PB10 | PORT_PB11) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +#define DEFAULT_I2C_BUS_SCL (&pin_PA13) +#define DEFAULT_I2C_BUS_SDA (&pin_PA12) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA17) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB23) +#define DEFAULT_SPI_BUS_MISO (&pin_PB22) + +#define DEFAULT_UART_BUS_RX (&pin_PB17) +#define DEFAULT_UART_BUS_TX (&pin_PB16) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk b/ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk new file mode 100644 index 0000000000..e5fa0cd84b --- /dev/null +++ b/ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk @@ -0,0 +1,14 @@ +USB_VID = 0x239A +USB_PID = 0x807E +USB_PRODUCT = "The Open Book Feather" +USB_MANUFACTURER = "Oddly Specific Objects" + +CHIP_VARIANT = SAMD51J19A +CHIP_FAMILY = samd51 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +CIRCUITPY_GAMEPADSHIFT = 1 diff --git a/ports/atmel-samd/boards/openbook_m4/pins.c b/ports/atmel-samd/boards/openbook_m4/pins.c new file mode 100644 index 0000000000..3fbb67860b --- /dev/null +++ b/ports/atmel-samd/boards/openbook_m4/pins.c @@ -0,0 +1,71 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, // A0 = audio right channel + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, // A1 = audio left channel + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA06) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB01) }, // A6 = VBAT Monitor + { MP_OBJ_NEW_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB04) }, // A7 = Raw mic input + { MP_OBJ_NEW_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PB03) }, // A8 = Bottom STEMMA Port + { MP_OBJ_NEW_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PB02) }, // A9 = Top STEMMA Port + { MP_OBJ_NEW_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA07) }, // A10 = Amplified mic input + { MP_OBJ_NEW_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PB00) }, // A11 = VBUS Monitor + + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB17) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB16) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA16) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA18) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA19) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA20) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA21) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D48), MP_ROM_PTR(&pin_PB31) }, + + // UART + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16) }, + + // I2C + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA13) }, + + // SPI + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB23) }, + + // e-paper SPI and control pins + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK1), MP_ROM_PTR(&pin_PB13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI1), MP_ROM_PTR(&pin_PB15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ECS), MP_ROM_PTR(&pin_PB07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_EDC), MP_ROM_PTR(&pin_PB05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ERST), MP_ROM_PTR(&pin_PA00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_EBSY), MP_ROM_PTR(&pin_PA01) }, + + // Special named pins + { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_LOCK_BUTTON), MP_ROM_PTR(&pin_PA27) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON_LATCH), MP_ROM_PTR(&pin_PB12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON_OUT), MP_ROM_PTR(&pin_PB30) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON_CLOCK), MP_ROM_PTR(&pin_PB14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDCS), MP_ROM_PTR(&pin_PA14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MIC_SHUTDOWN), MP_ROM_PTR(&pin_PB31) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_BCS), MP_ROM_PTR(&pin_PB06) }, // BCS = Babel Chip Select, the second flash chip + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)} +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From d6e657b593addf4009169e6ebc124d52666d0baf Mon Sep 17 00:00:00 2001 From: dalegrover Date: Tue, 14 Jan 2020 16:51:27 -0500 Subject: [PATCH 340/531] Initial commit. --- .github/workflows/build.yml | 1 + .../atmel-samd/boards/seeeduino_xiao/board.c | 39 ++++++++++++++ .../boards/seeeduino_xiao/mpconfigboard.h | 20 +++++++ .../boards/seeeduino_xiao/mpconfigboard.mk | 13 +++++ ports/atmel-samd/boards/seeeduino_xiao/pins.c | 54 +++++++++++++++++++ 5 files changed, 127 insertions(+) create mode 100644 ports/atmel-samd/boards/seeeduino_xiao/board.c create mode 100644 ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/seeeduino_xiao/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 041b8b27cb..a78fec4dda 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,6 +144,7 @@ jobs: - "pyruler" - "robohatmm1_m4" - "sam32" + - "seeeduino_xiao" - "serpente" - "shirtty" - "snekboard" diff --git a/ports/atmel-samd/boards/seeeduino_xiao/board.c b/ports/atmel-samd/boards/seeeduino_xiao/board.c new file mode 100644 index 0000000000..0f60736a24 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.h b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.h new file mode 100644 index 0000000000..4bd10ca412 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.h @@ -0,0 +1,20 @@ +#define MICROPY_HW_BOARD_NAME "Seeeduino XIAO" +#define MICROPY_HW_MCU_NAME "samd21g18" + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define DEFAULT_I2C_BUS_SCL (&pin_PA09) // was PA23 +#define DEFAULT_I2C_BUS_SDA (&pin_PA08) // was PA22 + +#define DEFAULT_SPI_BUS_SCK (&pin_PA07) // was PA17 +#define DEFAULT_SPI_BUS_MOSI (&pin_PA06) // was PA16 +#define DEFAULT_SPI_BUS_MISO (&pin_PA05) // was PA19 + +#define DEFAULT_UART_BUS_RX (&pin_PB09) // was PA11 +#define DEFAULT_UART_BUS_TX (&pin_PB08) // was PA10 + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk new file mode 100644 index 0000000000..2741454ce9 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk @@ -0,0 +1,13 @@ +USB_VID = 0x2886 +USB_PID = 0x002f +USB_PRODUCT = "Seeeduino XIAO" +USB_MANUFACTURER = "Seeed" + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 + +SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/seeeduino_xiao/pins.c b/ports/atmel-samd/boards/seeeduino_xiao/pins.c new file mode 100644 index 0000000000..8b96902531 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao/pins.c @@ -0,0 +1,54 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + + // Analog pins + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA06) }, + + // Digital pins + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, + + // UART pins + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB09) }, + + // SPI pins + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA05) }, + + // I2C pins + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + // LED pins + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, // status + { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_PA17) }, + + // Comm objects + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 85dc4089b9b2d721a3e4bfc68e252c0dda450137 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 14 Jan 2020 17:23:16 -0500 Subject: [PATCH 341/531] address review comments --- ports/nrf/common-hal/_bleio/bonding.c | 5 +---- ports/nrf/peripherals/nrf/nvm.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c index 7ba5896234..9716b3988b 100644 --- a/ports/nrf/common-hal/_bleio/bonding.c +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -92,6 +92,7 @@ void bonding_erase_storage(void) { // Given NULL to start or block address, return the address of the next valid block. // The last block returned is the unused block at the end. // Return NULL if we have run off the end of the bonding space. + STATIC bonding_block_t *next_block(bonding_block_t *block) { while (1) { // Advance to next block. @@ -127,10 +128,6 @@ STATIC bonding_block_t *find_existing_block(bool is_central, bonding_block_type_ if (block == NULL) { return NULL; } - if (block->type == BLOCK_INVALID) { - // Skip discarded blocks. - continue; - } // If types match, and block is unused, just return it. // Otherwise check that is_central and ediv match. if (type == block->type) { diff --git a/ports/nrf/peripherals/nrf/nvm.c b/ports/nrf/peripherals/nrf/nvm.c index e8fcc9008b..63b168f14e 100644 --- a/ports/nrf/peripherals/nrf/nvm.c +++ b/ports/nrf/peripherals/nrf/nvm.c @@ -89,7 +89,7 @@ bool sd_flash_write_sync(uint32_t *dest_words, uint32_t* src_words, uint32_t num // location before an erase is necessary, even if the write is all // ones (erased state). So we can't avoid erases even if the page // appears to be already erased (all ones), unless we keep track of -// writes to a page.g +// writes to a page. bool nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data) { #ifdef BLUETOOTH_SD From 4bf10a75c748b7f92f8325cd26501a916d904980 Mon Sep 17 00:00:00 2001 From: Benny Meisels Date: Tue, 7 Jan 2020 00:31:37 +0200 Subject: [PATCH 342/531] Add board definition files for AramCon Badge 2019 --- .github/workflows/build.yml | 1 + ports/nrf/boards/aramcon_badge_2019/board.c | 40 +++++++++++++++++++ .../boards/aramcon_badge_2019/mpconfigboard.h | 31 ++++++++++++++ .../aramcon_badge_2019/mpconfigboard.mk | 14 +++++++ ports/nrf/boards/aramcon_badge_2019/pins.c | 34 ++++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 ports/nrf/boards/aramcon_badge_2019/board.c create mode 100644 ports/nrf/boards/aramcon_badge_2019/mpconfigboard.h create mode 100644 ports/nrf/boards/aramcon_badge_2019/mpconfigboard.mk create mode 100644 ports/nrf/boards/aramcon_badge_2019/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 041b8b27cb..507842bac4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,7 @@ jobs: fail-fast: false matrix: board: + - "aramcon_badge_2019" - "arduino_mkr1300" - "arduino_mkrzero" - "arduino_nano_33_ble" diff --git a/ports/nrf/boards/aramcon_badge_2019/board.c b/ports/nrf/boards/aramcon_badge_2019/board.c new file mode 100644 index 0000000000..efb449285b --- /dev/null +++ b/ports/nrf/boards/aramcon_badge_2019/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Uri Shaked + * Copyright (c) 2019 Benjamin Meisels + * + * 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 "boards/board.h" +#include "common-hal/microcontroller/Pin.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/aramcon_badge_2019/mpconfigboard.h b/ports/nrf/boards/aramcon_badge_2019/mpconfigboard.h new file mode 100644 index 0000000000..51d14721cf --- /dev/null +++ b/ports/nrf/boards/aramcon_badge_2019/mpconfigboard.h @@ -0,0 +1,31 @@ +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "ARAMCON Badge 2019" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_LED_STATUS (&pin_P1_11) + +#ifdef QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 20) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 4) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(1, 6) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 0) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 2) +#endif + +#ifdef SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P0_20 +#define SPI_FLASH_MISO_PIN &pin_P0_22 +#define SPI_FLASH_SCK_PIN &pin_P1_00 +#define SPI_FLASH_CS_PIN &pin_P1_02 +#endif + +#define BOARD_HAS_32KHZ_XTAL 0 + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_28) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_03) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_01) +#define DEFAULT_SPI_BUS_MOSI (&pin_P1_10) +#define DEFAULT_SPI_BUS_MISO (&pin_P1_09) diff --git a/ports/nrf/boards/aramcon_badge_2019/mpconfigboard.mk b/ports/nrf/boards/aramcon_badge_2019/mpconfigboard.mk new file mode 100644 index 0000000000..09252ab4b7 --- /dev/null +++ b/ports/nrf/boards/aramcon_badge_2019/mpconfigboard.mk @@ -0,0 +1,14 @@ +USB_VID = 0x239A +USB_PID = 0x807A +USB_PRODUCT = "ARAMCON Badge 2019" +USB_MANUFACTURER = "ARAMCON Badge Team" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = "GD25Q16C" + +CIRCUITPY_DISPLAYIO = 1 + +CIRCUITPY_REQUIRE_I2C_PULLUPS = 0 diff --git a/ports/nrf/boards/aramcon_badge_2019/pins.c b/ports/nrf/boards/aramcon_badge_2019/pins.c new file mode 100644 index 0000000000..82ab200131 --- /dev/null +++ b/ports/nrf/boards/aramcon_badge_2019/pins.c @@ -0,0 +1,34 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_LEFT_BUTTON), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_MIDDLE_BUTTON), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_RIGHT_BUTTON), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_P1_11) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_01) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P1_09) }, + + { MP_ROM_QSTR(MP_QSTR_SND_CS), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_SND_DREQ), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_SND_RESET), MP_ROM_PTR(&pin_P0_00) }, + { MP_ROM_QSTR(MP_QSTR_SND_XDCS), MP_ROM_PTR(&pin_P0_24) }, + + { MP_ROM_QSTR(MP_QSTR_DISP_BUSY), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_DISP_RESET), MP_ROM_PTR(&pin_P0_06) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_08) }, + + { MP_ROM_QSTR(MP_QSTR_VIBRATION_MOTOR), MP_ROM_PTR(&pin_P0_17) }, + + { MP_ROM_QSTR(MP_QSTR_BATTERY_SENSE), MP_ROM_PTR(&pin_P0_30) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From e6869c8983ba732f77076242c86041aa77a047e0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 12 Jan 2020 10:12:42 -0600 Subject: [PATCH 343/531] mixer: factor out mix_one_voice --- shared-module/audiomixer/Mixer.c | 159 ++++++++++++++++--------------- 1 file changed, 82 insertions(+), 77 deletions(-) diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index afa3a06323..f3a435a094 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -295,6 +295,87 @@ static inline uint32_t mult16signed(uint32_t val, int32_t mul) { #endif } +static void mix_one_voice(audiomixer_mixer_obj_t* self, + audiomixer_mixervoice_obj_t* voice, bool voices_active, + uint32_t* word_buffer, uint32_t length) { + uint32_t j = 0; + bool voice_done = voice->sample == NULL; + for (uint32_t i = 0; i < length; i++) { + if (!voice_done && j >= voice->buffer_length) { + if (!voice->more_data) { + if (voice->loop) { + audiosample_reset_buffer(voice->sample, false, 0); + } else { + voice->sample = NULL; + voice_done = true; + } + } + if (!voice_done) { + // Load another buffer + audioio_get_buffer_result_t result = audiosample_get_buffer(voice->sample, false, 0, (uint8_t**) &voice->remaining_buffer, &voice->buffer_length); + // Track length in terms of words. + voice->buffer_length /= sizeof(uint32_t); + voice->more_data = result == GET_BUFFER_MORE_DATA; + j = 0; + } + } + // First active voice gets copied over verbatim. + uint32_t sample_value; + if (voice_done) { + // Exit early if another voice already set all samples once. + if (voices_active) { + continue; + } + sample_value = 0; + if (!self->samples_signed) { + if (self->bits_per_sample == 8) { + sample_value = 0x7f7f7f7f; + } else { + sample_value = 0x7fff7fff; + } + } + } else { + sample_value = voice->remaining_buffer[j]; + } + + // apply the mixer level + if (!self->samples_signed) { + if (self->bits_per_sample == 8) { + sample_value = mult8unsigned(sample_value, voice->level); + } else { + sample_value = mult16unsigned(sample_value, voice->level); + } + } else { + if (self->bits_per_sample == 8) { + sample_value = mult8signed(sample_value, voice->level); + } else { + sample_value = mult16signed(sample_value, voice->level); + } + } + + if (!voices_active) { + word_buffer[i] = sample_value; + } else { + if (self->bits_per_sample == 8) { + if (self->samples_signed) { + word_buffer[i] = add8signed(word_buffer[i], sample_value); + } else { + word_buffer[i] = add8unsigned(word_buffer[i], sample_value); + } + } else { + if (self->samples_signed) { + word_buffer[i] = add16signed(word_buffer[i], sample_value); + } else { + word_buffer[i] = add16unsigned(word_buffer[i], sample_value); + } + } + } + j++; + } + voice->buffer_length -= j; + voice->remaining_buffer += j; +} + audioio_get_buffer_result_t audiomixer_mixer_get_buffer(audiomixer_mixer_obj_t* self, bool single_channel, uint8_t channel, @@ -325,83 +406,7 @@ audioio_get_buffer_result_t audiomixer_mixer_get_buffer(audiomixer_mixer_obj_t* for (int32_t v = 0; v < self->voice_count; v++) { audiomixer_mixervoice_obj_t* voice = MP_OBJ_TO_PTR(self->voice[v]); - uint32_t j = 0; - bool voice_done = voice->sample == NULL; - for (uint32_t i = 0; i < self->len / sizeof(uint32_t); i++) { - if (!voice_done && j >= voice->buffer_length) { - if (!voice->more_data) { - if (voice->loop) { - audiosample_reset_buffer(voice->sample, false, 0); - } else { - voice->sample = NULL; - voice_done = true; - } - } - if (!voice_done) { - // Load another buffer - audioio_get_buffer_result_t result = audiosample_get_buffer(voice->sample, false, 0, (uint8_t**) &voice->remaining_buffer, &voice->buffer_length); - // Track length in terms of words. - voice->buffer_length /= sizeof(uint32_t); - voice->more_data = result == GET_BUFFER_MORE_DATA; - j = 0; - } - } - // First active voice gets copied over verbatim. - uint32_t sample_value; - if (voice_done) { - // Exit early if another voice already set all samples once. - if (voices_active) { - continue; - } - sample_value = 0; - if (!self->samples_signed) { - if (self->bits_per_sample == 8) { - sample_value = 0x7f7f7f7f; - } else { - sample_value = 0x7fff7fff; - } - } - } else { - sample_value = voice->remaining_buffer[j]; - } - - // apply the mixer level - if (!self->samples_signed) { - if (self->bits_per_sample == 8) { - sample_value = mult8unsigned(sample_value, voice->level); - } else { - sample_value = mult16unsigned(sample_value, voice->level); - } - } else { - if (self->bits_per_sample == 8) { - sample_value = mult8signed(sample_value, voice->level); - } else { - sample_value = mult16signed(sample_value, voice->level); - } - } - - if (!voices_active) { - word_buffer[i] = sample_value; - } else { - if (self->bits_per_sample == 8) { - if (self->samples_signed) { - word_buffer[i] = add8signed(word_buffer[i], sample_value); - } else { - word_buffer[i] = add8unsigned(word_buffer[i], sample_value); - } - } else { - if (self->samples_signed) { - word_buffer[i] = add16signed(word_buffer[i], sample_value); - } else { - word_buffer[i] = add16unsigned(word_buffer[i], sample_value); - } - } - } - j++; - } - voice->buffer_length -= j; - voice->remaining_buffer += j; - + mix_one_voice(self, voice, voices_active, word_buffer, self->len / sizeof(uint32_t)); voices_active = true; } From 449dbea4567dbc27a01ae695b9cebf776a6927f0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 12 Jan 2020 11:02:47 -0600 Subject: [PATCH 344/531] Mixer: Rework for performance, particularly of the S16 case This removes downscaling (halving-add) when multiple voices are being mixed. To avoid clipping, and get similar behavior to before, set the "level" of each voice to (1/voice_count). Slow paths that were applicable to only M0 chips were removed. As a side effect, the internal volume representation is now 0 .. 0x8000 (inclusive), which additionally makes a level of exactly 0.5 representable. Testing performed, on PyGamer: For all 4 data cases, for stereo and mono, for 1 and 2 voices, play pure sign waves represented as RawSamples and view the result on a scope and through headphones. Also, scope the amount of time spent in background tasks. Code size: growth of +272 bytes Performance (time in background task when mixing 2 stereo 16-bit voices): 76us per down from 135us (once per ~2.9ms long term average) (Decrease from 4.7% to 2.4% of all CPU time) --- shared-module/audiomixer/Mixer.c | 340 +++++++++----------------- shared-module/audiomixer/MixerVoice.c | 6 +- shared-module/audiomixer/MixerVoice.h | 2 +- 3 files changed, 113 insertions(+), 235 deletions(-) diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index f3a435a094..3c1c9a4912 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -101,213 +101,60 @@ void audiomixer_mixer_reset_buffer(audiomixer_mixer_obj_t* self, } } -uint32_t add8signed(uint32_t a, uint32_t b) { - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU - return __SHADD8(a, b); - #else - uint32_t result = 0; - for (int8_t i = 0; i < 4; i++) { - int8_t ai = a >> (sizeof(int8_t) * 8 * i); - int8_t bi = b >> (sizeof(int8_t) * 8 * i); - int32_t intermediate = (int32_t) ai + bi / 2; - if (intermediate > CHAR_MAX) { - intermediate = CHAR_MAX; - } else if (intermediate < CHAR_MIN) { - intermediate = CHAR_MIN; - } - result |= ((uint32_t) intermediate & 0xff) << (sizeof(int8_t) * 8 * i); - } - return result; - #endif -} - -uint32_t add8unsigned(uint32_t a, uint32_t b) { - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU - return __UHADD8(a, b); - #else - uint32_t result = 0; - for (int8_t i = 0; i < 4; i++) { - uint8_t ai = (a >> (sizeof(uint8_t) * 8 * i)); - uint8_t bi = (b >> (sizeof(uint8_t) * 8 * i)); - int32_t intermediate = (int32_t) (ai + bi) / 2; - if (intermediate > UCHAR_MAX) { - intermediate = UCHAR_MAX; - } - result |= ((uint32_t) intermediate & 0xff) << (sizeof(uint8_t) * 8 * i); - } - return result; - #endif -} - -uint32_t add16signed(uint32_t a, uint32_t b) { - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU - return __SHADD16(a, b); - #else - uint32_t result = 0; - for (int8_t i = 0; i < 2; i++) { - int16_t ai = a >> (sizeof(int16_t) * 8 * i); - int16_t bi = b >> (sizeof(int16_t) * 8 * i); - int32_t intermediate = (int32_t) ai + bi / 2; - if (intermediate > SHRT_MAX) { - intermediate = SHRT_MAX; - } else if (intermediate < SHRT_MIN) { - intermediate = SHRT_MIN; - } - result |= (((uint32_t) intermediate) & 0xffff) << (sizeof(int16_t) * 8 * i); - } - return result; - #endif -} - -uint32_t add16unsigned(uint32_t a, uint32_t b) { - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU - return __UHADD16(a, b); - #else - uint32_t result = 0; - for (int8_t i = 0; i < 2; i++) { - int16_t ai = (a >> (sizeof(uint16_t) * 8 * i)) - 0x8000; - int16_t bi = (b >> (sizeof(uint16_t) * 8 * i)) - 0x8000; - int32_t intermediate = (int32_t) ai + bi / 2; - if (intermediate > USHRT_MAX) { - intermediate = USHRT_MAX; - } - result |= ((uint32_t) intermediate & 0xffff) << (sizeof(int16_t) * 8 * i); - } - return result; - #endif -} - -static inline uint32_t mult8unsigned(uint32_t val, int32_t mul) { - // if mul == 0, no need in wasting cycles - if (mul == 0) { - return 0; - } - /* TODO: workout ARMv7 instructions - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU - return val; - #else*/ - uint32_t result = 0; - float mod_mul = (float) mul / (float) ((1<<15)-1); - for (int8_t i = 0; i < 4; i++) { - uint8_t ai = val >> (sizeof(uint8_t) * 8 * i); - int32_t intermediate = ai * mod_mul; - if (intermediate > SHRT_MAX) { - intermediate = SHRT_MAX; - } - result |= ((uint32_t) intermediate & 0xff) << (sizeof(uint8_t) * 8 * i); - } - - return result; - //#endif -} - -static inline uint32_t mult8signed(uint32_t val, int32_t mul) { - // if mul == 0, no need in wasting cycles - if (mul == 0) { - return 0; - } - /* TODO: workout ARMv7 instructions - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU - return val; - #else - */ - uint32_t result = 0; - float mod_mul = (float)mul / (float)((1<<15)-1); - for (int8_t i = 0; i < 4; i++) { - int16_t ai = val >> (sizeof(int8_t) * 8 * i); - int32_t intermediate = ai * mod_mul; - if (intermediate > CHAR_MAX) { - intermediate = CHAR_MAX; - } else if (intermediate < CHAR_MIN) { - intermediate = CHAR_MIN; - } - result |= (((uint32_t) intermediate) & 0xff) << (sizeof(int16_t) * 8 * i); - } - return result; - //#endif -} - -//TODO: -static inline uint32_t mult16unsigned(uint32_t val, int32_t mul) { - // if mul == 0, no need in wasting cycles - if (mul == 0) { - return 0; - } - /* TODO: the below ARMv7m instructions "work", but the amplitude is much higher/louder - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU - // there is no unsigned equivalent to the 'SMULWx' ARMv7 Thumb function, - // so we have to do it by hand. - uint32_t lo = val & 0xffff; - uint32_t hi = val >> 16; - //mp_printf(&mp_plat_print, "pre-asm: (mul: %d)\n\tval: %x\tlo: %x\thi: %x\n", mul, val, lo, hi); - uint32_t val_lo; - asm volatile("mul %0, %1, %2" : "=r" (val_lo) : "r" (mul), "r" (lo)); - asm volatile("mla %0, %1, %2, %3" : "=r" (val) : "r" (mul), "r" (hi), "r" (val_lo)); - //mp_printf(&mp_plat_print, "post-asm:\n\tval: %x\tlo: %x\n\n", val, val_lo); - return val; - #else - */ - uint32_t result = 0; - 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)) - 0x8000; - int32_t intermediate = ai * mod_mul; - if (intermediate > SHRT_MAX) { - intermediate = SHRT_MAX; - } else if (intermediate < SHRT_MIN) { - intermediate = SHRT_MIN; - } - result |= (((uint32_t) intermediate) + 0x8000) << (sizeof(int16_t) * 8 * i); - } - return result; - //#endif +__attribute__((always_inline)) +static inline uint32_t add16signed(uint32_t a, uint32_t b) { + return __QADD16(a, b); } +__attribute__((always_inline)) static inline uint32_t mult16signed(uint32_t val, int32_t mul) { - // if mul == 0, no need in wasting cycles - if (mul == 0) { - return 0; - } - #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) //Cortex-M4 w/FPU + mul <<= 16; int32_t hi, lo; enum { bits = 16 }; // saturate to 16 bits - enum { shift = 0 }; // shift is done automatically + enum { shift = 15 }; // shift is done automatically asm volatile("smulwb %0, %1, %2" : "=r" (lo) : "r" (mul), "r" (val)); asm volatile("smulwt %0, %1, %2" : "=r" (hi) : "r" (mul), "r" (val)); asm volatile("ssat %0, %1, %2, asr %3" : "=r" (lo) : "I" (bits), "r" (lo), "I" (shift)); asm volatile("ssat %0, %1, %2, asr %3" : "=r" (hi) : "I" (bits), "r" (hi), "I" (shift)); asm volatile("pkhbt %0, %1, %2, lsl #16" : "=r" (val) : "r" (lo), "r" (hi)); // pack return val; - #else - uint32_t result = 0; - float mod_mul = (float)mul / (float)((1<<15)-1); - for (int8_t i = 0; i < 2; i++) { - int16_t ai = val >> (sizeof(int16_t) * 8 * i); - int32_t intermediate = ai * mod_mul; - if (intermediate > SHRT_MAX) { - intermediate = SHRT_MAX; - } else if (intermediate < SHRT_MIN) { - intermediate = SHRT_MIN; - } - result |= (((uint32_t) intermediate) & 0xffff) << (sizeof(int16_t) * 8 * i); - } - return result; - #endif } +static inline uint32_t tounsigned8(uint32_t val) { + return __UADD8(val, 0x80808080); +} + +static inline uint32_t tounsigned16(uint32_t val) { + return __UADD16(val, 0x80008000); +} + +static inline uint32_t tosigned16(uint32_t val) { + return __UADD16(val, 0x80008000); +} + +static inline uint32_t unpack8(uint16_t val) { + return ((val & 0xff00) << 16) | ((val & 0x00ff) << 8); +} + +static inline uint32_t pack8(uint32_t val) { + return ((val & 0xff000000) >> 16) | ((val & 0xff00) >> 8); +} + +#define LIKELY(x) (__builtin_expect(!!(x), 1)) +#define UNLIKELY(x) (__builtin_expect(!!(x), 0)) static void mix_one_voice(audiomixer_mixer_obj_t* self, audiomixer_mixervoice_obj_t* voice, bool voices_active, uint32_t* word_buffer, uint32_t length) { - uint32_t j = 0; bool voice_done = voice->sample == NULL; - for (uint32_t i = 0; i < length; i++) { - if (!voice_done && j >= voice->buffer_length) { + while (!voice_done && length != 0) { + if (voice->buffer_length == 0) { if (!voice->more_data) { if (voice->loop) { audiosample_reset_buffer(voice->sample, false, 0); } else { voice->sample = NULL; voice_done = true; + break; } } if (!voice_done) { @@ -316,64 +163,81 @@ static void mix_one_voice(audiomixer_mixer_obj_t* self, // Track length in terms of words. voice->buffer_length /= sizeof(uint32_t); voice->more_data = result == GET_BUFFER_MORE_DATA; - j = 0; } } + + uint32_t n = MIN(voice->buffer_length, length); + uint32_t *src = voice->remaining_buffer; + uint16_t level = voice->level; + // First active voice gets copied over verbatim. - uint32_t sample_value; - if (voice_done) { - // Exit early if another voice already set all samples once. - if (voices_active) { - continue; - } - sample_value = 0; - if (!self->samples_signed) { - if (self->bits_per_sample == 8) { - sample_value = 0x7f7f7f7f; - } else { - sample_value = 0x7fff7fff; - } - } - } else { - sample_value = voice->remaining_buffer[j]; - } - - // apply the mixer level - if (!self->samples_signed) { - if (self->bits_per_sample == 8) { - sample_value = mult8unsigned(sample_value, voice->level); - } else { - sample_value = mult16unsigned(sample_value, voice->level); - } - } else { - if (self->bits_per_sample == 8) { - sample_value = mult8signed(sample_value, voice->level); - } else { - sample_value = mult16signed(sample_value, voice->level); - } - } - if (!voices_active) { - word_buffer[i] = sample_value; - } else { - if (self->bits_per_sample == 8) { - if (self->samples_signed) { - word_buffer[i] = add8signed(word_buffer[i], sample_value); + if (LIKELY(self->bits_per_sample == 16)) { + if (LIKELY(self->samples_signed)) { + for (uint32_t i = 0; isamples_signed) { - word_buffer[i] = add16signed(word_buffer[i], sample_value); + uint16_t *hword_buffer = (uint16_t*)word_buffer; + uint16_t *hsrc = (uint16_t*)src; + for (uint32_t i = 0; isamples_signed)) { + word = tosigned16(word); + } + word = mult16signed(word, level); + hword_buffer[i] = pack8(word); + } + } + } else { + if (LIKELY(self->bits_per_sample == 16)) { + if (LIKELY(self->samples_signed)) { + for (uint32_t i = 0; isamples_signed)) { + word = tosigned16(word); + } + word = mult16signed(word, level); + word = add16signed(word, unpack8(hword_buffer[i])); + hword_buffer[i] = pack8(word); } } } - j++; + length -= n; + word_buffer += n; + voice->remaining_buffer += n; + voice->buffer_length -= n; + } + + if (length && !voices_active) { + uint32_t sample_value = self->bits_per_sample == 8 + ? 0x80808080 : 0x80008000; + for (uint32_t i = 0; ibuffer_length -= j; - voice->remaining_buffer += j; } audioio_get_buffer_result_t audiomixer_mixer_get_buffer(audiomixer_mixer_obj_t* self, @@ -403,13 +267,27 @@ audioio_get_buffer_result_t audiomixer_mixer_get_buffer(audiomixer_mixer_obj_t* } self->use_first_buffer = !self->use_first_buffer; bool voices_active = false; + uint32_t length = self->len / sizeof(uint32_t); + for (int32_t v = 0; v < self->voice_count; v++) { audiomixer_mixervoice_obj_t* voice = MP_OBJ_TO_PTR(self->voice[v]); - mix_one_voice(self, voice, voices_active, word_buffer, self->len / sizeof(uint32_t)); + mix_one_voice(self, voice, voices_active, word_buffer, length); voices_active = true; } + if (!self->samples_signed) { + if (self->bits_per_sample == 16) { + for (uint32_t i = 0; i < length; i++) { + word_buffer[i] = tounsigned16(word_buffer[i]); + } + } else { + for (uint32_t i = 0; i < length; i++) { + word_buffer[i] = tounsigned8(word_buffer[i]); + } + } + } + self->read_count += 1; } else if (!self->use_first_buffer) { *buffer = (uint8_t*) self->first_buffer; diff --git a/shared-module/audiomixer/MixerVoice.c b/shared-module/audiomixer/MixerVoice.c index ff05dc93e4..9be104afcf 100644 --- a/shared-module/audiomixer/MixerVoice.c +++ b/shared-module/audiomixer/MixerVoice.c @@ -34,7 +34,7 @@ void common_hal_audiomixer_mixervoice_construct(audiomixer_mixervoice_obj_t *self) { self->sample = NULL; - self->level = ((1 << 15) - 1); + self->level = 1 << 15; } void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t* self, audiomixer_mixer_obj_t *parent) { @@ -42,11 +42,11 @@ void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t* se } float common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t* self) { - return ((float) self->level / ((1 << 15) - 1)); + return ((float) self->level / (1 << 15)); } void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t* self, float level) { - self->level = level * ((1 << 15)-1); + self->level = level * (1 << 15); } void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t* self, mp_obj_t sample, bool loop) { diff --git a/shared-module/audiomixer/MixerVoice.h b/shared-module/audiomixer/MixerVoice.h index efac191565..a85316e3d0 100644 --- a/shared-module/audiomixer/MixerVoice.h +++ b/shared-module/audiomixer/MixerVoice.h @@ -39,7 +39,7 @@ typedef struct { bool more_data; uint32_t* remaining_buffer; uint32_t buffer_length; - int16_t level; + uint16_t level; } audiomixer_mixervoice_obj_t; From 86d454adf3842e0d0e4c49546f1aaeb3455080b4 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Thu, 16 Jan 2020 13:46:56 -0800 Subject: [PATCH 345/531] Initial board support for OHS2020 Badge Not tested but builds. Signed-off-by: Michael Welling --- ports/nrf/boards/ohs2020_badge/board.c | 99 +++++++++++++++++++ .../nrf/boards/ohs2020_badge/mpconfigboard.h | 57 +++++++++++ .../nrf/boards/ohs2020_badge/mpconfigboard.mk | 10 ++ ports/nrf/boards/ohs2020_badge/pins.c | 18 ++++ 4 files changed, 184 insertions(+) create mode 100644 ports/nrf/boards/ohs2020_badge/board.c create mode 100644 ports/nrf/boards/ohs2020_badge/mpconfigboard.h create mode 100644 ports/nrf/boards/ohs2020_badge/mpconfigboard.mk create mode 100644 ports/nrf/boards/ohs2020_badge/pins.c diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c new file mode 100644 index 0000000000..ee1f284597 --- /dev/null +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -0,0 +1,99 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "tick.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + 0x11, 0 | DELAY, 255, // SLPOUT + 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order. + 0x3a, 1, 0x55, // COLMOD - 16bit color + 0x21, 0 | DELAY, 10, // _INVON + 0x13, 0 | DELAY, 10, // _NORON + 0x29, 0 | DELAY, 255, // _DISPON +}; + +void board_init(void) { + busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL); + 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_P0_08, // TFT_DC Command or data + &pin_P0_14, // TFT_CS Chip select + &pin_P0_13, // TFT_RST Reset + 60000000); + + 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 + 0, // row start + 270, // rotation + 16, // Color depth + false, // Grayscale + false, // Pixels in a byte share a row. Only used for depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + 0x37, // set vertical scroll command + display_init_sequence, + sizeof(display_init_sequence), + &pin_P1_05, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60); // native_frames_per_second +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/nrf/boards/ohs2020_badge/mpconfigboard.h b/ports/nrf/boards/ohs2020_badge/mpconfigboard.h new file mode 100644 index 0000000000..8e4e68dea3 --- /dev/null +++ b/ports/nrf/boards/ohs2020_badge/mpconfigboard.h @@ -0,0 +1,57 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2020 Michael Welling + * + * 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 "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "Open Hardware Summit 2020 Badge" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#if QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(1, 0) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 20) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(1, 2) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 1) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 23) +#endif + +#if SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P1_00 +#define SPI_FLASH_MISO_PIN &pin_P0_22 +#define SPI_FLASH_SCK_PIN &pin_P1_01 +#define SPI_FLASH_CS_PIN &pin_P0_23 +#endif + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_P1_14) +#define DEFAULT_I2C_BUS_SDA (&pin_P1_15) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_11) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_12) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_07) diff --git a/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk b/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk new file mode 100644 index 0000000000..ed96b1164a --- /dev/null +++ b/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk @@ -0,0 +1,10 @@ +USB_VID = 0x239A +USB_PID = 0x8072 +USB_PRODUCT = "OHS2020 Badge" +USB_MANUFACTURER = "Adafruit Industries LLC" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = "W25Q32JV_IQ" diff --git a/ports/nrf/boards/ohs2020_badge/pins.c b/ports/nrf/boards/ohs2020_badge/pins.c new file mode 100644 index 0000000000..c3752d06b7 --- /dev/null +++ b/ports/nrf/boards/ohs2020_badge/pins.c @@ -0,0 +1,18 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_28) }, + + { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_P0_16) }, + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_P0_12) }, + + { 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 b61014a7b8a0673900245570d3e351d7049d8e34 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Thu, 16 Jan 2020 14:28:28 -0800 Subject: [PATCH 346/531] Add OHS2020 badge to build.yml Signed-off-by: Michael Welling --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74792726be..921a40d273 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,6 +126,7 @@ jobs: - "metro_nrf52840_express" - "mini_sam_m4" - "monster_m4sk" + - "ohs2020_badge" - "openbook_m4" - "particle_argon" - "particle_boron" From cc03d689846035c5c2973dbf393cd46a6b67f91d Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Thu, 16 Jan 2020 14:53:07 -0800 Subject: [PATCH 347/531] Fix backlight pin registration Signed-off-by: Michael Welling --- ports/nrf/boards/ohs2020_badge/board.c | 2 +- ports/nrf/boards/ohs2020_badge/pins.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index ee1f284597..189f7acdf2 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -81,7 +81,7 @@ void board_init(void) { 0x37, // set vertical scroll command display_init_sequence, sizeof(display_init_sequence), - &pin_P1_05, // backlight pin + &pin_P0_02, // backlight pin NO_BRIGHTNESS_COMMAND, 1.0f, // brightness (ignored) true, // auto_brightness diff --git a/ports/nrf/boards/ohs2020_badge/pins.c b/ports/nrf/boards/ohs2020_badge/pins.c index c3752d06b7..df87deeeb6 100644 --- a/ports/nrf/boards/ohs2020_badge/pins.c +++ b/ports/nrf/boards/ohs2020_badge/pins.c @@ -5,7 +5,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_28) }, { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_P0_13) }, - { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_P0_16) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_P0_02) }, { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_P0_14) }, { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_P0_08) }, { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_P0_11) }, From cc77e86408f3502ce353e30ee0fc8f006afb048e Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Thu, 16 Jan 2020 15:43:49 -0800 Subject: [PATCH 348/531] Update the VID and USB company string Signed-off-by: Michael Welling --- ports/nrf/boards/ohs2020_badge/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk b/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk index ed96b1164a..46a4c3be61 100644 --- a/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk +++ b/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk @@ -1,7 +1,7 @@ USB_VID = 0x239A -USB_PID = 0x8072 +USB_PID = 0x8080 USB_PRODUCT = "OHS2020 Badge" -USB_MANUFACTURER = "Adafruit Industries LLC" +USB_MANUFACTURER = "OSHWA" MCU_CHIP = nrf52840 From 69785cccfe966ebae54aeb1e038dd553a0fd1b4a Mon Sep 17 00:00:00 2001 From: arturo182 Date: Fri, 17 Jan 2020 14:45:29 +0100 Subject: [PATCH 349/531] mimxrt1011: Fix pin definition --- ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c index 0b219468f5..8e68e77027 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.c @@ -41,8 +41,8 @@ const mcu_pin_obj_t pin_GPIO_08 = PIN(GPIO1, 8, GPIO_08, NO_ADC, 0); const mcu_pin_obj_t pin_GPIO_09 = PIN(GPIO1, 9, GPIO_09, NO_ADC, 0); const mcu_pin_obj_t pin_GPIO_10 = PIN(GPIO1, 10, GPIO_10, NO_ADC, 0); const mcu_pin_obj_t pin_GPIO_11 = PIN(GPIO1, 11, GPIO_11, NO_ADC, 0); -const mcu_pin_obj_t pin_GPIO_12 = PIN(GPIO1, 12, GPIO_11, NO_ADC, 0); -const mcu_pin_obj_t pin_GPIO_13 = PIN(GPIO1, 13, GPIO_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_12 = PIN(GPIO1, 12, GPIO_12, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_13 = PIN(GPIO1, 13, GPIO_13, NO_ADC, 0); const mcu_pin_obj_t pin_GPIO_AD_00 = PIN(GPIO1, 14, GPIO_AD_00, ADC1, 0); const mcu_pin_obj_t pin_GPIO_AD_01 = PIN(GPIO1, 15, GPIO_AD_01, ADC1, 1); From 3f43155b636a61f204d10dafa6bed733f86be4ec Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 17 Jan 2020 13:31:12 -0500 Subject: [PATCH 350/531] Meowbit bus conflict WIP --- .../boards/meowbit_v121/mpconfigboard.h | 10 +++++----- .../boards/meowbit_v121/mpconfigboard.mk | 18 +++++++++--------- ports/stm32f4/boards/meowbit_v121/pins.c | 2 ++ supervisor/spi_flash_api.h | 4 ++++ 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 0de74a946c..7c7f4ad745 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -37,10 +37,10 @@ #define BOARD_OSC_DIV 12 #define BOARD_NO_VBUS_SENSE -#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader +//#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader // On-board flash -#define SPI_FLASH_MOSI_PIN (&pin_PB15) -#define SPI_FLASH_MISO_PIN (&pin_PB14) -#define SPI_FLASH_SCK_PIN (&pin_PB13) -#define SPI_FLASH_CS_PIN (&pin_PB01) +// #define SPI_FLASH_MOSI_PIN (&pin_PB15) +// #define SPI_FLASH_MISO_PIN (&pin_PB14) +// #define SPI_FLASH_SCK_PIN (&pin_PB13) +// #define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 1d6f68b13c..f24a2690cd 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -4,20 +4,20 @@ USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" USB_DEVICES = "CDC,MSC" -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ -LONGINT_IMPL = MPZ +# SPI_FLASH_FILESYSTEM = 1 +# EXTERNAL_FLASH_DEVICE_COUNT = 1 +# EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ +# LONGINT_IMPL = MPZ -BOOTLOADER_OFFSET = 0x8010000 +# BOOTLOADER_OFFSET = 0x8010000 -# INTERNAL_FLASH_FILESYSTEM = 1 -# LONGINT_IMPL = NONE +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401_boot.ld -#LD_FILE = boards/STM32F401_fs.ld \ No newline at end of file +#LD_FILE = boards/STM32F401_boot.ld +LD_FILE = boards/STM32F401_fs.ld \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 1216f4a80e..66cbcd7d6f 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -1,4 +1,5 @@ #include "shared-bindings/board/__init__.h" +#include "supervisor/spi_flash_api.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) }, @@ -59,5 +60,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) }, + //{ MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/supervisor/spi_flash_api.h b/supervisor/spi_flash_api.h index 28cccb1b1a..b477308bab 100644 --- a/supervisor/spi_flash_api.h +++ b/supervisor/spi_flash_api.h @@ -31,6 +31,10 @@ #include "supervisor/shared/external_flash/devices.h" +#include "shared-bindings/busio/SPI.h" + +extern busio_spi_obj_t spi; //Used to share SPI bus on some boards + // This API is implemented for both normal SPI peripherals and QSPI peripherals. bool spi_flash_command(uint8_t command); From 7d8dac9211dab92d750a0351335b4ad3fffc05e2 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 8 Jan 2020 20:32:45 -0800 Subject: [PATCH 351/531] Refine iMX RT memory layout and add three boards Introduces a way to place CircuitPython code and data into tightly coupled memory (TCM) which is accessible by the CPU in a single cycle. It also frees up room in the corresponding cache for intermittent data. Loading from external flash is slow! The data cache is also now enabled. Adds support for the iMX RT 1021 chip. Adds three new boards: * iMX RT 1020 EVK * iMX RT 1060 EVK * Teensy 4.0 Related to #2492, #2472 and #2477. Fixes #2475. --- .github/workflows/build.yml | 3 + .gitmodules | 2 +- lib/tinyusb | 2 +- ports/mimxrt10xx/Makefile | 20 +- ports/mimxrt10xx/background.c | 3 +- .../boards/feather_mimxrt1011/board.c | 16 - .../boards/feather_mimxrt1011/flash_config.c | 122 ++++++ .../boards/feather_mimxrt1011/mpconfigboard.h | 11 - .../feather_mimxrt1011/mpconfigboard.mk | 15 +- .../boards/feather_mimxrt1062/board.c | 16 - .../boards/feather_mimxrt1062/flash_config.c | 122 ++++++ .../boards/feather_mimxrt1062/mpconfigboard.h | 8 - .../feather_mimxrt1062/mpconfigboard.mk | 15 +- ports/mimxrt10xx/boards/imxrt1010_evk/board.c | 16 - .../boards/imxrt1010_evk/flash_config.c | 141 +++++++ .../boards/imxrt1010_evk/mpconfigboard.h | 17 - .../boards/imxrt1010_evk/mpconfigboard.mk | 16 +- ports/mimxrt10xx/boards/imxrt1010_evk/pins.c | 30 +- ports/mimxrt10xx/boards/imxrt1020_evk/board.c | 39 ++ .../boards/imxrt1020_evk/flash_config.c | 122 ++++++ .../boards/imxrt1020_evk/mpconfigboard.h | 14 + .../boards/imxrt1020_evk/mpconfigboard.mk | 8 + ports/mimxrt10xx/boards/imxrt1020_evk/pins.c | 84 ++++ ports/mimxrt10xx/boards/imxrt1060_evk/board.c | 39 ++ .../boards/imxrt1060_evk/flash_config.c | 141 +++++++ .../boards/imxrt1060_evk/mpconfigboard.h | 14 + .../boards/imxrt1060_evk/mpconfigboard.mk | 8 + ports/mimxrt10xx/boards/imxrt1060_evk/pins.c | 128 ++++++ .../mimxrt1011-bootloader-external-flash.ld | 106 ----- .../boards/mimxrt1011-external-flash.ld | 123 ------ .../mimxrt1062-bootloader-external-flash.ld | 106 ----- ports/mimxrt10xx/boards/teensy40/board.c | 39 ++ ports/mimxrt10xx/boards/teensy40/board.ld | 1 + .../mimxrt10xx/boards/teensy40/flash_config.c | 141 +++++++ .../boards/teensy40/mpconfigboard.h | 18 + .../boards/teensy40/mpconfigboard.mk | 8 + ports/mimxrt10xx/boards/teensy40/pins.c | 87 ++++ .../common-hal/microcontroller/__init__.c | 6 +- .../linking/chip_family/MIMXRT1011.ld | 2 + .../linking/chip_family/MIMXRT1021.ld | 2 + .../linking/chip_family/MIMXRT1062.ld | 2 + ports/mimxrt10xx/linking/common.ld | 158 ++++++++ ports/mimxrt10xx/linking/flash/AT25SF128A.ld | 1 + ports/mimxrt10xx/linking/flash/IS25LP064A.ld | 1 + ports/mimxrt10xx/linking/flash/IS25WP064A.ld | 1 + ports/mimxrt10xx/linking/flash/W25Q16JV.ld | 1 + ports/mimxrt10xx/linking/flash/W25Q64JV.ld | 1 + ports/mimxrt10xx/mpconfigport.h | 12 +- ports/mimxrt10xx/mpconfigport.mk | 17 +- ports/mimxrt10xx/mphalport.c | 2 +- .../mimxrt10xx/MIMXRT1021/clocks.c | 371 ++++++++++++++++++ .../mimxrt10xx/MIMXRT1021/periph.c | 218 ++++++++++ .../mimxrt10xx/MIMXRT1021/periph.h | 43 ++ .../peripherals/mimxrt10xx/MIMXRT1021/pins.c | 128 ++++++ .../peripherals/mimxrt10xx/MIMXRT1021/pins.h | 129 ++++++ .../mimxrt10xx/MIMXRT1062/periph.c | 2 +- .../peripherals/mimxrt10xx/periph.h | 2 + .../mimxrt10xx/peripherals/mimxrt10xx/pins.h | 2 + ports/mimxrt10xx/reset.c | 2 +- ports/mimxrt10xx/reset.h | 2 - ports/mimxrt10xx/sdk | 2 +- ports/mimxrt10xx/supervisor/internal_flash.c | 10 +- ports/mimxrt10xx/supervisor/port.c | 201 +++++++++- py/map.c | 4 +- py/mpstate.c | 3 +- py/obj.c | 3 +- py/objdict.c | 5 +- py/objfun.c | 4 +- py/qstr.c | 4 +- py/runtime.c | 8 +- py/runtime.h | 10 +- py/vm.c | 4 +- py/vmentrytable.h | 4 +- supervisor/linker.h | 42 ++ supervisor/port.h | 6 + supervisor/shared/filesystem.c | 2 +- supervisor/shared/memory.c | 7 +- supervisor/shared/safe_mode.c | 3 + supervisor/shared/safe_mode.h | 1 + supervisor/shared/stack.c | 7 + supervisor/shared/tick.c | 8 +- tools/build_board_info.py | 3 +- 82 files changed, 2717 insertions(+), 530 deletions(-) create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c create mode 100644 ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c create mode 100644 ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c create mode 100644 ports/mimxrt10xx/boards/imxrt1020_evk/board.c create mode 100644 ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c create mode 100644 ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/imxrt1020_evk/pins.c create mode 100644 ports/mimxrt10xx/boards/imxrt1060_evk/board.c create mode 100644 ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c create mode 100644 ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/imxrt1060_evk/pins.c delete mode 100644 ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld delete mode 100644 ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld delete mode 100644 ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld create mode 100644 ports/mimxrt10xx/boards/teensy40/board.c create mode 100644 ports/mimxrt10xx/boards/teensy40/board.ld create mode 100644 ports/mimxrt10xx/boards/teensy40/flash_config.c create mode 100644 ports/mimxrt10xx/boards/teensy40/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/teensy40/pins.c create mode 100644 ports/mimxrt10xx/linking/chip_family/MIMXRT1011.ld create mode 100644 ports/mimxrt10xx/linking/chip_family/MIMXRT1021.ld create mode 100644 ports/mimxrt10xx/linking/chip_family/MIMXRT1062.ld create mode 100644 ports/mimxrt10xx/linking/common.ld create mode 100644 ports/mimxrt10xx/linking/flash/AT25SF128A.ld create mode 100644 ports/mimxrt10xx/linking/flash/IS25LP064A.ld create mode 100644 ports/mimxrt10xx/linking/flash/IS25WP064A.ld create mode 100644 ports/mimxrt10xx/linking/flash/W25Q16JV.ld create mode 100644 ports/mimxrt10xx/linking/flash/W25Q64JV.ld create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.c create mode 100644 ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.h create mode 100755 supervisor/linker.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 921a40d273..cfb6c2f084 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -113,6 +113,8 @@ jobs: - "hallowing_m0_express" - "hallowing_m4_express" - "imxrt1010_evk" + - "imxrt1020_evk" + - "imxrt1060_evk" - "itsybitsy_m0_express" - "itsybitsy_m4_express" - "itsybitsy_nrf52840_express" @@ -163,6 +165,7 @@ jobs: - "stm32f411ve_discovery" - "stm32f412zg_discovery" - "stringcar_m0_express" + - "teensy40" - "teknikio_bluebird" - "trellis_m4_express" - "trinket_m0" diff --git a/.gitmodules b/.gitmodules index 44fc818c84..cb36ad4c4a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -110,4 +110,4 @@ url = https://github.com/adafruit/Adafruit_MP3 [submodule "ports/mimxrt10xx/sdk"] path = ports/mimxrt10xx/sdk - url = https://github.com/arturo182/MIMXRT10xx_SDK + url = https://github.com/adafruit/MIMXRT10xx_SDK diff --git a/lib/tinyusb b/lib/tinyusb index dda4c9a94b..1f95f439e1 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit dda4c9a94b509238faa7b5ab5b9464c1d2e63ff0 +Subproject commit 1f95f439e11f519e69d75a4a8b7b9f28eaf5060e diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index 68ddea565c..d46806dc6b 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -71,6 +71,7 @@ INC += \ -Isdk/CMSIS/Include \ -Isdk/devices/$(CHIP_FAMILY) \ -Isdk/devices/$(CHIP_FAMILY)/drivers \ + -Isdk/devices/$(CHIP_FAMILY)/xip \ # NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt. @@ -114,6 +115,7 @@ CFLAGS += \ -mfpu=fpv5-sp-d16 \ -DCPU_$(CHIP_VARIANT) \ -DDEBUG \ + -DIMXRT10XX \ -DXIP_EXTERNAL_FLASH=1 \ -DXIP_BOOT_HEADER_ENABLE=1 \ -D__START=main \ @@ -121,7 +123,11 @@ CFLAGS += \ -ffunction-sections -fdata-sections -fstack-usage \ -D__STARTUP_CLEAR_BSS -LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs +LD_FILES = $(wildcard boards/$(BOARD)/*.ld) $(addprefix linking/, flash/$(FLASH).ld chip_family/$(CHIP_FAMILY).ld common.ld) + +LD_SCRIPT_FLAG := -Wl,-T, + +LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib $(addprefix $(LD_SCRIPT_FLAG), $(LD_FILES)) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LIBS := -lgcc -lc -lnosys -lm # Use toolchain libm if we're not using our own. @@ -154,6 +160,7 @@ SRC_SDK := $(addprefix sdk/devices/$(CHIP_FAMILY)/, $(SRC_SDK)) SRC_C = \ background.c \ boards/$(BOARD)/board.c \ + boards/$(BOARD)/flash_config.c \ boards/$(BOARD)/pins.c \ fatfs_port.c \ lib/mp-readline/readline.c \ @@ -231,20 +238,23 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o)) SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) -all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 +all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex -$(BUILD)/firmware.elf: $(LD_FILE) $(OBJ) +$(BUILD)/firmware.elf: $(OBJ) $(LD_FILES) $(STEPECHO) "LINK $@" - $(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out $<,$^) -Wl,--start-group $(LIBS) -Wl,--end-group + $(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out %.ld, $^) -Wl,--start-group $(LIBS) -Wl,--end-group $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" - $(Q)$(OBJCOPY) -O binary -j .interrupts -j .text -j .ARM.exidx -j .data $^ $@ + $(Q)$(OBJCOPY) -O binary -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@ $(BUILD)/firmware.uf2: $(BUILD)/firmware.bin $(STEPECHO) "Create $@" $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $^ +$(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 $< $@ + include $(TOP)/py/mkrules.mk # Print out the value of a make variable. diff --git a/ports/mimxrt10xx/background.c b/ports/mimxrt10xx/background.c index 8c7333cf8b..c0b2176853 100644 --- a/ports/mimxrt10xx/background.c +++ b/ports/mimxrt10xx/background.c @@ -34,6 +34,7 @@ #include "py/runtime.h" #include "shared-module/network/__init__.h" +#include "supervisor/linker.h" #include "supervisor/shared/stack.h" // TODO @@ -51,7 +52,7 @@ void background_tasks_reset(void) { running_background_tasks = false; } -void run_background_tasks(void) { +void PLACE_IN_ITCM(run_background_tasks)(void) { // Don't call ourselves recursively. if (running_background_tasks) { return; diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c index 8e73df4ad4..52dd498b3f 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c @@ -27,24 +27,8 @@ #include "boards/board.h" #include "mpconfigboard.h" -#include "fsl_iomuxc.h" void board_init(void) { - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1,1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 1U); - - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B,0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 0x10E1U); } bool board_requests_safe_mode(void) { diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c new file mode 100644 index 0000000000..b74c0b1514 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c @@ -0,0 +1,122 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.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 */ +}; + +__attribute__((section(".boot_hdr.conf"))) +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = FLASH_SIZE, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h index 98d1f478bf..a715a2c563 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.h @@ -1,19 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Feather MIMXRT1011" #define MICROPY_HW_MCU_NAME "IMXRT1011DAE5A" -//TODO -//#define MICROPY_HW_LED_STATUS (&pin_PA27) - #define MICROPY_HW_NEOPIXEL (&pin_GPIO_SD_05) -// These are pins not to reset. -// QSPI Data pins -//#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 ) -// QSPI CS, and QSPI SCK -//#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 ) -//#define MICROPY_PORT_C ( 0 ) -//#define MICROPY_PORT_D ( 0 ) - // If you change this, then make sure to update the linker scripts as well to // make sure you don't overwrite code #define CIRCUITPY_INTERNAL_NVM_SIZE 0 diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk index 6efd3f329a..08164b140d 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/mpconfigboard.mk @@ -1,21 +1,8 @@ -LD_FILE = boards/mimxrt1011-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8074 USB_PRODUCT = "Feather MIMXRT1011" USB_MANUFACTURER = "arturo182" -USB_DEVICES = "CDC,MSC,HID" CHIP_VARIANT = MIMXRT1011DAE5A CHIP_FAMILY = MIMXRT1011 - -INTERNAL_FLASH_FILESYSTEM = 1 - -CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_AUDIOIO = 0 -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CSLAVE = 0 -CIRCUITPY_NVM = 0 -CIRCUITPY_ROTARYIO = 0 - -LONGINT_IMPL = MPZ +FLASH = W25Q64JV diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c index 979dd82ce8..52dd498b3f 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c @@ -27,24 +27,8 @@ #include "boards/board.h" #include "mpconfigboard.h" -#include "fsl_iomuxc.h" void board_init(void) { - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_06_FLEXSPIA_SS0_B, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_07_FLEXSPIA_SCLK,1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_08_FLEXSPIA_DATA00, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_09_FLEXSPIA_DATA01, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_10_FLEXSPIA_DATA02, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_11_FLEXSPIA_DATA03, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_05_FLEXSPIA_DQS, 1U); - - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_06_FLEXSPIA_SS0_B,0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_09_FLEXSPIA_DATA01, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_10_FLEXSPIA_DATA02, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_08_FLEXSPIA_DATA00, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_07_FLEXSPIA_SCLK, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_11_FLEXSPIA_DATA03, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_05_FLEXSPIA_DQS, 0x10E1U); } bool board_requests_safe_mode(void) { diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c new file mode 100644 index 0000000000..b74c0b1514 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c @@ -0,0 +1,122 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.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 */ +}; + +__attribute__((section(".boot_hdr.conf"))) +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = FLASH_SIZE, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h index b91209c82a..4c3953187e 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.h @@ -6,14 +6,6 @@ //#define MICROPY_HW_NEOPIXEL (&pin_PB22) -// These are pins not to reset. -// QSPI Data pins -//#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 ) -// QSPI CS, and QSPI SCK -//#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 ) -//#define MICROPY_PORT_C ( 0 ) -//#define MICROPY_PORT_D ( 0 ) - // If you change this, then make sure to update the linker scripts as well to // make sure you don't overwrite code #define CIRCUITPY_INTERNAL_NVM_SIZE 0 diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk index b2e356e558..1c8646991c 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/mpconfigboard.mk @@ -1,21 +1,8 @@ -LD_FILE = boards/mimxrt1062-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8076 USB_PRODUCT = "Feather MIMXRT1062" USB_MANUFACTURER = "arturo182" -USB_DEVICES = "CDC,MSC,HID" CHIP_VARIANT = MIMXRT1062DVJ6A CHIP_FAMILY = MIMXRT1062 - -INTERNAL_FLASH_FILESYSTEM = 1 - -CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_AUDIOIO = 0 -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CSLAVE = 0 -CIRCUITPY_NVM = 0 -CIRCUITPY_ROTARYIO = 0 - -LONGINT_IMPL = MPZ +FLASH = W25Q64JV diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/board.c b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c index 8e73df4ad4..52dd498b3f 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/board.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c @@ -27,24 +27,8 @@ #include "boards/board.h" #include "mpconfigboard.h" -#include "fsl_iomuxc.h" void board_init(void) { - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1,1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 1U); - IOMUXC_SetPinMux(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 1U); - - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_06_FLEXSPI_A_SS0_B,0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_07_FLEXSPI_A_DATA1, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_08_FLEXSPI_A_DATA2, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_09_FLEXSPI_A_DATA0, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_10_FLEXSPI_A_SCLK, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_11_FLEXSPI_A_DATA3, 0x10E1U); - IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_12_FLEXSPI_A_DQS, 0x10E1U); } bool board_requests_safe_mode(void) { diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c new file mode 100644 index 0000000000..c281d4541e --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c @@ -0,0 +1,141 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.h" + +/* Component ID definition, used by tools. */ +#ifndef FSL_COMPONENT_ID +#define FSL_COMPONENT_ID "platform.drivers.xip_device" +#endif + +#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1) +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) + __attribute__((section(".boot_hdr.ivt"))) +#elif defined(__ICCARM__) +#pragma location=".boot_hdr.ivt" +#endif +/************************************* + * 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 */ +}; + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) + __attribute__((section(".boot_hdr.boot_data"))) +#elif defined(__ICCARM__) +#pragma location=".boot_hdr.boot_data" +#endif +/************************************* + * 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 */ +}; +#endif + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) +__attribute__((section(".boot_hdr.conf"))) +#elif defined(__ICCARM__) +#pragma location = ".boot_hdr.conf" +#endif + +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = FLASH_SIZE, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h index 12cb5e8a86..128e33111e 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.h @@ -1,19 +1,6 @@ #define MICROPY_HW_BOARD_NAME "IMXRT1010-EVK" #define MICROPY_HW_MCU_NAME "IMXRT1011DAE5A" -//TODO -//#define MICROPY_HW_LED_STATUS (&pin_PA27) - -//#define MICROPY_HW_NEOPIXEL (&pin_PB22) - -// These are pins not to reset. -// QSPI Data pins -//#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 ) -// QSPI CS, and QSPI SCK -//#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 ) -//#define MICROPY_PORT_C ( 0 ) -//#define MICROPY_PORT_D ( 0 ) - // If you change this, then make sure to update the linker scripts as well to // make sure you don't overwrite code #define CIRCUITPY_INTERNAL_NVM_SIZE 0 @@ -23,9 +10,5 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO_02) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO_01) -#define DEFAULT_SPI_BUS_SCK (&pin_GPIO_AD_06) -#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO_AD_04) -#define DEFAULT_SPI_BUS_MISO (&pin_GPIO_AD_03) - #define DEFAULT_UART_BUS_RX (&pin_GPIO_09) #define DEFAULT_UART_BUS_TX (&pin_GPIO_10) diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk index 4401647c44..81eb635973 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/mpconfigboard.mk @@ -1,22 +1,8 @@ -LD_FILE = boards/mimxrt1011-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8078 USB_PRODUCT = "IMXRT1010-EVK" USB_MANUFACTURER = "NXP" -USB_DEVICES = "CDC,MSC,HID" CHIP_VARIANT = MIMXRT1011DAE5A CHIP_FAMILY = MIMXRT1011 - -INTERNAL_FLASH_FILESYSTEM = 1 - -CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_AUDIOIO = 0 -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CSLAVE = 0 -CIRCUITPY_NEOPIXEL_WRITE = 0 -CIRCUITPY_NVM = 0 -CIRCUITPY_ROTARYIO = 0 - -LONGINT_IMPL = MPZ +FLASH = AT25SF128A diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c index cfc8763694..a5a598760b 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c @@ -4,21 +4,25 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_09) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_10) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO_AD_05) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO_AD_06) }, - //{ MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO_08) }, // Connected to audio codec - //{ MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_01) }, // Connected to audio codec + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_01) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_AD_01) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO_AD_02) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO_SD_02) }, - //{ MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_03) }, // Connected to audio codec + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_03) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_AD_05) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_AD_04) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_AD_03) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_AD_06) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_01) }, { MP_OBJ_NEW_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_02) }, { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_07) }, { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_09) }, @@ -27,8 +31,24 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_01) }, { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_02) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_USR_LED), MP_ROM_PTR(&pin_GPIO_11) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_USR_SW), MP_ROM_PTR(&pin_GPIO_SD_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_USER_LED), MP_ROM_PTR(&pin_GPIO_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO_SD_05) }, + + // Audio Interface + { MP_ROM_QSTR(MP_QSTR_AUDIO_INT), MP_ROM_PTR(&pin_GPIO_00) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_SYNC), MP_ROM_PTR(&pin_GPIO_07) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_BCLK), MP_ROM_PTR(&pin_GPIO_06) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_RXD), MP_ROM_PTR(&pin_GPIO_03) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_TXD), MP_ROM_PTR(&pin_GPIO_04) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_MCLK), MP_ROM_PTR(&pin_GPIO_08) }, + + // SPDIF + { MP_ROM_QSTR(MP_QSTR_SPDIF_IN), MP_ROM_PTR(&pin_GPIO_10) }, + { MP_ROM_QSTR(MP_QSTR_SPDIF_OUT), MP_ROM_PTR(&pin_GPIO_11) }, + + // Freelink UART + { MP_ROM_QSTR(MP_QSTR_FREELINK_TX), MP_ROM_PTR(&pin_GPIO_10) }, + { MP_ROM_QSTR(MP_QSTR_FREELINK_RX), MP_ROM_PTR(&pin_GPIO_09) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/board.c b/ports/mimxrt10xx/boards/imxrt1020_evk/board.c new file mode 100644 index 0000000000..52dd498b3f --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/board.c @@ -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 + * 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 "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c new file mode 100644 index 0000000000..b74c0b1514 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c @@ -0,0 +1,122 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.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 */ +}; + +__attribute__((section(".boot_hdr.conf"))) +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = FLASH_SIZE, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.h b/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.h new file mode 100644 index 0000000000..a40df100e3 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.h @@ -0,0 +1,14 @@ +#define MICROPY_HW_BOARD_NAME "iMX RT 1020 EVK" +#define MICROPY_HW_MCU_NAME "IMXRT1021DAG5A" + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (8 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_SD_B1_03) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_SD_B1_02) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_B1_09) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_B1_08) diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk b/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk new file mode 100644 index 0000000000..62a2c90dee --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk @@ -0,0 +1,8 @@ +USB_VID = 0x16C0 +USB_PID = 0x8888 +USB_PRODUCT = "iMX RT 1020 EVK" +USB_MANUFACTURER = "NXP" + +CHIP_VARIANT = MIMXRT1021DAG5A +CHIP_FAMILY = MIMXRT1021 +FLASH = IS25LP064A diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c new file mode 100644 index 0000000000..ef8115a64f --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c @@ -0,0 +1,84 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO_AD_B0_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO_AD_B0_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO_AD_B0_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_AD_B0_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_AD_B0_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_AD_B0_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_AD_B0_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_AD_B0_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_SD_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_SD_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO_SD_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_SD_B1_02) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_B1_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_B1_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_USER_LED), MP_ROM_PTR(&pin_GPIO_AD_B0_05) }, + + // SD Card + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CLK), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_SW), MP_ROM_PTR(&pin_GPIO_SD_B0_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CMD), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D0), MP_ROM_PTR(&pin_GPIO_SD_B0_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D1), MP_ROM_PTR(&pin_GPIO_SD_B0_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D2), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D3), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_PWREN), MP_ROM_PTR(&pin_GPIO_SD_B1_04) }, + + // // Audio Interface + { MP_ROM_QSTR(MP_QSTR_AUDIO_INT), MP_ROM_PTR(&pin_GPIO_AD_B1_04) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_SYNC), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_BCLK), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_RXD), MP_ROM_PTR(&pin_GPIO_AD_B1_05) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_TXD), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_MCLK), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + + // // Ethernet + { MP_ROM_QSTR(MP_QSTR_ETHERNET_MDIO), MP_ROM_PTR(&pin_GPIO_EMC_40) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_MDC), MP_ROM_PTR(&pin_GPIO_EMC_41) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RXD0), MP_ROM_PTR(&pin_GPIO_AD_B0_10) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RXD1), MP_ROM_PTR(&pin_GPIO_AD_B0_09) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_CRS_DV), MP_ROM_PTR(&pin_GPIO_AD_B0_11) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_TXD0), MP_ROM_PTR(&pin_GPIO_AD_B0_14) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_TXD1), MP_ROM_PTR(&pin_GPIO_AD_B0_15) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_TXEN), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_INT), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RST), MP_ROM_PTR(&pin_GPIO_AD_B0_04) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_CLK), MP_ROM_PTR(&pin_GPIO_AD_B0_08) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RXER), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + + // // Freelink UART + { MP_ROM_QSTR(MP_QSTR_FREELINK_TX), MP_ROM_PTR(&pin_GPIO_AD_B0_06) }, + { MP_ROM_QSTR(MP_QSTR_FREELINK_RX), MP_ROM_PTR(&pin_GPIO_AD_B0_07) }, + + // CAN + { MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR(&pin_GPIO_SD_B1_00) }, + { MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR(&pin_GPIO_SD_B1_01) }, + { MP_ROM_QSTR(MP_QSTR_CAN_STBY), MP_ROM_PTR(&pin_GPIO_AD_B1_13) }, + + // + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_GPIO_SD_B1_03) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SCL), MP_ROM_PTR(&pin_GPIO_SD_B1_02) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/board.c b/ports/mimxrt10xx/boards/imxrt1060_evk/board.c new file mode 100644 index 0000000000..52dd498b3f --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/board.c @@ -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 + * 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 "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c new file mode 100644 index 0000000000..c281d4541e --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c @@ -0,0 +1,141 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.h" + +/* Component ID definition, used by tools. */ +#ifndef FSL_COMPONENT_ID +#define FSL_COMPONENT_ID "platform.drivers.xip_device" +#endif + +#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1) +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) + __attribute__((section(".boot_hdr.ivt"))) +#elif defined(__ICCARM__) +#pragma location=".boot_hdr.ivt" +#endif +/************************************* + * 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 */ +}; + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) + __attribute__((section(".boot_hdr.boot_data"))) +#elif defined(__ICCARM__) +#pragma location=".boot_hdr.boot_data" +#endif +/************************************* + * 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 */ +}; +#endif + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) +__attribute__((section(".boot_hdr.conf"))) +#elif defined(__ICCARM__) +#pragma location = ".boot_hdr.conf" +#endif + +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = FLASH_SIZE, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h new file mode 100644 index 0000000000..8eccd8aee4 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h @@ -0,0 +1,14 @@ +#define MICROPY_HW_BOARD_NAME "iMX RT 1060 EVK" +#define MICROPY_HW_MCU_NAME "IMXRT1062DVJ6A" + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (8 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_AD_B1_00) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_AD_B1_01) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_B1_07) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_B1_06) diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk new file mode 100644 index 0000000000..a70d1deebc --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk @@ -0,0 +1,8 @@ +USB_VID = 0x16C0 +USB_PID = 0x8888 +USB_PRODUCT = "iMX RT 1060 EVK" +USB_MANUFACTURER = "NXP" + +CHIP_VARIANT = MIMXRT1062DVJ6A +CHIP_FAMILY = MIMXRT1062 +FLASH = IS25WP064A diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c new file mode 100644 index 0000000000..2d268952d1 --- /dev/null +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c @@ -0,0 +1,128 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO_AD_B0_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO_AD_B0_09) }, // Connected to audio codec + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_AD_B0_10) }, // Connected to audio codec + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, // Connected to audio codec + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + + // i2c sensor is on I2C1_SCL/SDA + + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_B1_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_B1_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_USER_LED), MP_ROM_PTR(&pin_GPIO_AD_B0_09) }, + + // Camera Sensor Interface + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_VSYNC), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_PWDN), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_HSYNC), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D9), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_MCLK), MP_ROM_PTR(&pin_GPIO_AD_B1_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D8), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D7), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_PIXCLK), MP_ROM_PTR(&pin_GPIO_AD_B1_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D6), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D2), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D5), MP_ROM_PTR(&pin_GPIO_AD_B1_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D3), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CSI_D4), MP_ROM_PTR(&pin_GPIO_AD_B1_13) }, + + // SD Card + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CLK), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_SW), MP_ROM_PTR(&pin_GPIO_B1_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CMD), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D0), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D1), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D2), MP_ROM_PTR(&pin_GPIO_SD_B0_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_D3), MP_ROM_PTR(&pin_GPIO_SD_B0_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SD_PWREN), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + + // LCD Interface + { MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO_B1_15) }, + { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_ROM_QSTR(MP_QSTR_LCD_ENABLE), MP_ROM_PTR(&pin_GPIO_B0_01) }, + { MP_ROM_QSTR(MP_QSTR_LCD_VSYNC), MP_ROM_PTR(&pin_GPIO_B0_03) }, + { MP_ROM_QSTR(MP_QSTR_LCD_HSYNC), MP_ROM_PTR(&pin_GPIO_B0_02) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO_B0_00) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D0), MP_ROM_PTR(&pin_GPIO_B0_04) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D1), MP_ROM_PTR(&pin_GPIO_B0_05) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D2), MP_ROM_PTR(&pin_GPIO_B0_06) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D3), MP_ROM_PTR(&pin_GPIO_B0_07) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D4), MP_ROM_PTR(&pin_GPIO_B0_08) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D5), MP_ROM_PTR(&pin_GPIO_B0_09) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D6), MP_ROM_PTR(&pin_GPIO_B0_10) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D7), MP_ROM_PTR(&pin_GPIO_B0_11) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D8), MP_ROM_PTR(&pin_GPIO_B0_12) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D9), MP_ROM_PTR(&pin_GPIO_B0_13) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D10), MP_ROM_PTR(&pin_GPIO_B0_14) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D11), MP_ROM_PTR(&pin_GPIO_B0_15) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D12), MP_ROM_PTR(&pin_GPIO_B1_00) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D13), MP_ROM_PTR(&pin_GPIO_B1_01) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D14), MP_ROM_PTR(&pin_GPIO_B1_02) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D15), MP_ROM_PTR(&pin_GPIO_B1_03) }, + + // Touch Interface + { MP_ROM_QSTR(MP_QSTR_LCD_TOUCH_INT), MP_ROM_PTR(&pin_GPIO_AD_B0_11) }, + + // Audio Interface + { MP_ROM_QSTR(MP_QSTR_AUDIO_INT), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_SYNC), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_BCLK), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_RXD), MP_ROM_PTR(&pin_GPIO_AD_B1_12) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_TXD), MP_ROM_PTR(&pin_GPIO_AD_B1_13) }, + { MP_ROM_QSTR(MP_QSTR_AUDIO_MCLK), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + + // SPDIF + { MP_ROM_QSTR(MP_QSTR_SPDIF_IN), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_ROM_QSTR(MP_QSTR_SPDIF_OUT), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + + // Ethernet + { MP_ROM_QSTR(MP_QSTR_ETHERNET_MDIO), MP_ROM_PTR(&pin_GPIO_EMC_41) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_MDC), MP_ROM_PTR(&pin_GPIO_EMC_40) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RXD0), MP_ROM_PTR(&pin_GPIO_B1_04) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RXD1), MP_ROM_PTR(&pin_GPIO_B1_05) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_CRS_DV), MP_ROM_PTR(&pin_GPIO_B1_06) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_TXD0), MP_ROM_PTR(&pin_GPIO_B1_07) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_TXD1), MP_ROM_PTR(&pin_GPIO_B1_08) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_TXEN), MP_ROM_PTR(&pin_GPIO_B1_09) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_INT), MP_ROM_PTR(&pin_GPIO_AD_B0_10) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RST), MP_ROM_PTR(&pin_GPIO_AD_B0_09) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_CLK), MP_ROM_PTR(&pin_GPIO_B1_10) }, + { MP_ROM_QSTR(MP_QSTR_ETHERNET_RXER), MP_ROM_PTR(&pin_GPIO_B1_11) }, + + // Freelink UART + { MP_ROM_QSTR(MP_QSTR_FREELINK_TX), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_ROM_QSTR(MP_QSTR_FREELINK_RX), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + + // CAN + { MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR(&pin_GPIO_AD_B0_14) }, + { MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR(&pin_GPIO_AD_B0_15) }, + { MP_ROM_QSTR(MP_QSTR_CAN_STBY), MP_ROM_PTR(&pin_GPIO_AD_B0_05) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld b/ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld deleted file mode 100644 index d36ee12396..0000000000 --- a/ports/mimxrt10xx/boards/mimxrt1011-bootloader-external-flash.ld +++ /dev/null @@ -1,106 +0,0 @@ -ENTRY(Reset_Handler) - -_minimum_stack_size = 64K; -_minimum_heap_size = 0; - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 8M - FLASH_BOOTLOADER (rx) : ORIGIN = 0x60000000, LENGTH = 48K - FLASH_ISR (rx) : ORIGIN = 0x6000C000, LENGTH = 1K - FLASH_TEXT (rx) : ORIGIN = 0x6000C400, LENGTH = 975K - FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = 7M - RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 32K - OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = 64K -} - -_estack = ORIGIN(OCRAM) + LENGTH(OCRAM); -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); -__fatfs_flash_length = LENGTH(FLASH_FATFS); - -__RAM_VECTOR_TABLE_SIZE_BYTES = 0; - -SECTIONS -{ - .interrupts : - { - __VECTOR_TABLE = .; - __VECTOR_RAM = .; - - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } > FLASH_ISR - - .text : - { - . = ALIGN(4); - *(EXCLUDE_FILE( - *flexspi_nor_flash_ops.o - *fsl_flexspi.o - ) .text*) /* .text* sections (code) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } > FLASH_TEXT - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - __etext = .; /* define a global symbol at end of code */ - } > FLASH_TEXT - - /* used by the startup to initialize data */ - _sidata = .; - - .data : AT (_sidata) - { - . = ALIGN(4); - __data_start__ = .; /* create a global symbol at data start */ - - *(.data*) /* .data* sections */ - *flexspi_nor_flash_ops.o(.text*) - *fsl_flexspi.o(.text*) - . = ALIGN(4); - - __data_end__ = .; /* define a global symbol at data end */ - } > RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - __bss_start__ = .; - - *(.bss*) - *(COMMON) - - . = ALIGN(4); - __bss_end__ = .; - PROVIDE(end = .); - } > RAM - - .heap : - { - . = ALIGN(8); - _heap_start = .; /* define a global symbol at heap start */ - - . += _minimum_heap_size; - - __HeapLimit = .; - } > OCRAM - - .stack : - { - . = ALIGN(8); - . += _minimum_stack_size; - } > OCRAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - -ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") -ASSERT(_estack - _minimum_stack_size >= __HeapLimit, "region OCRAM overflowed with stack and heap") diff --git a/ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld b/ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld deleted file mode 100644 index f1b0d85545..0000000000 --- a/ports/mimxrt10xx/boards/mimxrt1011-external-flash.ld +++ /dev/null @@ -1,123 +0,0 @@ -ENTRY(Reset_Handler) - -_minimum_stack_size = 64K; -_minimum_heap_size = 0; - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 8M - FLASH_CONFIG (rx) : ORIGIN = 0x60000400, LENGTH = 3K - FLASH_IVT (rx) : ORIGIN = 0x60001000, LENGTH = 4K - FLASH_ISR (rx) : ORIGIN = 0x60002000, LENGTH = 1K - FLASH_TEXT (rx) : ORIGIN = 0x60002400, LENGTH = 1015K - FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = 7M - RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 32K - OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = 64K -} - -_estack = ORIGIN(OCRAM) + LENGTH(OCRAM); -_bootloader_dbl_tap = 0; - -__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); -__fatfs_flash_length = LENGTH(FLASH_FATFS); - -__RAM_VECTOR_TABLE_SIZE_BYTES = 0; - -SECTIONS -{ - .flash_config : - { - . = ALIGN(4); - KEEP(* (.boot_hdr.conf)) - . = ALIGN(4); - } > FLASH_CONFIG - - .ivt : - { - . = ALIGN(4); - KEEP(* (.boot_hdr.ivt)) - KEEP(* (.boot_hdr.boot_data)) - KEEP(* (.boot_hdr.dcd_data)) - . = ALIGN(4); - } > FLASH_IVT - - .interrupts : - { - __VECTOR_TABLE = .; - __VECTOR_RAM = .; - - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } > FLASH_ISR - - .text : - { - . = ALIGN(4); - *(EXCLUDE_FILE( - *flexspi_nor_flash_ops.o - *fsl_flexspi.o - ) .text*) /* .text* sections (code) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } > FLASH_TEXT - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - __etext = .; /* define a global symbol at end of code */ - } > FLASH_TEXT - - /* used by the startup to initialize data */ - _sidata = .; - - .data : AT (_sidata) - { - . = ALIGN(4); - __data_start__ = .; /* create a global symbol at data start */ - - *(.data*) /* .data* sections */ - *flexspi_nor_flash_ops.o(.text*) - *fsl_flexspi.o(.text*) - . = ALIGN(4); - - __data_end__ = .; /* define a global symbol at data end */ - } > RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - __bss_start__ = .; - - *(.bss*) - *(COMMON) - - . = ALIGN(4); - __bss_end__ = .; - PROVIDE(end = .); - } > RAM - - .heap : - { - . = ALIGN(8); - _heap_start = .; /* define a global symbol at heap start */ - - . += _minimum_heap_size; - - __HeapLimit = .; - } > OCRAM - - .stack : - { - . = ALIGN(8); - . += _minimum_stack_size; - } > OCRAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - -ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") -ASSERT(_estack - _minimum_stack_size >= __HeapLimit, "region OCRAM overflowed with stack and heap") diff --git a/ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld b/ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld deleted file mode 100644 index 16442607f3..0000000000 --- a/ports/mimxrt10xx/boards/mimxrt1062-bootloader-external-flash.ld +++ /dev/null @@ -1,106 +0,0 @@ -ENTRY(Reset_Handler) - -_minimum_stack_size = 64K; -_minimum_heap_size = 0; - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 8M - FLASH_BOOTLOADER (rx) : ORIGIN = 0x60000000, LENGTH = 48K - FLASH_ISR (rx) : ORIGIN = 0x6000C000, LENGTH = 1K - FLASH_TEXT (rx) : ORIGIN = 0x6000C400, LENGTH = 975K - FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = 7M - RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 128K - OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = 768K -} - -_estack = ORIGIN(OCRAM) + LENGTH(OCRAM); -_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4; - -__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS); -__fatfs_flash_length = LENGTH(FLASH_FATFS); - -__RAM_VECTOR_TABLE_SIZE_BYTES = 0; - -SECTIONS -{ - .interrupts : - { - __VECTOR_TABLE = .; - __VECTOR_RAM = .; - - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } > FLASH_ISR - - .text : - { - . = ALIGN(4); - *(EXCLUDE_FILE( - *flexspi_nor_flash_ops.o - *fsl_flexspi.o - ) .text*) /* .text* sections (code) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } > FLASH_TEXT - - .ARM.exidx : - { - *(.ARM.exidx*) - *(.gnu.linkonce.armexidx.*) - _etext = .; /* define a global symbol at end of code */ - __etext = .; /* define a global symbol at end of code */ - } > FLASH_TEXT - - /* used by the startup to initialize data */ - _sidata = .; - - .data : AT (_sidata) - { - . = ALIGN(4); - __data_start__ = .; /* create a global symbol at data start */ - - *(.data*) /* .data* sections */ - *flexspi_nor_flash_ops.o(.text*) - *fsl_flexspi.o(.text*) - . = ALIGN(4); - - __data_end__ = .; /* define a global symbol at data end */ - } > RAM - - /* Uninitialized data section */ - .bss : - { - . = ALIGN(4); - __bss_start__ = .; - - *(.bss*) - *(COMMON) - - . = ALIGN(4); - __bss_end__ = .; - PROVIDE(end = .); - } > RAM - - .heap : - { - . = ALIGN(8); - _heap_start = .; /* define a global symbol at heap start */ - - . += _minimum_heap_size; - - __HeapLimit = .; - } > OCRAM - - .stack : - { - . = ALIGN(8); - . += _minimum_stack_size; - } > OCRAM - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - -ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") -ASSERT(_estack - _minimum_stack_size >= __HeapLimit, "region OCRAM overflowed with stack and heap") diff --git a/ports/mimxrt10xx/boards/teensy40/board.c b/ports/mimxrt10xx/boards/teensy40/board.c new file mode 100644 index 0000000000..52dd498b3f --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy40/board.c @@ -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 + * 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 "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/teensy40/board.ld b/ports/mimxrt10xx/boards/teensy40/board.ld new file mode 100644 index 0000000000..8f19810a35 --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy40/board.ld @@ -0,0 +1 @@ +_ld_reserved_flash_size = 4K; diff --git a/ports/mimxrt10xx/boards/teensy40/flash_config.c b/ports/mimxrt10xx/boards/teensy40/flash_config.c new file mode 100644 index 0000000000..a0661280b8 --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy40/flash_config.c @@ -0,0 +1,141 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.h" + +/* Component ID definition, used by tools. */ +#ifndef FSL_COMPONENT_ID +#define FSL_COMPONENT_ID "platform.drivers.xip_device" +#endif + +#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1) +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) + __attribute__((section(".boot_hdr.ivt"))) +#elif defined(__ICCARM__) +#pragma location=".boot_hdr.ivt" +#endif +/************************************* + * 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 */ +}; + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) + __attribute__((section(".boot_hdr.boot_data"))) +#elif defined(__ICCARM__) +#pragma location=".boot_hdr.boot_data" +#endif +/************************************* + * 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 */ +}; +#endif + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) +__attribute__((section(".boot_hdr.conf"))) +#elif defined(__ICCARM__) +#pragma location = ".boot_hdr.conf" +#endif + +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = 0x00200000, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/teensy40/mpconfigboard.h b/ports/mimxrt10xx/boards/teensy40/mpconfigboard.h new file mode 100644 index 0000000000..718d9b9673 --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy40/mpconfigboard.h @@ -0,0 +1,18 @@ +#define MICROPY_HW_BOARD_NAME "Teensy 4.0" +#define MICROPY_HW_MCU_NAME "IMXRT1062DVJ6A" + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (2 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_AD_B1_00) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_AD_B1_01) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO_B0_03) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO_B0_02) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO_B0_01) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_B0_03) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_B0_02) diff --git a/ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk b/ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk new file mode 100644 index 0000000000..5913f9c9cb --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk @@ -0,0 +1,8 @@ +USB_VID = 0x239A +USB_PID = 0x8888 +USB_PRODUCT = "Teensy 4.0" +USB_MANUFACTURER = "PJRC" + +CHIP_VARIANT = MIMXRT1062DVJ6A +CHIP_FAMILY = MIMXRT1062 +FLASH = W25Q16JV diff --git a/ports/mimxrt10xx/boards/teensy40/pins.c b/ports/mimxrt10xx/boards/teensy40/pins.c new file mode 100644 index 0000000000..9066ce0d20 --- /dev/null +++ b/ports/mimxrt10xx/boards/teensy40/pins.c @@ -0,0 +1,87 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // With USB on left. Bottom edge. + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_GPIO_AD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_GPIO_AD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO_EMC_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO_EMC_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO_EMC_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_EMC_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_B0_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_B0_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO_B0_01) }, + + // Top edge + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_B1_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_B1_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_B1_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA0), MP_ROM_PTR(&pin_GPIO_AD_B1_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL0), MP_ROM_PTR(&pin_GPIO_AD_B1_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO_AD_B1_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO_AD_B1_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO_AD_B1_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, + + // Back side + { MP_OBJ_NEW_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_GPIO_AD_B0_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO_AD_B0_13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A13), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D28), MP_ROM_PTR(&pin_GPIO_EMC_32) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D29), MP_ROM_PTR(&pin_GPIO_EMC_31) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D30), MP_ROM_PTR(&pin_GPIO_EMC_37) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D31), MP_ROM_PTR(&pin_GPIO_EMC_36) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D32), MP_ROM_PTR(&pin_GPIO_B0_12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D33), MP_ROM_PTR(&pin_GPIO_EMC_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT1), MP_ROM_PTR(&pin_GPIO_SD_B0_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT0), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_CMD), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO_SD_B0_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT3), MP_ROM_PTR(&pin_GPIO_SD_B0_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO_SD_B0_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_DAT2), MP_ROM_PTR(&pin_GPIO_SD_B0_05) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 68de3a8907..a9f4c740fe 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -72,10 +72,10 @@ void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { } // Pretend to be the first of the two reset presses needed to enter the // bootloader. That way one reset will end in the bootloader. - _bootloader_dbl_tap = DBL_TAP_MAGIC; + SNVS->LPGPR[0] = DBL_TAP_MAGIC; } else { // Set up the default. - _bootloader_dbl_tap = DBL_TAP_MAGIC_QUICK_BOOT; + SNVS->LPGPR[0] = DBL_TAP_MAGIC_QUICK_BOOT; } if (runmode == RUNMODE_SAFE_MODE) { safe_mode_on_next_reset(PROGRAMMATIC_SAFE_MODE); @@ -229,6 +229,7 @@ STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_13), MP_ROM_PTR(&pin_GPIO_AD_B1_13) }, { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_14), MP_ROM_PTR(&pin_GPIO_AD_B1_14) }, { MP_ROM_QSTR(MP_QSTR_GPIO_AD_B1_15), MP_ROM_PTR(&pin_GPIO_AD_B1_15) }, + #ifdef MIMXRT1062_SERIES { MP_ROM_QSTR(MP_QSTR_GPIO_B0_00), MP_ROM_PTR(&pin_GPIO_B0_00) }, { MP_ROM_QSTR(MP_QSTR_GPIO_B0_01), MP_ROM_PTR(&pin_GPIO_B0_01) }, { MP_ROM_QSTR(MP_QSTR_GPIO_B0_02), MP_ROM_PTR(&pin_GPIO_B0_02) }, @@ -261,6 +262,7 @@ STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GPIO_B1_13), MP_ROM_PTR(&pin_GPIO_B1_13) }, { MP_ROM_QSTR(MP_QSTR_GPIO_B1_14), MP_ROM_PTR(&pin_GPIO_B1_14) }, { MP_ROM_QSTR(MP_QSTR_GPIO_B1_15), MP_ROM_PTR(&pin_GPIO_B1_15) }, + #endif { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_00), MP_ROM_PTR(&pin_GPIO_SD_B0_00) }, { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_01), MP_ROM_PTR(&pin_GPIO_SD_B0_01) }, { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B0_02), MP_ROM_PTR(&pin_GPIO_SD_B0_02) }, diff --git a/ports/mimxrt10xx/linking/chip_family/MIMXRT1011.ld b/ports/mimxrt10xx/linking/chip_family/MIMXRT1011.ld new file mode 100644 index 0000000000..0d0beebaae --- /dev/null +++ b/ports/mimxrt10xx/linking/chip_family/MIMXRT1011.ld @@ -0,0 +1,2 @@ +ram_size = 128K; +flash_config_location = 0x60000400; diff --git a/ports/mimxrt10xx/linking/chip_family/MIMXRT1021.ld b/ports/mimxrt10xx/linking/chip_family/MIMXRT1021.ld new file mode 100644 index 0000000000..21f2ea872c --- /dev/null +++ b/ports/mimxrt10xx/linking/chip_family/MIMXRT1021.ld @@ -0,0 +1,2 @@ +ram_size = 256K; +flash_config_location = 0x60000000; diff --git a/ports/mimxrt10xx/linking/chip_family/MIMXRT1062.ld b/ports/mimxrt10xx/linking/chip_family/MIMXRT1062.ld new file mode 100644 index 0000000000..e07c5c2c37 --- /dev/null +++ b/ports/mimxrt10xx/linking/chip_family/MIMXRT1062.ld @@ -0,0 +1,2 @@ +ram_size = 1M; +flash_config_location = 0x60000000; diff --git a/ports/mimxrt10xx/linking/common.ld b/ports/mimxrt10xx/linking/common.ld new file mode 100644 index 0000000000..5cead9ed04 --- /dev/null +++ b/ports/mimxrt10xx/linking/common.ld @@ -0,0 +1,158 @@ +/* Template for iMX RT 10xx linking. This is the last of four linker scripts passed in. + +The first three provide variables for this one. + +Boards can setup reserved flash with _ld_reserved_flash_size in board.ld. */ + +ENTRY(Reset_Handler) + +code_size = 1M; +_ld_default_stack_size = 20K; + +/* Default reserved flash to nothing. */ +_ld_reserved_flash_size = DEFINED(_ld_reserved_flash_size) ? _ld_reserved_flash_size : 0K ; + +MEMORY +{ + /* These next two sections are included in place of a bootloader. If a UF2 is used to load, it + will ignore these two sections because it lives there. */ + /* This is the first block and is read so that the bootrom knows the optimal way to interface with the flash chip. */ + FLASH_CONFIG (rx) : ORIGIN = flash_config_location, LENGTH = 512 + /* This can't move because the bootrom looks at this address. */ + FLASH_IVT (rx) : ORIGIN = 0x60001000, LENGTH = 4K + /* Place the ISRs 48k in to leave room for the bootloader when it is available. */ + FLASH_TEXT (rx) : ORIGIN = 0x6000C000, LENGTH = code_size - 48K + FLASH_FATFS (r) : ORIGIN = 0x60100000, 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 + OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = ram_size - 64K + DTCM (x) : ORIGIN = 0x20000000, LENGTH = 32K + ITCM (x) : ORIGIN = 0x00000000, LENGTH = 32K +} + +__RAM_VECTOR_TABLE_SIZE_BYTES = 0; + +SECTIONS +{ + .flash_config : + { + . = ALIGN(4); + KEEP(* (.boot_hdr.conf)) + . = ALIGN(4); + } > FLASH_CONFIG + + .ivt : + { + . = ALIGN(4); + KEEP(* (.boot_hdr.ivt)) + KEEP(* (.boot_hdr.boot_data)) + KEEP(* (.boot_hdr.dcd_data)) + . = ALIGN(4); + } > FLASH_IVT + image_vector_table = LOADADDR(.ivt); + + .text : + { + . = ALIGN(4); + __VECTOR_TABLE = .; + __VECTOR_RAM = .; + _ld_isr_table = .; + + KEEP(*(.isr_vector)) /* Startup code */ + *(EXCLUDE_FILE( + *flexspi_nor_flash_ops.o + *fsl_flexspi.o + ) .text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } > FLASH_TEXT + + .ARM.exidx : + { + *(.ARM.exidx*) + *(.gnu.linkonce.armexidx.*) + _etext = .; /* define a global symbol at end of code */ + __etext = .; /* define a global symbol at end of code */ + } > FLASH_TEXT + + _ld_filesystem_start = ORIGIN(FLASH_FATFS); + _ld_filesystem_end = _ld_filesystem_start + LENGTH(FLASH_FATFS); + + .data : + { + . = ALIGN(4); + _sidata = .; + __data_start__ = .; /* create a global symbol at data start */ + + *(.data*) /* .data* sections */ + *flexspi_nor_flash_ops.o(.text*) + *fsl_flexspi.o(.text*) + . = ALIGN(4); + + __data_end__ = .; /* define a global symbol at data end */ + } > OCRAM AT> FLASH_TEXT + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + + *(.bss*) + *(COMMON) + + . = ALIGN(4); + __bss_end__ = .; + _ld_heap_start = .; + PROVIDE(end = .); + } > OCRAM + _ld_heap_end = ORIGIN(OCRAM) + LENGTH(OCRAM); + + .itcm : + { + . = ALIGN(4); + + *(.itcm.*) + + . = ALIGN(4); + } > ITCM AT> FLASH_TEXT + _ld_itcm_destination = ADDR(.itcm); + _ld_itcm_flash_copy = LOADADDR(.itcm); + _ld_itcm_size = SIZEOF(.itcm); + + .dtcm_data : + { + . = ALIGN(4); + + *(.dtcm_data.*) + + . = ALIGN(4); + } > DTCM AT> FLASH_TEXT + _ld_dtcm_data_destination = ADDR(.dtcm_data); + _ld_dtcm_data_flash_copy = LOADADDR(.dtcm_data); + _ld_dtcm_data_size = SIZEOF(.dtcm_data); + + .dtcm_bss : + { + . = ALIGN(4); + + *(.dtcm_bss.*) + + . = ALIGN(4); + } > DTCM AT> DTCM + _ld_dtcm_bss_start = ADDR(.dtcm_bss); + _ld_dtcm_bss_end = ADDR(.dtcm_bss) + SIZEOF(.dtcm_bss); + + .stack : + { + . = ALIGN(8); + _ld_stack_bottom = .; + . += _ld_default_stack_size; + } > DTCM + _ld_stack_top = ORIGIN(DTCM) + LENGTH(DTCM); + _estack = _ld_stack_top; + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + +ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") diff --git a/ports/mimxrt10xx/linking/flash/AT25SF128A.ld b/ports/mimxrt10xx/linking/flash/AT25SF128A.ld new file mode 100644 index 0000000000..205d9dd839 --- /dev/null +++ b/ports/mimxrt10xx/linking/flash/AT25SF128A.ld @@ -0,0 +1 @@ +_ld_flash_size = 16M; diff --git a/ports/mimxrt10xx/linking/flash/IS25LP064A.ld b/ports/mimxrt10xx/linking/flash/IS25LP064A.ld new file mode 100644 index 0000000000..53d296ec80 --- /dev/null +++ b/ports/mimxrt10xx/linking/flash/IS25LP064A.ld @@ -0,0 +1 @@ +_ld_flash_size = 8M; diff --git a/ports/mimxrt10xx/linking/flash/IS25WP064A.ld b/ports/mimxrt10xx/linking/flash/IS25WP064A.ld new file mode 100644 index 0000000000..53d296ec80 --- /dev/null +++ b/ports/mimxrt10xx/linking/flash/IS25WP064A.ld @@ -0,0 +1 @@ +_ld_flash_size = 8M; diff --git a/ports/mimxrt10xx/linking/flash/W25Q16JV.ld b/ports/mimxrt10xx/linking/flash/W25Q16JV.ld new file mode 100644 index 0000000000..9ce06b44a8 --- /dev/null +++ b/ports/mimxrt10xx/linking/flash/W25Q16JV.ld @@ -0,0 +1 @@ +_ld_flash_size = 2M; diff --git a/ports/mimxrt10xx/linking/flash/W25Q64JV.ld b/ports/mimxrt10xx/linking/flash/W25Q64JV.ld new file mode 100644 index 0000000000..53d296ec80 --- /dev/null +++ b/ports/mimxrt10xx/linking/flash/W25Q64JV.ld @@ -0,0 +1 @@ +_ld_flash_size = 8M; diff --git a/ports/mimxrt10xx/mpconfigport.h b/ports/mimxrt10xx/mpconfigport.h index 47b793fed9..745c12f7de 100644 --- a/ports/mimxrt10xx/mpconfigport.h +++ b/ports/mimxrt10xx/mpconfigport.h @@ -28,11 +28,17 @@ #ifndef __INCLUDED_MPCONFIGPORT_H #define __INCLUDED_MPCONFIGPORT_H +#include + #define MICROPY_PY_SYS_PLATFORM "NXP IMXRT10XX" #define SPI_FLASH_MAX_BAUDRATE 24000000 +extern uint8_t _ld_filesystem_start; +extern uint8_t _ld_filesystem_end; +extern uint8_t _ld_default_stack_size; + // 20kiB stack -#define CIRCUITPY_DEFAULT_STACK_SIZE 0x5000 +#define CIRCUITPY_DEFAULT_STACK_SIZE ((uint32_t) &_ld_default_stack_size) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) #define MICROPY_PY_FUNCTION_ATTRS (0) @@ -40,6 +46,10 @@ #define MICROPY_PY_UJSON (1) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) + +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR ((uint32_t) &_ld_filesystem_start) +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE ((uint32_t) (&_ld_filesystem_end - &_ld_filesystem_start)) + #include "py/circuitpy_mpconfig.h" #define MICROPY_PORT_ROOT_POINTERS \ diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index f1106e88f0..b928ce3bb4 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -1,6 +1,4 @@ -# 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. +LD_FILE = $(FLASH).ld $(CHIP_FAMILY).ld imxrt10xx.ld ifeq ($(LONGINT_IMPL),NONE) MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none @@ -16,5 +14,18 @@ endif INTERNAL_LIBM = 1 +USB_DEVICES = "CDC,MSC,HID" USB_SERIAL_NUMBER_LENGTH = 32 USB_MSC_MAX_PACKET_SIZE = 512 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_NVM = 0 +CIRCUITPY_ROTARYIO = 0 + +LONGINT_IMPL = MPZ diff --git a/ports/mimxrt10xx/mphalport.c b/ports/mimxrt10xx/mphalport.c index b333730b9a..06275cd83c 100644 --- a/ports/mimxrt10xx/mphalport.c +++ b/ports/mimxrt10xx/mphalport.c @@ -49,7 +49,7 @@ void mp_hal_delay_ms(mp_uint_t delay) { } void mp_hal_delay_us(mp_uint_t delay) { -#ifdef MIMXRT1011_SERIES +#if defined(MIMXRT1011_SERIES) || defined(MIMXRT1021_SERIES) SDK_DelayAtLeastUs(delay, SystemCoreClock); #else SDK_DelayAtLeastUs(delay); diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c new file mode 100644 index 0000000000..7dc08f6dde --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c @@ -0,0 +1,371 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Artur Pacholec + * Copyright (c) 2020 Scott Shawcroft + * + * 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. + */ +/* + * Copyright 2019 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "mpconfigport.h" + +#include "fsl_clock.h" +#include "fsl_iomuxc.h" + +// These values are pulled from the SDK's devices/MIMXRT1021/project_template/clock_config.* files. + +#define BOARD_XTAL0_CLK_HZ 24000000U /*!< Board xtal0 frequency in Hz */ +#define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32k frequency in Hz */ + +#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 500000000U /*!< Core clock frequency: 500000000Hz */ + +/* Clock outputs (values are in Hz): */ +#define BOARD_BOOTCLOCKRUN_AHB_CLK_ROOT 500000000UL +#define BOARD_BOOTCLOCKRUN_CAN_CLK_ROOT 40000000UL +#define BOARD_BOOTCLOCKRUN_CKIL_SYNC_CLK_ROOT 32768UL +#define BOARD_BOOTCLOCKRUN_CLKO1_CLK 0UL +#define BOARD_BOOTCLOCKRUN_CLKO2_CLK 0UL +#define BOARD_BOOTCLOCKRUN_CLK_1M 1000000UL +#define BOARD_BOOTCLOCKRUN_CLK_24M 24000000UL +#define BOARD_BOOTCLOCKRUN_ENET1_TX_CLK 0UL +#define BOARD_BOOTCLOCKRUN_ENET_125M_CLK 0UL +#define BOARD_BOOTCLOCKRUN_ENET_25M_REF_CLK 0UL +#define BOARD_BOOTCLOCKRUN_ENET_500M_REF_CLK 500000000UL +#define BOARD_BOOTCLOCKRUN_FLEXIO1_CLK_ROOT 30000000UL +#define BOARD_BOOTCLOCKRUN_FLEXSPI_CLK_ROOT 132000000UL +#define BOARD_BOOTCLOCKRUN_GPT1_IPG_CLK_HIGHFREQ 62500000UL +#define BOARD_BOOTCLOCKRUN_GPT2_IPG_CLK_HIGHFREQ 62500000UL +#define BOARD_BOOTCLOCKRUN_IPG_CLK_ROOT 125000000UL +#define BOARD_BOOTCLOCKRUN_LPI2C_CLK_ROOT 60000000UL +#define BOARD_BOOTCLOCKRUN_LPSPI_CLK_ROOT 105600000UL +#define BOARD_BOOTCLOCKRUN_MQS_MCLK 63529411UL +#define BOARD_BOOTCLOCKRUN_PERCLK_CLK_ROOT 62500000UL +#define BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI1_MCLK1 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI1_MCLK2 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI1_MCLK3 30000000UL +#define BOARD_BOOTCLOCKRUN_SAI2_CLK_ROOT 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI2_MCLK1 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI2_MCLK2 0UL +#define BOARD_BOOTCLOCKRUN_SAI2_MCLK3 30000000UL +#define BOARD_BOOTCLOCKRUN_SAI3_CLK_ROOT 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI3_MCLK1 63529411UL +#define BOARD_BOOTCLOCKRUN_SAI3_MCLK2 0UL +#define BOARD_BOOTCLOCKRUN_SAI3_MCLK3 30000000UL +#define BOARD_BOOTCLOCKRUN_SEMC_CLK_ROOT 62500000UL +#define BOARD_BOOTCLOCKRUN_SPDIF0_CLK_ROOT 30000000UL +#define BOARD_BOOTCLOCKRUN_SPDIF0_EXTCLK_OUT 0UL +#define BOARD_BOOTCLOCKRUN_TRACE_CLK_ROOT 117333333UL +#define BOARD_BOOTCLOCKRUN_UART_CLK_ROOT 80000000UL +#define BOARD_BOOTCLOCKRUN_USBPHY1_CLK 0UL +#define BOARD_BOOTCLOCKRUN_USDHC1_CLK_ROOT 176000000UL +#define BOARD_BOOTCLOCKRUN_USDHC2_CLK_ROOT 176000000UL + +const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN = { + .loopDivider = 1, /* PLL loop divider, Fout = Fin * ( 20 + loopDivider*2 + numerator / denominator ) */ + .numerator = 0, /* 30 bit numerator of fractional loop divider */ + .denominator = 1, /* 30 bit denominator of fractional loop divider */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ +}; +const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN = { + .loopDivider = 0, /* PLL loop divider, Fout = Fin * 20 */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ +}; +const clock_enet_pll_config_t enetPllConfig_BOARD_BootClockRUN = { + .enableClkOutput = false, /* Disable the PLL providing the ENET 125MHz reference clock */ + .enableClkOutput500M = true, /* Enable the PLL providing the ENET 500MHz reference clock */ + .enableClkOutput25M = false, /* Disable the PLL providing the ENET 25MHz reference clock */ + .loopDivider = 1, /* Set frequency of ethernet reference clock to 50 MHz */ + .src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ +}; + +// Based on the hello_world example in the SDK +void clocks_init(void) { + /* Init RTC OSC clock frequency. */ + CLOCK_SetRtcXtalFreq(32768U); + /* Enable 1MHz clock output. */ + XTALOSC24M->OSC_CONFIG2 |= XTALOSC24M_OSC_CONFIG2_ENABLE_1M_MASK; + /* Use free 1MHz clock output. */ + XTALOSC24M->OSC_CONFIG2 &= ~XTALOSC24M_OSC_CONFIG2_MUX_1M_MASK; + /* Set XTAL 24MHz clock frequency. */ + CLOCK_SetXtalFreq(24000000U); + /* Enable XTAL 24MHz clock source. */ + CLOCK_InitExternalClk(0); + /* Enable internal RC. */ + CLOCK_InitRcOsc24M(); + /* Switch clock source to external OSC. */ + CLOCK_SwitchOsc(kCLOCK_XtalOsc); + /* Set Oscillator ready counter value. */ + CCM->CCR = (CCM->CCR & (~CCM_CCR_OSCNT_MASK)) | CCM_CCR_OSCNT(127); + /* Setting PeriphClk2Mux and PeriphMux to provide stable clock before PLLs are initialed */ + CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 1); /* Set PERIPH_CLK2 MUX to OSC */ + CLOCK_SetMux(kCLOCK_PeriphMux, 1); /* Set PERIPH_CLK MUX to PERIPH_CLK2 */ + /* Setting the VDD_SOC to 1.5V. It is necessary to config AHB to 500Mhz. */ + DCDC->REG3 = (DCDC->REG3 & (~DCDC_REG3_TRG_MASK)) | DCDC_REG3_TRG(0x12); + /* Waiting for DCDC_STS_DC_OK bit is asserted */ + while (DCDC_REG0_STS_DC_OK_MASK != (DCDC_REG0_STS_DC_OK_MASK & DCDC->REG0)) + { + } + /* Set AHB_PODF. */ + CLOCK_SetDiv(kCLOCK_AhbDiv, 0); + /* Disable IPG clock gate. */ + CLOCK_DisableClock(kCLOCK_Adc1); + CLOCK_DisableClock(kCLOCK_Adc2); + CLOCK_DisableClock(kCLOCK_Xbar1); + CLOCK_DisableClock(kCLOCK_Xbar2); + /* Set IPG_PODF. */ + CLOCK_SetDiv(kCLOCK_IpgDiv, 3); + /* Set ARM_PODF. */ + CLOCK_SetDiv(kCLOCK_ArmDiv, 0); + /* Set PERIPH_CLK2_PODF. */ + CLOCK_SetDiv(kCLOCK_PeriphClk2Div, 0); + /* Disable PERCLK clock gate. */ + CLOCK_DisableClock(kCLOCK_Gpt1); + CLOCK_DisableClock(kCLOCK_Gpt1S); + CLOCK_DisableClock(kCLOCK_Gpt2); + CLOCK_DisableClock(kCLOCK_Gpt2S); + CLOCK_DisableClock(kCLOCK_Pit); + /* Set PERCLK_PODF. */ + CLOCK_SetDiv(kCLOCK_PerclkDiv, 1); + /* Disable USDHC1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Usdhc1); + /* Set USDHC1_PODF. */ + CLOCK_SetDiv(kCLOCK_Usdhc1Div, 2); + /* Set Usdhc1 clock source. */ + CLOCK_SetMux(kCLOCK_Usdhc1Mux, 0); + /* Disable USDHC2 clock gate. */ + CLOCK_DisableClock(kCLOCK_Usdhc2); + /* Set USDHC2_PODF. */ + CLOCK_SetDiv(kCLOCK_Usdhc2Div, 2); + /* Set Usdhc2 clock source. */ + CLOCK_SetMux(kCLOCK_Usdhc2Mux, 0); + /* In SDK projects, SDRAM (configured by SEMC) will be initialized in either debug script or dcd. + * With this macro SKIP_SYSCLK_INIT, system pll (selected to be SEMC source clock in SDK projects) will be left + * unchanged. Note: If another clock source is selected for SEMC, user may want to avoid changing that clock as + * well.*/ +#ifndef SKIP_SYSCLK_INIT + /* Disable Semc clock gate. */ + CLOCK_DisableClock(kCLOCK_Semc); + /* Set SEMC_PODF. */ + CLOCK_SetDiv(kCLOCK_SemcDiv, 7); + /* Set Semc alt clock source. */ + CLOCK_SetMux(kCLOCK_SemcAltMux, 0); + /* Set Semc clock source. */ + CLOCK_SetMux(kCLOCK_SemcMux, 0); +#endif + /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. + * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left + * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as + * well.*/ +#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) + /* Disable Flexspi clock gate. */ + CLOCK_DisableClock(kCLOCK_FlexSpi); + /* Set FLEXSPI_PODF. */ + CLOCK_SetDiv(kCLOCK_FlexspiDiv, 3); + /* Set Flexspi clock source. */ + CLOCK_SetMux(kCLOCK_FlexspiMux, 2); +#endif + /* Disable LPSPI clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpspi1); + CLOCK_DisableClock(kCLOCK_Lpspi2); + CLOCK_DisableClock(kCLOCK_Lpspi3); + CLOCK_DisableClock(kCLOCK_Lpspi4); + /* Set LPSPI_PODF. */ + CLOCK_SetDiv(kCLOCK_LpspiDiv, 4); + /* Set Lpspi clock source. */ + CLOCK_SetMux(kCLOCK_LpspiMux, 2); + /* Disable TRACE clock gate. */ + CLOCK_DisableClock(kCLOCK_Trace); + /* Set TRACE_PODF. */ + CLOCK_SetDiv(kCLOCK_TraceDiv, 2); + /* Set Trace clock source. */ + CLOCK_SetMux(kCLOCK_TraceMux, 2); + /* Disable SAI1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai1); + /* Set SAI1_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai1PreDiv, 3); + /* Set SAI1_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai1Div, 1); + /* Set Sai1 clock source. */ + CLOCK_SetMux(kCLOCK_Sai1Mux, 0); + /* Disable SAI2 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai2); + /* Set SAI2_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai2PreDiv, 3); + /* Set SAI2_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai2Div, 1); + /* Set Sai2 clock source. */ + CLOCK_SetMux(kCLOCK_Sai2Mux, 0); + /* Disable SAI3 clock gate. */ + CLOCK_DisableClock(kCLOCK_Sai3); + /* Set SAI3_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Sai3PreDiv, 3); + /* Set SAI3_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Sai3Div, 1); + /* Set Sai3 clock source. */ + CLOCK_SetMux(kCLOCK_Sai3Mux, 0); + /* Disable Lpi2c clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpi2c1); + CLOCK_DisableClock(kCLOCK_Lpi2c2); + CLOCK_DisableClock(kCLOCK_Lpi2c3); + /* Set LPI2C_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Lpi2cDiv, 0); + /* Set Lpi2c clock source. */ + CLOCK_SetMux(kCLOCK_Lpi2cMux, 0); + /* Disable CAN clock gate. */ + CLOCK_DisableClock(kCLOCK_Can1); + CLOCK_DisableClock(kCLOCK_Can2); + CLOCK_DisableClock(kCLOCK_Can1S); + CLOCK_DisableClock(kCLOCK_Can2S); + /* Set CAN_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_CanDiv, 1); + /* Set Can clock source. */ + CLOCK_SetMux(kCLOCK_CanMux, 2); + /* Disable UART clock gate. */ + CLOCK_DisableClock(kCLOCK_Lpuart1); + CLOCK_DisableClock(kCLOCK_Lpuart2); + CLOCK_DisableClock(kCLOCK_Lpuart3); + CLOCK_DisableClock(kCLOCK_Lpuart4); + CLOCK_DisableClock(kCLOCK_Lpuart5); + CLOCK_DisableClock(kCLOCK_Lpuart6); + CLOCK_DisableClock(kCLOCK_Lpuart7); + CLOCK_DisableClock(kCLOCK_Lpuart8); + /* Set UART_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_UartDiv, 0); + /* Set Uart clock source. */ + CLOCK_SetMux(kCLOCK_UartMux, 0); + /* Disable SPDIF clock gate. */ + CLOCK_DisableClock(kCLOCK_Spdif); + /* Set SPDIF0_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Spdif0PreDiv, 1); + /* Set SPDIF0_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Spdif0Div, 7); + /* Set Spdif clock source. */ + CLOCK_SetMux(kCLOCK_SpdifMux, 3); + /* Disable Flexio1 clock gate. */ + CLOCK_DisableClock(kCLOCK_Flexio1); + /* Set FLEXIO1_CLK_PRED. */ + CLOCK_SetDiv(kCLOCK_Flexio1PreDiv, 1); + /* Set FLEXIO1_CLK_PODF. */ + CLOCK_SetDiv(kCLOCK_Flexio1Div, 7); + /* Set Flexio1 clock source. */ + CLOCK_SetMux(kCLOCK_Flexio1Mux, 3); + /* Set Pll3 sw clock source. */ + CLOCK_SetMux(kCLOCK_Pll3SwMux, 0); + /* In SDK projects, SDRAM (configured by SEMC) will be initialized in either debug script or dcd. + * With this macro SKIP_SYSCLK_INIT, system pll (selected to be SEMC source clock in SDK projects) will be left + * unchanged. Note: If another clock source is selected for SEMC, user may want to avoid changing that clock as + * well.*/ +#ifndef SKIP_SYSCLK_INIT +#if defined(XIP_BOOT_HEADER_DCD_ENABLE) && (XIP_BOOT_HEADER_DCD_ENABLE == 1) + #warning "SKIP_SYSCLK_INIT should be defined to keep system pll (selected to be SEMC source clock in SDK projects) unchanged." +#endif + /* Init System PLL. */ + CLOCK_InitSysPll(&sysPllConfig_BOARD_BootClockRUN); + /* Init System pfd0. */ + CLOCK_InitSysPfd(kCLOCK_Pfd0, 27); + /* Init System pfd1. */ + CLOCK_InitSysPfd(kCLOCK_Pfd1, 16); + /* Init System pfd2. */ + CLOCK_InitSysPfd(kCLOCK_Pfd2, 18); + /* Init System pfd3. */ + CLOCK_InitSysPfd(kCLOCK_Pfd3, 18); +#endif + /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. + * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left + * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as + * well.*/ +#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) + /* Init Usb1 PLL. */ + CLOCK_InitUsb1Pll(&usb1PllConfig_BOARD_BootClockRUN); + /* Init Usb1 pfd0. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 22); + /* Init Usb1 pfd1. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd1, 16); + /* Init Usb1 pfd2. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd2, 17); + /* Init Usb1 pfd3. */ + CLOCK_InitUsb1Pfd(kCLOCK_Pfd3, 18); + /* Disable Usb1 PLL output for USBPHY1. */ + CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; +#endif + /* 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; + /* Init Enet PLL. */ + CLOCK_InitEnetPll(&enetPllConfig_BOARD_BootClockRUN); + /* Set preperiph clock source. */ + CLOCK_SetMux(kCLOCK_PrePeriphMux, 3); + /* Set periph clock source. */ + CLOCK_SetMux(kCLOCK_PeriphMux, 0); + /* Set periph clock2 clock source. */ + CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 0); + /* Set per clock source. */ + CLOCK_SetMux(kCLOCK_PerclkMux, 0); + /* Set clock out1 divider. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO1_DIV_MASK)) | CCM_CCOSR_CLKO1_DIV(0); + /* Set clock out1 source. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO1_SEL_MASK)) | CCM_CCOSR_CLKO1_SEL(1); + /* Set clock out2 divider. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO2_DIV_MASK)) | CCM_CCOSR_CLKO2_DIV(0); + /* Set clock out2 source. */ + CCM->CCOSR = (CCM->CCOSR & (~CCM_CCOSR_CLKO2_SEL_MASK)) | CCM_CCOSR_CLKO2_SEL(3); + /* Set clock out1 drives clock out1. */ + CCM->CCOSR &= ~CCM_CCOSR_CLK_OUT_SEL_MASK; + /* Disable clock out1. */ + CCM->CCOSR &= ~CCM_CCOSR_CLKO1_EN_MASK; + /* Disable clock out2. */ + CCM->CCOSR &= ~CCM_CCOSR_CLKO2_EN_MASK; + /* Set SAI1 MCLK1 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk1Sel, 0); + /* Set SAI1 MCLK2 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk2Sel, 0); + /* Set SAI1 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI1MClk3Sel, 0); + /* Set SAI2 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI2MClk3Sel, 0); + /* Set SAI3 MCLK3 clock source. */ + IOMUXC_SetSaiMClkClockSource(IOMUXC_GPR, kIOMUXC_GPR_SAI3MClk3Sel, 0); + /* Set MQS configuration. */ + IOMUXC_MQSConfig(IOMUXC_GPR, kIOMUXC_MqsPwmOverSampleRate32, 0); + /* Set ENET Tx clock source. */ + IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1RefClkMode, false); + /* Set GPT1 High frequency reference clock source. */ + IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT1_MASK; + /* Set GPT2 High frequency reference clock source. */ + IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT2_MASK; + /* Set SystemCoreClock variable. */ + SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK; + + CLOCK_EnableClock(kCLOCK_Iomuxc); +} diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c new file mode 100644 index 0000000000..39e4f0131d --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c @@ -0,0 +1,218 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * Copyright (c) 2019 Artur Pacholec + * Copyright (c) 2020 Scott Shawcroft + * + * 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/obj.h" +#include "py/mphal.h" +#include "mimxrt10xx/periph.h" + +LPI2C_Type *mcu_i2c_banks[] = { LPI2C1, LPI2C2, LPI2C3, LPI2C4 }; + +const mcu_periph_obj_t mcu_i2c_sda_list[8] = { + PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_B1_15), + PERIPH_PIN(1, 6, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 1, &pin_GPIO_EMC_03), + + PERIPH_PIN(2, 0, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_B1_09), + PERIPH_PIN(2, 2, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 1, &pin_GPIO_EMC_18), + + PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_B0_09), + PERIPH_PIN(3, 4, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 1, &pin_GPIO_SD_B0_01), + + PERIPH_PIN(4, 2, kIOMUXC_LPI2C4_SDA_SELECT_INPUT, 0, &pin_GPIO_EMC_10), + PERIPH_PIN(4, 3, kIOMUXC_LPI2C4_SDA_SELECT_INPUT, 1, &pin_GPIO_SD_B1_03), +}; + +const mcu_periph_obj_t mcu_i2c_scl_list[8] = { + PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_B1_14), + PERIPH_PIN(1, 6, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 1, &pin_GPIO_EMC_02), + + PERIPH_PIN(2, 0, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_B1_08), + PERIPH_PIN(2, 2, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 1, &pin_GPIO_EMC_19), + + PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_B0_08), + PERIPH_PIN(3, 4, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 1, &pin_GPIO_SD_B0_00), + + PERIPH_PIN(4, 2, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 0, &pin_GPIO_EMC_11), + PERIPH_PIN(4, 3, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 1, &pin_GPIO_SD_B1_02), +}; + +LPSPI_Type *mcu_spi_banks[] = { LPSPI1, LPSPI2, LPSPI3, LPSPI4 }; + +const mcu_periph_obj_t mcu_spi_sck_list[8] = { + PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B0_10), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 1, &pin_GPIO_SD_B0_02), + + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 0, &pin_GPIO_EMC_00), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 1, &pin_GPIO_EMC_10), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 2, &pin_GPIO_SD_B1_07), + + PERIPH_PIN(3, 2, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B1_12), + + PERIPH_PIN(4, 2, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B1_02), + PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 1, &pin_GPIO_EMC_32), +}; + +const mcu_periph_obj_t mcu_spi_mosi_list[8] = { + PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B0_13), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 1, &pin_GPIO_SD_B0_05), + + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_EMC_03), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_EMC_13), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 2, &pin_GPIO_SD_B1_09), + + PERIPH_PIN(3, 2, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B1_15), + + PERIPH_PIN(4, 2, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B1_05), + PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_EMC_35), +}; + +const mcu_periph_obj_t mcu_spi_miso_list[8] = { + PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B0_12), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 1, &pin_GPIO_SD_B0_04), + + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_EMC_02), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_12), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 2, &pin_GPIO_SD_B1_08), + + PERIPH_PIN(3, 2, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B1_14), + + PERIPH_PIN(4, 2, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B1_04), + PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_34), +}; + +LPUART_Type *mcu_uart_banks[] = { 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), + + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_23), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_09), + + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_07), + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_15), + + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_03), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_33), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 2, &pin_GPIO_AD_B1_11), + + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_39), + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_11), + + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_13), + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_01), + + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_35), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 1, &pin_GPIO_SD_B0_05), + + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_27), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_03), +}; + +const mcu_periph_obj_t mcu_uart_tx_list[16] = { + PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_06), + + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_22), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_08), + + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_06), + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_14), + + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_02), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_32), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 2, &pin_GPIO_AD_B1_10), + + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_38), + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_10), + + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_12), + PERIPH_PIN(6, 2, kIOMUXC_LPUART6_TX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_00), + + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_34), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 1, &pin_GPIO_SD_B0_04), + + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_26), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_02), +}; + +const mcu_pwm_obj_t mcu_pwm_list[39] = { + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_EMC_26), + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_AD_B1_06), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_EMC_24), + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_AD_B1_08), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_EMC_22), + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_AD_B1_10), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_EMC_20), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmA, 6, &pin_GPIO_AD_B1_12), + + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_EMC_27), + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_AD_B1_07), + + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_EMC_25), + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_AD_B1_09), + + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_EMC_23), + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_AD_B1_11), + + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 1, &pin_GPIO_EMC_21), + PWM_PIN(PWM1, kPWM_Module_3, kPWM_PwmB, 6, &pin_GPIO_AD_B1_13), + + PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmX, 7, &pin_GPIO_EMC_28), + PWM_PIN(PWM1, kPWM_Module_1, kPWM_PwmX, 7, &pin_GPIO_EMC_29), + PWM_PIN(PWM1, kPWM_Module_2, kPWM_PwmX, 7, &pin_GPIO_EMC_30), + + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_EMC_38), + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmA, 4, &pin_GPIO_AD_B0_14), + + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmA, 1, &pin_GPIO_EMC_36), + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmA, 4, &pin_GPIO_AD_B0_12), + + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmA, 1, &pin_GPIO_EMC_30), + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmA, 4, &pin_GPIO_AD_B0_10), + + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmA, 1, &pin_GPIO_EMC_28), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmA, 4, &pin_GPIO_AD_B0_06), + + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmB, 1, &pin_GPIO_EMC_39), + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmB, 4, &pin_GPIO_AD_B0_15), + + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmB, 1, &pin_GPIO_EMC_37), + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmB, 4, &pin_GPIO_AD_B0_13), + + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmB, 1, &pin_GPIO_EMC_31), + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmB, 4, &pin_GPIO_AD_B0_11), + + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmB, 1, &pin_GPIO_EMC_29), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmB, 4, &pin_GPIO_AD_B0_07), + + PWM_PIN(PWM2, kPWM_Module_0, kPWM_PwmX, 6, &pin_GPIO_EMC_10), + PWM_PIN(PWM2, kPWM_Module_1, kPWM_PwmX, 6, &pin_GPIO_EMC_11), + PWM_PIN(PWM2, kPWM_Module_2, kPWM_PwmX, 6, &pin_GPIO_EMC_12), + PWM_PIN(PWM2, kPWM_Module_3, kPWM_PwmX, 6, &pin_GPIO_EMC_13), +}; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h new file mode 100644 index 0000000000..1d720f6336 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Artur Pacholec + * Copyright (c) 2020 Scott Shawcroft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H + +extern const mcu_periph_obj_t mcu_i2c_sda_list[8]; +extern const mcu_periph_obj_t mcu_i2c_scl_list[8]; + +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 const mcu_periph_obj_t mcu_uart_rx_list[16]; +extern const mcu_periph_obj_t mcu_uart_tx_list[16]; + +extern const mcu_pwm_obj_t mcu_pwm_list[39]; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIP_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.c new file mode 100644 index 0000000000..4106c9bad4 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.c @@ -0,0 +1,128 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "py/obj.h" +#include "py/mphal.h" +#include "mimxrt10xx/pins.h" + +const mcu_pin_obj_t pin_GPIO_AD_B0_00 = PIN(GPIO1, 0, GPIO_AD_B0_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_01 = PIN(GPIO1, 1, GPIO_AD_B0_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_02 = PIN(GPIO1, 2, GPIO_AD_B0_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_03 = PIN(GPIO1, 3, GPIO_AD_B0_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_04 = PIN(GPIO1, 4, GPIO_AD_B0_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_05 = PIN(GPIO1, 5, GPIO_AD_B0_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_06 = PIN(GPIO1, 6, GPIO_AD_B0_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_07 = PIN(GPIO1, 7, GPIO_AD_B0_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_08 = PIN(GPIO1, 8, GPIO_AD_B0_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_09 = PIN(GPIO1, 9, GPIO_AD_B0_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_10 = PIN(GPIO1, 10, GPIO_AD_B0_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_11 = PIN(GPIO1, 11, GPIO_AD_B0_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_12 = PIN(GPIO1, 12, GPIO_AD_B0_12, ADC1, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_13 = PIN(GPIO1, 13, GPIO_AD_B0_13, ADC2, 0); +const mcu_pin_obj_t pin_GPIO_AD_B0_14 = PIN(GPIO1, 14, GPIO_AD_B0_14, ADC2, 1); +const mcu_pin_obj_t pin_GPIO_AD_B0_15 = PIN(GPIO1, 15, GPIO_AD_B0_15, ADC1, 2); + +const mcu_pin_obj_t pin_GPIO_AD_B1_00 = PIN(GPIO1, 16, GPIO_AD_B1_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_AD_B1_01 = PIN(GPIO1, 17, GPIO_AD_B1_01, ADC1, 3); +const mcu_pin_obj_t pin_GPIO_AD_B1_02 = PIN(GPIO1, 18, GPIO_AD_B1_02, ADC2, 3); +const mcu_pin_obj_t pin_GPIO_AD_B1_03 = PIN(GPIO1, 19, GPIO_AD_B1_03, ADC1, 4); +const mcu_pin_obj_t pin_GPIO_AD_B1_04 = PIN(GPIO1, 20, GPIO_AD_B1_04, ADC2, 4); +const mcu_pin_obj_t pin_GPIO_AD_B1_05 = PIN(GPIO1, 21, GPIO_AD_B1_05, ADC2, 5); +const mcu_pin_obj_t pin_GPIO_AD_B1_06 = PIN(GPIO1, 22, GPIO_AD_B1_06, ADC2, 6); +const mcu_pin_obj_t pin_GPIO_AD_B1_07 = PIN(GPIO1, 23, GPIO_AD_B1_07, ADC2, 7); +const mcu_pin_obj_t pin_GPIO_AD_B1_08 = PIN(GPIO1, 24, GPIO_AD_B1_08, ADC2, 8); +const mcu_pin_obj_t pin_GPIO_AD_B1_09 = PIN(GPIO1, 25, GPIO_AD_B1_09, ADC2, 9); +const mcu_pin_obj_t pin_GPIO_AD_B1_10 = PIN(GPIO1, 26, GPIO_AD_B1_10, ADC2, 10); +const mcu_pin_obj_t pin_GPIO_AD_B1_11 = PIN(GPIO1, 27, GPIO_AD_B1_11, ADC2, 11); +const mcu_pin_obj_t pin_GPIO_AD_B1_12 = PIN(GPIO1, 28, GPIO_AD_B1_12, ADC2, 12); +const mcu_pin_obj_t pin_GPIO_AD_B1_13 = PIN(GPIO1, 29, GPIO_AD_B1_13, ADC2, 13); +const mcu_pin_obj_t pin_GPIO_AD_B1_14 = PIN(GPIO1, 30, GPIO_AD_B1_14, ADC2, 14); +const mcu_pin_obj_t pin_GPIO_AD_B1_15 = PIN(GPIO1, 31, GPIO_AD_B1_15, ADC2, 15); + +const mcu_pin_obj_t pin_GPIO_EMC_00 = PIN(GPIO2, 0, GPIO_EMC_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_01 = PIN(GPIO2, 1, GPIO_EMC_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_02 = PIN(GPIO2, 2, GPIO_EMC_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_03 = PIN(GPIO2, 3, GPIO_EMC_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_04 = PIN(GPIO2, 4, GPIO_EMC_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_05 = PIN(GPIO2, 5, GPIO_EMC_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_06 = PIN(GPIO2, 6, GPIO_EMC_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_07 = PIN(GPIO2, 7, GPIO_EMC_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_08 = PIN(GPIO2, 8, GPIO_EMC_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_09 = PIN(GPIO2, 9, GPIO_EMC_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_10 = PIN(GPIO2, 10, GPIO_EMC_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_11 = PIN(GPIO2, 11, GPIO_EMC_11, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_12 = PIN(GPIO2, 12, GPIO_EMC_12, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_13 = PIN(GPIO2, 13, GPIO_EMC_13, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_14 = PIN(GPIO2, 14, GPIO_EMC_14, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_15 = PIN(GPIO2, 15, GPIO_EMC_15, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_16 = PIN(GPIO2, 16, GPIO_EMC_16, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_17 = PIN(GPIO2, 17, GPIO_EMC_17, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_18 = PIN(GPIO2, 18, GPIO_EMC_18, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_19 = PIN(GPIO2, 19, GPIO_EMC_19, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_20 = PIN(GPIO2, 20, GPIO_EMC_20, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_21 = PIN(GPIO2, 21, GPIO_EMC_21, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_22 = PIN(GPIO2, 22, GPIO_EMC_22, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_23 = PIN(GPIO2, 23, GPIO_EMC_23, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_24 = PIN(GPIO2, 24, GPIO_EMC_24, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_25 = PIN(GPIO2, 25, GPIO_EMC_25, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_26 = PIN(GPIO2, 26, GPIO_EMC_26, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_27 = PIN(GPIO2, 27, GPIO_EMC_27, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_28 = PIN(GPIO2, 28, GPIO_EMC_28, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_29 = PIN(GPIO2, 29, GPIO_EMC_29, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_30 = PIN(GPIO2, 30, GPIO_EMC_30, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_31 = PIN(GPIO2, 31, GPIO_EMC_31, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_32 = PIN(GPIO3, 0, GPIO_EMC_32, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_33 = PIN(GPIO3, 1, GPIO_EMC_33, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_34 = PIN(GPIO3, 2, GPIO_EMC_34, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_35 = PIN(GPIO3, 3, GPIO_EMC_35, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_36 = PIN(GPIO3, 4, GPIO_EMC_36, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_37 = PIN(GPIO3, 5, GPIO_EMC_37, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_38 = PIN(GPIO3, 6, GPIO_EMC_38, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_39 = PIN(GPIO3, 7, GPIO_EMC_39, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_40 = PIN(GPIO3, 8, GPIO_EMC_40, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_EMC_41 = PIN(GPIO3, 9, GPIO_EMC_41, NO_ADC, 0); + +const mcu_pin_obj_t pin_GPIO_SD_B0_00 = PIN(GPIO3, 13, GPIO_SD_B0_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_01 = PIN(GPIO3, 14, GPIO_SD_B0_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_02 = PIN(GPIO3, 15, GPIO_SD_B0_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_03 = PIN(GPIO3, 16, GPIO_SD_B0_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_04 = PIN(GPIO3, 17, GPIO_SD_B0_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_05 = PIN(GPIO3, 18, GPIO_SD_B0_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B0_06 = PIN(GPIO3, 19, GPIO_SD_B0_06, NO_ADC, 0); + +const mcu_pin_obj_t pin_GPIO_SD_B1_00 = PIN(GPIO3, 20, GPIO_SD_B1_00, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_01 = PIN(GPIO3, 21, GPIO_SD_B1_01, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_02 = PIN(GPIO3, 22, GPIO_SD_B1_02, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_03 = PIN(GPIO3, 23, GPIO_SD_B1_03, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_04 = PIN(GPIO3, 24, GPIO_SD_B1_04, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_05 = PIN(GPIO3, 25, GPIO_SD_B1_05, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_06 = PIN(GPIO3, 26, GPIO_SD_B1_06, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_07 = PIN(GPIO3, 27, GPIO_SD_B1_07, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_08 = PIN(GPIO3, 28, GPIO_SD_B1_08, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_09 = PIN(GPIO3, 29, GPIO_SD_B1_09, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_10 = PIN(GPIO3, 30, GPIO_SD_B1_10, NO_ADC, 0); +const mcu_pin_obj_t pin_GPIO_SD_B1_11 = PIN(GPIO3, 31, GPIO_SD_B1_11, NO_ADC, 0); diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.h new file mode 100644 index 0000000000..a13bacfc35 --- /dev/null +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.h @@ -0,0 +1,129 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Artur Pacholec + * Copyright (c) 2020 Scott Shawcroft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PINS_H +#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PINS_H + +extern const mcu_pin_obj_t pin_GPIO_AD_B0_00; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_01; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_02; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_03; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_04; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_05; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_06; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_07; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_08; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_09; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_10; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_11; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_12; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_13; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_14; +extern const mcu_pin_obj_t pin_GPIO_AD_B0_15; + +extern const mcu_pin_obj_t pin_GPIO_AD_B1_00; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_01; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_02; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_03; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_04; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_05; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_06; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_07; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_08; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_09; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_10; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_11; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_12; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_13; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_14; +extern const mcu_pin_obj_t pin_GPIO_AD_B1_15; + +extern const mcu_pin_obj_t pin_GPIO_EMC_00; +extern const mcu_pin_obj_t pin_GPIO_EMC_01; +extern const mcu_pin_obj_t pin_GPIO_EMC_02; +extern const mcu_pin_obj_t pin_GPIO_EMC_03; +extern const mcu_pin_obj_t pin_GPIO_EMC_04; +extern const mcu_pin_obj_t pin_GPIO_EMC_05; +extern const mcu_pin_obj_t pin_GPIO_EMC_06; +extern const mcu_pin_obj_t pin_GPIO_EMC_07; +extern const mcu_pin_obj_t pin_GPIO_EMC_08; +extern const mcu_pin_obj_t pin_GPIO_EMC_09; +extern const mcu_pin_obj_t pin_GPIO_EMC_10; +extern const mcu_pin_obj_t pin_GPIO_EMC_11; +extern const mcu_pin_obj_t pin_GPIO_EMC_12; +extern const mcu_pin_obj_t pin_GPIO_EMC_13; +extern const mcu_pin_obj_t pin_GPIO_EMC_14; +extern const mcu_pin_obj_t pin_GPIO_EMC_15; +extern const mcu_pin_obj_t pin_GPIO_EMC_16; +extern const mcu_pin_obj_t pin_GPIO_EMC_17; +extern const mcu_pin_obj_t pin_GPIO_EMC_18; +extern const mcu_pin_obj_t pin_GPIO_EMC_19; +extern const mcu_pin_obj_t pin_GPIO_EMC_20; +extern const mcu_pin_obj_t pin_GPIO_EMC_21; +extern const mcu_pin_obj_t pin_GPIO_EMC_22; +extern const mcu_pin_obj_t pin_GPIO_EMC_23; +extern const mcu_pin_obj_t pin_GPIO_EMC_24; +extern const mcu_pin_obj_t pin_GPIO_EMC_25; +extern const mcu_pin_obj_t pin_GPIO_EMC_26; +extern const mcu_pin_obj_t pin_GPIO_EMC_27; +extern const mcu_pin_obj_t pin_GPIO_EMC_28; +extern const mcu_pin_obj_t pin_GPIO_EMC_29; +extern const mcu_pin_obj_t pin_GPIO_EMC_30; +extern const mcu_pin_obj_t pin_GPIO_EMC_31; +extern const mcu_pin_obj_t pin_GPIO_EMC_32; +extern const mcu_pin_obj_t pin_GPIO_EMC_33; +extern const mcu_pin_obj_t pin_GPIO_EMC_34; +extern const mcu_pin_obj_t pin_GPIO_EMC_35; +extern const mcu_pin_obj_t pin_GPIO_EMC_36; +extern const mcu_pin_obj_t pin_GPIO_EMC_37; +extern const mcu_pin_obj_t pin_GPIO_EMC_38; +extern const mcu_pin_obj_t pin_GPIO_EMC_39; +extern const mcu_pin_obj_t pin_GPIO_EMC_40; +extern const mcu_pin_obj_t pin_GPIO_EMC_41; + +extern const mcu_pin_obj_t pin_GPIO_SD_B0_00; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_01; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_02; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_03; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_04; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_05; +extern const mcu_pin_obj_t pin_GPIO_SD_B0_06; + +extern const mcu_pin_obj_t pin_GPIO_SD_B1_00; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_01; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_02; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_03; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_04; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_05; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_06; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_07; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_08; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_09; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_10; +extern const mcu_pin_obj_t pin_GPIO_SD_B1_11; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PINS_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c index fc90e2374d..3f0473a886 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c @@ -71,7 +71,7 @@ const mcu_periph_obj_t mcu_spi_sck_list[8] = { PERIPH_PIN(2, 2, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 1, &pin_GPIO_EMC_00), PERIPH_PIN(3, 7, kIOMUXC_LPSPI3_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B0_00), - PERIPH_PIN(3, 2, kIOMUXC_LPSPI3_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B1_15), + PERIPH_PIN(3, 2, kIOMUXC_LPSPI3_SCK_SELECT_INPUT, 1, &pin_GPIO_AD_B1_15), PERIPH_PIN(4, 3, kIOMUXC_LPSPI4_SCK_SELECT_INPUT, 0, &pin_GPIO_B0_03), PERIPH_PIN(4, 1, kIOMUXC_LPSPI4_SCK_SELECT_INPUT, 1, &pin_GPIO_B1_07), diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h index 301eb0db47..9b9713bb4d 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/periph.h @@ -70,6 +70,8 @@ extern LPUART_Type *mcu_uart_banks[]; #ifdef MIMXRT1011_SERIES #include "MIMXRT1011/periph.h" +#elif defined(MIMXRT1021_SERIES) +#include "MIMXRT1021/periph.h" #elif defined(MIMXRT1062_SERIES) #include "MIMXRT1062/periph.h" #endif diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h index 64a8324bd0..404a411e18 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.h @@ -68,6 +68,8 @@ typedef struct { #ifdef MIMXRT1011_SERIES #include "MIMXRT1011/pins.h" +#elif defined(MIMXRT1021_SERIES) +#include "MIMXRT1021/pins.h" #elif defined(MIMXRT1062_SERIES) #include "MIMXRT1062/pins.h" #endif diff --git a/ports/mimxrt10xx/reset.c b/ports/mimxrt10xx/reset.c index dc4a1dce11..a3a4f667de 100644 --- a/ports/mimxrt10xx/reset.c +++ b/ports/mimxrt10xx/reset.c @@ -35,5 +35,5 @@ void reset(void) { } bool bootloader_available(void) { - return &_bootloader_dbl_tap >= 0; + return SNVS->LPGPR[0] >= 0; } diff --git a/ports/mimxrt10xx/reset.h b/ports/mimxrt10xx/reset.h index b6dfc38cc2..dc3106cf07 100644 --- a/ports/mimxrt10xx/reset.h +++ b/ports/mimxrt10xx/reset.h @@ -34,8 +34,6 @@ #define DBL_TAP_MAGIC 0xf01669ef // Randomly selected, adjusted to have first and last bit set #define DBL_TAP_MAGIC_QUICK_BOOT 0xf02669ef -extern volatile uint32_t _bootloader_dbl_tap; - void reset_to_bootloader(void); void reset(void); bool bootloader_available(void); diff --git a/ports/mimxrt10xx/sdk b/ports/mimxrt10xx/sdk index 2251c7b793..4e7438e654 160000 --- a/ports/mimxrt10xx/sdk +++ b/ports/mimxrt10xx/sdk @@ -1 +1 @@ -Subproject commit 2251c7b79343966a57a0f36d897873dd40b692b9 +Subproject commit 4e7438e654f4a6b4f386b4bb9e817d74a0fbffc7 diff --git a/ports/mimxrt10xx/supervisor/internal_flash.c b/ports/mimxrt10xx/supervisor/internal_flash.c index e15b4962ef..7e9d8fa377 100644 --- a/ports/mimxrt10xx/supervisor/internal_flash.c +++ b/ports/mimxrt10xx/supervisor/internal_flash.c @@ -166,11 +166,13 @@ void supervisor_flash_init(void) { } __enable_irq(); + SCB_EnableDCache(); + init_done = true; } static inline uint32_t lba2addr(uint32_t block) { - return ((uint32_t)__fatfs_flash_start_addr) + block * FILESYSTEM_BLOCK_SIZE; + return CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR + block * FILESYSTEM_BLOCK_SIZE; } uint32_t supervisor_flash_get_block_size(void) { @@ -178,7 +180,7 @@ uint32_t supervisor_flash_get_block_size(void) { } uint32_t supervisor_flash_get_block_count(void) { - return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE; + return CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE; } void supervisor_flash_flush(void) { @@ -191,20 +193,20 @@ void supervisor_flash_flush(void) { __disable_irq(); status = flexspi_nor_flash_erase_sector(FLEXSPI, sector_addr); + __enable_irq(); if (status != kStatus_Success) { printf("Page erase failure %ld!\r\n", status); return; } - __enable_irq(); for (int i = 0; i < SECTOR_SIZE / FLASH_PAGE_SIZE; ++i) { __disable_irq(); status = flexspi_nor_flash_page_program(FLEXSPI, sector_addr + i * FLASH_PAGE_SIZE, (void *)_flash_cache + i * FLASH_PAGE_SIZE); + __enable_irq(); if (status != kStatus_Success) { printf("Page program failure %ld!\r\n", status); return; } - __enable_irq(); } DCACHE_CleanInvalidateByRange(_flash_page_addr, SECTOR_SIZE); diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 3573074279..555b783597 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -3,8 +3,8 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * Copyright (c) 2017 Artur Pacholec + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2020 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 @@ -24,6 +24,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +/* + * Copyright 2018 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ #include "boards/board.h" #include "supervisor/port.h" @@ -54,16 +60,139 @@ #include "fsl_gpio.h" #include "fsl_lpuart.h" -void mpu_init(void) -{ - ARM_MPU_Disable(); +// Device memories must be accessed in order. +#define DEVICE 2 +// Normal memory can have accesses reorder and prefetched. +#define NORMAL 0 - SCB_EnableDCache(); - SCB_EnableICache(); +// Prevents instruction access. +#define NO_EXECUTION 1 +#define EXECUTION 0 + +// Shareable if the memory system manages coherency. +#define NOT_SHAREABLE 0 +#define SHAREABLE 1 + +// +#define NOT_CACHEABLE 0 +#define CACHEABLE 1 + +#define NOT_BUFFERABLE 0 +#define BUFFERABLE 1 + +#define NO_SUBREGIONS 0 + +extern uint32_t _ld_flash_size; + +extern uint8_t _ld_dtcm_bss_start; +extern uint8_t _ld_dtcm_bss_end; +extern uint8_t _ld_dtcm_data_destination; +extern uint8_t _ld_dtcm_data_size; +extern uint8_t _ld_dtcm_data_flash_copy; +extern uint8_t _ld_itcm_destination; +extern uint8_t _ld_itcm_size; +extern uint8_t _ld_itcm_flash_copy; + +// This is called before RAM is setup! Be very careful what you do here. +void SystemInitHook(void) { + // asm("bkpt"); + /* Disable I cache and D cache */ + if (SCB_CCR_IC_Msk == (SCB_CCR_IC_Msk & SCB->CCR)) + { + SCB_DisableICache(); + } + if (SCB_CCR_DC_Msk == (SCB_CCR_DC_Msk & SCB->CCR)) + { + SCB_DisableDCache(); + } + // Configure FlexRAM. The e is one block of ITCM (0b11) and DTCM (0b10). The rest is two OCRAM + // (0b01). We shift in zeroes for all unimplemented banks. + IOMUXC_GPR->GPR17 = (0xe5555555) >> (32 - 2 * FSL_FEATURE_FLEXRAM_INTERNAL_RAM_TOTAL_BANK_NUMBERS); + + // Switch from FlexRAM fuse config to the IOMUXC values. + IOMUXC_GPR->GPR16 |= IOMUXC_GPR_GPR16_FLEXRAM_BANK_CFG_SEL(1); + + // Let the core know the TCM sizes changed. + uint32_t current_gpr14 = IOMUXC_GPR->GPR14; + current_gpr14 &= ~IOMUXC_GPR_GPR14_CM7_CFGDTCMSZ_MASK; + current_gpr14 |= IOMUXC_GPR_GPR14_CM7_CFGDTCMSZ(0x6); + current_gpr14 &= ~IOMUXC_GPR_GPR14_CM7_CFGITCMSZ_MASK; + current_gpr14 |= IOMUXC_GPR_GPR14_CM7_CFGITCMSZ(0x6); + IOMUXC_GPR->GPR14 = current_gpr14; + + /* Disable MPU */ + ARM_MPU_Disable(); + + // Copy all of the code to run from ITCM. + memcpy(&_ld_itcm_destination, &_ld_itcm_flash_copy, (size_t) &_ld_itcm_size); + + // Copy all of the data to run from DTCM. + memcpy(&_ld_dtcm_data_destination, &_ld_dtcm_data_flash_copy, (size_t) &_ld_dtcm_data_size); + + // Clear DTCM bss. + memset(&_ld_dtcm_bss_start, 0, (size_t) (&_ld_dtcm_bss_end - &_ld_dtcm_bss_start)); + + // 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. + + // This is an undocumented region and is likely more registers. + MPU->RBAR = ARM_MPU_RBAR(8, 0xC0000000U); + MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, DEVICE, NOT_SHAREABLE, NOT_CACHEABLE, NOT_BUFFERABLE, NO_SUBREGIONS, ARM_MPU_REGION_SIZE_512MB); + + // This is the SEMC region where external RAM and 8+ flash would live. Disable for now, even though the EVKs have stuff here. + MPU->RBAR = ARM_MPU_RBAR(9, 0x80000000U); + MPU->RASR = ARM_MPU_RASR(NO_EXECUTION, ARM_MPU_AP_NONE, DEVICE, NOT_SHAREABLE, NOT_CACHEABLE, NOT_BUFFERABLE, NO_SUBREGIONS, ARM_MPU_REGION_SIZE_1GB); + + // 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); + + // 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; + uint32_t filesystem_size = &_ld_filesystem_end - &_ld_filesystem_start; + while (filesystem_size > (1u << (region_size + 1))) { + region_size += 1; + } + // Mask out as much of the remainder as we can. For example on an 8MB flash, 7MB are for the + // filesystem. The region_size here must be a power of 2 so it is 8MB. Using the subregion mask + // we can ignore 1/8th size chunks. So, we ignore the last 1MB using the subregion. + uint32_t remainder = (1u << (region_size + 1)) - filesystem_size; + uint32_t subregion_size = (1u << (region_size + 1)) / 8; + uint16_t subregion_mask = 0xff00 >> (remainder / subregion_size); + + MPU->RBAR = ARM_MPU_RBAR(11, 0x60100000U); + MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, (uint8_t) subregion_mask, region_size); + + // This the ITCM. Set it to read-only because we've loaded everything already and it's easy to + // accidentally write the wrong value to 0x00000000 (aka NULL). + MPU->RBAR = ARM_MPU_RBAR(12, 0x00000000U); + MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_RO, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, NO_SUBREGIONS, ARM_MPU_REGION_SIZE_32KB); + + // This the DTCM. + MPU->RBAR = ARM_MPU_RBAR(13, 0x20000000U); + MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, NO_SUBREGIONS, ARM_MPU_REGION_SIZE_32KB); + + // This is OCRAM. + MPU->RBAR = ARM_MPU_RBAR(14, 0x20200000U); + MPU->RASR = ARM_MPU_RASR(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. + 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); + + /* Enable MPU */ + ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); + + /* Enable I cache and D cache */ + SCB_EnableDCache(); + SCB_EnableICache(); } safe_mode_t port_init(void) { - mpu_init(); clocks_init(); // Configure millisecond timer initialization. @@ -129,7 +258,7 @@ void reset_port(void) { } void reset_to_bootloader(void) { - _bootloader_dbl_tap = DBL_TAP_MAGIC; + SNVS->LPGPR[0] = DBL_TAP_MAGIC; reset(); } @@ -137,23 +266,64 @@ void reset_cpu(void) { reset(); } -extern uint32_t _heap_start, _estack; +extern uint32_t _ld_heap_start, _ld_heap_end, _ld_stack_top, _ld_stack_bottom; uint32_t *port_stack_get_limit(void) { - return &_heap_start; + return &_ld_heap_start; } uint32_t *port_stack_get_top(void) { - return &_estack; + return &_ld_stack_top; +} + +uint32_t *port_heap_get_bottom(void) { + return &_ld_heap_start; +} + +// Get heap top address +uint32_t *port_heap_get_top(void) { + return &_ld_heap_end; } -extern uint32_t __bss_end__; // Place the word to save just after our BSS section that gets blanked. void port_set_saved_word(uint32_t value) { - __bss_end__ = value; + SNVS->LPGPR[1] = value; } uint32_t port_get_saved_word(void) { - return __bss_end__; + return SNVS->LPGPR[1]; +} + +/** + * \brief Default interrupt handler for unused IRQs. + */ +__attribute__((used)) void MemManage_Handler(void) +{ + reset_into_safe_mode(MEM_MANAGE); + while (true) { + asm("nop;"); + } +} + +/** + * \brief Default interrupt handler for unused IRQs. + */ +__attribute__((used)) void BusFault_Handler(void) +{ + reset_into_safe_mode(MEM_MANAGE); + while (true) { + asm("nop;"); + } +} + +/** + * \brief Default interrupt handler for unused IRQs. + */ +__attribute__((used)) void UsageFault_Handler(void) +{ + reset_into_safe_mode(MEM_MANAGE); + while (true) { + asm("nop;"); + } } /** @@ -166,3 +336,4 @@ __attribute__((used)) void HardFault_Handler(void) asm("nop;"); } } + diff --git a/py/map.c b/py/map.c index 6abf4853f1..57c11dbc97 100644 --- a/py/map.c +++ b/py/map.c @@ -33,6 +33,8 @@ #include "py/misc.h" #include "py/runtime.h" +#include "supervisor/linker.h" + #if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_PRINT (1) #else // don't print debugging info @@ -143,7 +145,7 @@ STATIC void mp_map_rehash(mp_map_t *map) { // - returns slot, with key non-null and value=MP_OBJ_NULL if it was added // MP_MAP_LOOKUP_REMOVE_IF_FOUND behaviour: // - returns NULL if not found, else the slot if was found in with key null and value non-null -mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { +mp_map_elem_t *PLACE_IN_ITCM(mp_map_lookup)(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { // If the map is a fixed array then we must only be called for a lookup assert(!map->is_fixed || lookup_kind == MP_MAP_LOOKUP); diff --git a/py/mpstate.c b/py/mpstate.c index 6ce64adfd1..32f1d60a59 100644 --- a/py/mpstate.c +++ b/py/mpstate.c @@ -25,9 +25,10 @@ */ #include "py/mpstate.h" +#include "supervisor/linker.h" #if MICROPY_DYNAMIC_COMPILER mp_dynamic_compiler_t mp_dynamic_compiler = {0}; #endif -mp_state_ctx_t mp_state_ctx; +mp_state_ctx_t PLACE_IN_DTCM_BSS(mp_state_ctx); diff --git a/py/obj.c b/py/obj.c index 09e71be4d6..f1e00de1a4 100644 --- a/py/obj.c +++ b/py/obj.c @@ -38,6 +38,7 @@ #include "py/stackctrl.h" #include "py/stream.h" // for mp_obj_print +#include "supervisor/linker.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" @@ -128,7 +129,7 @@ void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { mp_print_str(print, "\n"); } -bool mp_obj_is_true(mp_obj_t arg) { +bool PLACE_IN_ITCM(mp_obj_is_true)(mp_obj_t arg) { if (arg == mp_const_false) { return 0; } else if (arg == mp_const_true) { diff --git a/py/objdict.c b/py/objdict.c index 683fcb748e..3ec3cbe80a 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -31,6 +31,7 @@ #include "py/builtin.h" #include "py/objtype.h" +#include "supervisor/linker.h" #include "supervisor/shared/translate.h" #define MP_OBJ_IS_DICT_TYPE(o) (MP_OBJ_IS_OBJ(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new) @@ -324,7 +325,7 @@ STATIC mp_obj_t dict_popitem(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem); -STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { +STATIC mp_obj_t PLACE_IN_ITCM(dict_update)(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { mp_check_self(MP_OBJ_IS_DICT_TYPE(args[0])); mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]); mp_ensure_not_fixed(self); @@ -590,7 +591,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_TYPE(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 7e58994563..c586a290ac 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -34,6 +34,8 @@ #include "py/bc.h" #include "py/stackctrl.h" +#include "supervisor/linker.h" + #if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_PRINT (1) #else // don't print debugging info @@ -249,7 +251,7 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args } #endif -STATIC mp_obj_t fun_bc_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_bc_call)(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { MP_STACK_CHECK(); DEBUG_printf("Input n_args: " UINT_FMT ", n_kw: " UINT_FMT "\n", n_args, n_kw); diff --git a/py/qstr.c b/py/qstr.c index eea57c1e0e..bb80244355 100755 --- a/py/qstr.c +++ b/py/qstr.c @@ -33,6 +33,8 @@ #include "py/qstr.h" #include "py/gc.h" +#include "supervisor/linker.h" + // NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings) // ultimately we will replace this with a static hash table of some kind // also probably need to include the length in the string data, to allow null bytes in the string @@ -248,7 +250,7 @@ qstr qstr_from_strn(const char *str, size_t len) { return q; } -mp_uint_t qstr_hash(qstr q) { +mp_uint_t PLACE_IN_ITCM(qstr_hash)(qstr q) { return Q_GET_HASH(find_qstr(q)); } diff --git a/py/runtime.c b/py/runtime.c index a786619bf0..48416bab26 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -200,7 +200,7 @@ mp_obj_t mp_load_build_class(void) { return MP_OBJ_FROM_PTR(&mp_builtin___build_class___obj); } -void mp_store_name(qstr qst, mp_obj_t obj) { +void PLACE_IN_ITCM(mp_store_name)(qstr qst, mp_obj_t obj) { DEBUG_OP_printf("store name %s <- %p\n", qstr_str(qst), obj); mp_obj_dict_store(MP_OBJ_FROM_PTR(mp_locals_get()), MP_OBJ_NEW_QSTR(qst), obj); } @@ -211,7 +211,7 @@ void mp_delete_name(qstr qst) { mp_obj_dict_delete(MP_OBJ_FROM_PTR(mp_locals_get()), MP_OBJ_NEW_QSTR(qst)); } -void mp_store_global(qstr qst, mp_obj_t obj) { +void PLACE_IN_ITCM(mp_store_global)(qstr qst, mp_obj_t obj) { DEBUG_OP_printf("store global %s <- %p\n", qstr_str(qst), obj); mp_obj_dict_store(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(qst), obj); } @@ -283,7 +283,7 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) { } } -mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { +mp_obj_t PLACE_IN_ITCM(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { DEBUG_OP_printf("binary " UINT_FMT " %q %p %p\n", op, mp_binary_op_method_name[op], lhs, rhs); // TODO correctly distinguish inplace operators for mutable objects @@ -641,7 +641,7 @@ mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args) { #if !MICROPY_STACKLESS STATIC #endif -void mp_call_prepare_args_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args) { +void PLACE_IN_ITCM(mp_call_prepare_args_n_kw_var)(bool have_self, size_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args) { mp_obj_t fun = *args++; mp_obj_t self = MP_OBJ_NULL; if (have_self) { diff --git a/py/runtime.h b/py/runtime.h index e8398cf0ea..4121352dfd 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -29,6 +29,8 @@ #include "py/mpstate.h" #include "py/pystack.h" +#include "supervisor/linker.h" + typedef enum { MP_VM_RETURN_NORMAL, MP_VM_RETURN_YIELD, @@ -84,10 +86,10 @@ void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args, NORETURN void mp_arg_error_terse_mismatch(void); NORETURN void mp_arg_error_unimpl_kw(void); -static inline mp_obj_dict_t *mp_locals_get(void) { return MP_STATE_THREAD(dict_locals); } -static inline void mp_locals_set(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_locals) = d; } -static inline mp_obj_dict_t *mp_globals_get(void) { return MP_STATE_THREAD(dict_globals); } -static inline void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_globals) = d; } +static inline mp_obj_dict_t *PLACE_IN_ITCM(mp_locals_get)(void) { return MP_STATE_THREAD(dict_locals); } +static inline void PLACE_IN_ITCM(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) { return MP_STATE_THREAD(dict_globals); } +static inline void PLACE_IN_ITCM(mp_globals_set)(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_globals) = d; } mp_obj_t mp_load_name(qstr qst); mp_obj_t mp_load_global(qstr qst); diff --git a/py/vm.c b/py/vm.c index 353fc88100..4f0340681e 100644 --- a/py/vm.c +++ b/py/vm.c @@ -35,6 +35,8 @@ #include "py/bc0.h" #include "py/bc.h" +#include "supervisor/linker.h" + #if 0 #define TRACE(ip) printf("sp=%d ", (int)(sp - &code_state->state[0] + 1)); mp_bytecode_print2(ip, 1, code_state->fun_bc->const_table); #else @@ -116,7 +118,7 @@ // MP_VM_RETURN_NORMAL, sp valid, return value in *sp // MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp // MP_VM_RETURN_EXCEPTION, exception in fastn[0] -mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { +mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { #define SELECTIVE_EXC_IP (0) #if SELECTIVE_EXC_IP #define MARK_EXC_IP_SELECTIVE() { code_state->ip = ip; } /* stores ip 1 byte past last opcode */ diff --git a/py/vmentrytable.h b/py/vmentrytable.h index a0e2d40658..31a96dbec4 100644 --- a/py/vmentrytable.h +++ b/py/vmentrytable.h @@ -29,7 +29,9 @@ #pragma clang diagnostic ignored "-Winitializer-overrides" #endif // __clang__ -static const void *const entry_table[256] = { +#include "supervisor/linker.h" + +static const void *const PLACE_IN_DTCM_DATA(entry_table[256]) = { [0 ... 255] = &&entry_default, [MP_BC_LOAD_CONST_FALSE] = &&entry_MP_BC_LOAD_CONST_FALSE, [MP_BC_LOAD_CONST_NONE] = &&entry_MP_BC_LOAD_CONST_NONE, diff --git a/supervisor/linker.h b/supervisor/linker.h new file mode 100755 index 0000000000..b584144338 --- /dev/null +++ b/supervisor/linker.h @@ -0,0 +1,42 @@ +/* + * 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. + */ + +// These macros are used to place code and data into different linking sections. + +#ifndef MICROPY_INCLUDED_SUPERVISOR_LINKER_H +#define MICROPY_INCLUDED_SUPERVISOR_LINKER_H + +#if defined(IMXRT10XX) +#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 +#else +#define PLACE_IN_DTCM_DATA(name) name +#define PLACE_IN_DTCM_BSS(name) name +#define PLACE_IN_ITCM(name) name +#endif + +#endif // MICROPY_INCLUDED_SUPERVISOR_LINKER_H diff --git a/supervisor/port.h b/supervisor/port.h index c8a0119788..b289583dd6 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -60,6 +60,12 @@ uint32_t *port_stack_get_limit(void); // Get stack top address uint32_t *port_stack_get_top(void); +// Get heap bottom address +uint32_t *port_heap_get_bottom(void); + +// Get heap top address +uint32_t *port_heap_get_top(void); + // Save and retrieve a word from memory that is preserved over reset. Used for safe mode. void port_set_saved_word(uint32_t); uint32_t port_get_saved_word(void); diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index 92727f6fb8..3b799619f4 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -75,7 +75,7 @@ static void make_sample_code_file(FATFS *fatfs) { FIL fs; UINT char_written = 0; const byte buffer[] = "print('Hello World!')\n"; - //Create or modify existing code.py file + //Create or modify existing code.py file f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS); f_write(&fs, buffer, sizeof(buffer) - 1, &char_written); f_close(&fs); diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index 38040d11d9..14c3b4979b 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -39,11 +39,14 @@ uint32_t* low_address; uint32_t* high_address; void memory_init(void) { - low_address = port_stack_get_limit(); - high_address = port_stack_get_top(); + low_address = port_heap_get_bottom(); + high_address = port_heap_get_top(); } void free_memory(supervisor_allocation* allocation) { + if (allocation == NULL) { + return; + } int32_t index = 0; bool found = false; for (index = 0; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index++) { diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index aba31e9c9e..c957aee534 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -157,6 +157,9 @@ void print_safe_mode_message(safe_mode_t reason) { case FLASH_WRITE_FAIL: serial_write_compressed(translate("Failed to write internal flash.")); break; + case MEM_MANAGE: + serial_write_compressed(translate("Invalid memory access.")); + break; default: serial_write_compressed(translate("Unknown reason.")); break; diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h index e05fca0e46..5b09c4b543 100644 --- a/supervisor/shared/safe_mode.h +++ b/supervisor/shared/safe_mode.h @@ -40,6 +40,7 @@ typedef enum { PROGRAMMATIC_SAFE_MODE, NORDIC_SOFT_DEVICE_ASSERT, FLASH_WRITE_FAIL, + MEM_MANAGE, } safe_mode_t; safe_mode_t wait_for_safe_mode_reset(void); diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index dcecf2067b..2b7b1c03a4 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -46,6 +46,10 @@ void allocate_stack(void) { mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp; + if (port_stack_get_top() != port_heap_get_top()) { + return; + } + stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true); if (stack_alloc == NULL) { stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true); @@ -71,6 +75,9 @@ void stack_init(void) { } void stack_resize(void) { + if (stack_alloc == NULL) { + return; + } if (next_stack_size == current_stack_size) { *stack_alloc->ptr = STACK_CANARY_VALUE; return; diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 69256081c4..5668f8fa10 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -25,11 +25,13 @@ */ #include "supervisor/shared/tick.h" + +#include "supervisor/linker.h" #include "supervisor/filesystem.h" #include "supervisor/shared/autoreload.h" -static volatile uint64_t ticks_ms; -static volatile uint32_t background_ticks_ms32; +static volatile uint64_t PLACE_IN_DTCM_BSS(ticks_ms); +static volatile uint32_t PLACE_IN_DTCM_BSS(background_ticks_ms32); #if CIRCUITPY_GAMEPAD #include "shared-module/gamepad/__init__.h" @@ -77,7 +79,7 @@ uint32_t supervisor_ticks_ms32() { extern void run_background_tasks(void); -void supervisor_run_background_tasks_if_tick() { +void PLACE_IN_ITCM(supervisor_run_background_tasks_if_tick)() { uint32_t now32 = ticks_ms; if (now32 == background_ticks_ms32) { diff --git a/tools/build_board_info.py b/tools/build_board_info.py index d583fc63f2..1f074dddfc 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -18,6 +18,7 @@ BIN = ('bin',) UF2 = ('uf2',) BIN_UF2 = ('bin', 'uf2') HEX = ('hex',) +HEX_UF2 = ('hex', 'uf2') SPK = ('spk',) # Default extensions @@ -26,7 +27,7 @@ extension_by_port = { "atmel-samd": UF2, "stm32f4": BIN, "cxd56": SPK, - "mimxrt10xx": UF2, + "mimxrt10xx": HEX_UF2, } # Per board overrides From 9f4ea2122a346040d3a82b90e8eaaf63f44b23ce Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 17 Jan 2020 18:35:09 -0800 Subject: [PATCH 352/531] teensy fixes --- ports/mimxrt10xx/boards/teensy40/flash_config.c | 2 +- ports/mimxrt10xx/supervisor/port.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/mimxrt10xx/boards/teensy40/flash_config.c b/ports/mimxrt10xx/boards/teensy40/flash_config.c index a0661280b8..c281d4541e 100644 --- a/ports/mimxrt10xx/boards/teensy40/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy40/flash_config.c @@ -68,7 +68,7 @@ const flexspi_nor_config_t qspiflash_config = { .deviceType = kFlexSpiDeviceType_SerialNOR, .sflashPadType = kSerialFlash_4Pads, .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 - .sflashA1Size = 0x00200000, + .sflashA1Size = FLASH_SIZE, .lookupTable = { // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 555b783597..e141bc6b8e 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -162,10 +162,10 @@ void SystemInitHook(void) { // we can ignore 1/8th size chunks. So, we ignore the last 1MB using the subregion. uint32_t remainder = (1u << (region_size + 1)) - filesystem_size; uint32_t subregion_size = (1u << (region_size + 1)) / 8; - uint16_t subregion_mask = 0xff00 >> (remainder / subregion_size); + uint8_t subregion_mask = (0xff00 >> (remainder / subregion_size)) & 0xff; MPU->RBAR = ARM_MPU_RBAR(11, 0x60100000U); - MPU->RASR = ARM_MPU_RASR(EXECUTION, ARM_MPU_AP_FULL, NORMAL, NOT_SHAREABLE, CACHEABLE, BUFFERABLE, (uint8_t) subregion_mask, region_size); + 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 // accidentally write the wrong value to 0x00000000 (aka NULL). From 9d5742ebd19441c3cfb15be1b65a2b0a27b4e475 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Sat, 18 Jan 2020 11:54:01 -0800 Subject: [PATCH 353/531] Fix start on power up by providing Reset_Handler ourselves. On power up the FlexRAM banks are in an unknown config so we can't rely on the stack until after we configure FlexRAM. --- ports/mimxrt10xx/Makefile | 22 +--- .../boards/imxrt1010_evk/flash_config.c | 18 +-- .../boards/imxrt1060_evk/flash_config.c | 19 +--- .../mimxrt10xx/boards/teensy40/flash_config.c | 19 +--- ports/mimxrt10xx/linking/common.ld | 24 ++-- .../mimxrt10xx/MIMXRT1011/clocks.c | 31 ----- .../mimxrt10xx/MIMXRT1021/clocks.c | 30 ----- .../mimxrt10xx/MIMXRT1062/clocks.c | 28 ----- .../supervisor/flexspi_nor_flash_ops.c | 9 -- ports/mimxrt10xx/supervisor/port.c | 107 +++++++++++++----- 10 files changed, 98 insertions(+), 209 deletions(-) diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index d46806dc6b..66a540a402 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -84,24 +84,10 @@ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_ ifeq ($(DEBUG), 1) CFLAGS += -ggdb # You may want to disable -flto if it interferes with debugging. - #CFLAGS += -flto -flto-partition=none + # CFLAGS += -flto -flto-partition=none # You may want to enable these flags to make setting breakpoints easier. CFLAGS += -fno-inline -fno-ipa-sra else - # -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_SMALL_BUILD),1) - CFLAGS_INLINE_LIMIT = 50 - endif - endif - - ifdef CFLAGS_INLINE_LIMIT - CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT) - endif #CFLAGS += -flto -flto-partition=none endif @@ -116,12 +102,8 @@ CFLAGS += \ -DCPU_$(CHIP_VARIANT) \ -DDEBUG \ -DIMXRT10XX \ - -DXIP_EXTERNAL_FLASH=1 \ - -DXIP_BOOT_HEADER_ENABLE=1 \ - -D__START=main \ -Os -g3 -Wno-unused-parameter \ - -ffunction-sections -fdata-sections -fstack-usage \ - -D__STARTUP_CLEAR_BSS + -ffunction-sections -fdata-sections -fstack-usage LD_FILES = $(wildcard boards/$(BOARD)/*.ld) $(addprefix linking/, flash/$(FLASH).ld chip_family/$(CHIP_FAMILY).ld common.ld) diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c index c281d4541e..805e62f010 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c @@ -13,12 +13,7 @@ #define FSL_COMPONENT_ID "platform.drivers.xip_device" #endif -#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1) -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) - __attribute__((section(".boot_hdr.ivt"))) -#elif defined(__ICCARM__) -#pragma location=".boot_hdr.ivt" -#endif +__attribute__((section(".boot_hdr.ivt"))) /************************************* * IVT Data *************************************/ @@ -33,11 +28,7 @@ const ivt image_vector_table = { IVT_RSVD /* Reserved = 0 */ }; -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) - __attribute__((section(".boot_hdr.boot_data"))) -#elif defined(__ICCARM__) -#pragma location=".boot_hdr.boot_data" -#endif +__attribute__((section(".boot_hdr.boot_data"))) /************************************* * Boot Data *************************************/ @@ -49,12 +40,7 @@ const BOOT_DATA_T boot_data = { }; #endif -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) __attribute__((section(".boot_hdr.conf"))) -#elif defined(__ICCARM__) -#pragma location = ".boot_hdr.conf" -#endif - // Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 const flexspi_nor_config_t qspiflash_config = { .memConfig = diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c index c281d4541e..c51c59a519 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c @@ -13,12 +13,8 @@ #define FSL_COMPONENT_ID "platform.drivers.xip_device" #endif -#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1) -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) - __attribute__((section(".boot_hdr.ivt"))) -#elif defined(__ICCARM__) -#pragma location=".boot_hdr.ivt" -#endif +__attribute__((section(".boot_hdr.ivt"))) + /************************************* * IVT Data *************************************/ @@ -33,11 +29,7 @@ const ivt image_vector_table = { IVT_RSVD /* Reserved = 0 */ }; -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) - __attribute__((section(".boot_hdr.boot_data"))) -#elif defined(__ICCARM__) -#pragma location=".boot_hdr.boot_data" -#endif +__attribute__((section(".boot_hdr.boot_data"))) /************************************* * Boot Data *************************************/ @@ -49,12 +41,7 @@ const BOOT_DATA_T boot_data = { }; #endif -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) __attribute__((section(".boot_hdr.conf"))) -#elif defined(__ICCARM__) -#pragma location = ".boot_hdr.conf" -#endif - // Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 const flexspi_nor_config_t qspiflash_config = { .memConfig = diff --git a/ports/mimxrt10xx/boards/teensy40/flash_config.c b/ports/mimxrt10xx/boards/teensy40/flash_config.c index c281d4541e..426deb884d 100644 --- a/ports/mimxrt10xx/boards/teensy40/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy40/flash_config.c @@ -13,12 +13,7 @@ #define FSL_COMPONENT_ID "platform.drivers.xip_device" #endif -#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1) -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) - __attribute__((section(".boot_hdr.ivt"))) -#elif defined(__ICCARM__) -#pragma location=".boot_hdr.ivt" -#endif +__attribute__((section(".boot_hdr.ivt"))) /************************************* * IVT Data *************************************/ @@ -33,11 +28,7 @@ const ivt image_vector_table = { IVT_RSVD /* Reserved = 0 */ }; -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) - __attribute__((section(".boot_hdr.boot_data"))) -#elif defined(__ICCARM__) -#pragma location=".boot_hdr.boot_data" -#endif +__attribute__((section(".boot_hdr.boot_data"))) /************************************* * Boot Data *************************************/ @@ -47,14 +38,8 @@ const BOOT_DATA_T boot_data = { PLUGIN_FLAG, /* Plugin flag*/ 0xFFFFFFFF /* empty - extra data word */ }; -#endif -#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) __attribute__((section(".boot_hdr.conf"))) -#elif defined(__ICCARM__) -#pragma location = ".boot_hdr.conf" -#endif - // Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 const flexspi_nor_config_t qspiflash_config = { .memConfig = diff --git a/ports/mimxrt10xx/linking/common.ld b/ports/mimxrt10xx/linking/common.ld index 5cead9ed04..10568bfb86 100644 --- a/ports/mimxrt10xx/linking/common.ld +++ b/ports/mimxrt10xx/linking/common.ld @@ -30,7 +30,9 @@ MEMORY ITCM (x) : ORIGIN = 0x00000000, LENGTH = 32K } -__RAM_VECTOR_TABLE_SIZE_BYTES = 0; +__data_start__ = 0; +__data_end__ = 0; +_start = 0; SECTIONS { @@ -81,31 +83,28 @@ SECTIONS .data : { . = ALIGN(4); - _sidata = .; - __data_start__ = .; /* create a global symbol at data start */ - *(.data*) /* .data* sections */ *flexspi_nor_flash_ops.o(.text*) *fsl_flexspi.o(.text*) . = ALIGN(4); - - __data_end__ = .; /* define a global symbol at data end */ } > OCRAM AT> FLASH_TEXT + _ld_ocram_data_destination = ADDR(.data); + _ld_ocram_data_flash_copy = LOADADDR(.data); + _ld_ocram_data_size = SIZEOF(.data); /* Uninitialized data section */ .bss : { . = ALIGN(4); - __bss_start__ = .; *(.bss*) *(COMMON) . = ALIGN(4); - __bss_end__ = .; - _ld_heap_start = .; - PROVIDE(end = .); } > OCRAM + _ld_ocram_bss_start = ADDR(.bss); + _ld_ocram_bss_size = SIZEOF(.bss); + _ld_heap_start = _ld_ocram_bss_start + _ld_ocram_bss_size; _ld_heap_end = ORIGIN(OCRAM) + LENGTH(OCRAM); .itcm : @@ -141,7 +140,7 @@ SECTIONS . = ALIGN(4); } > DTCM AT> DTCM _ld_dtcm_bss_start = ADDR(.dtcm_bss); - _ld_dtcm_bss_end = ADDR(.dtcm_bss) + SIZEOF(.dtcm_bss); + _ld_dtcm_bss_size = SIZEOF(.dtcm_bss); .stack : { @@ -150,9 +149,6 @@ SECTIONS . += _ld_default_stack_size; } > DTCM _ld_stack_top = ORIGIN(DTCM) + LENGTH(DTCM); - _estack = _ld_stack_top; .ARM.attributes 0 : { *(.ARM.attributes) } } - -ASSERT(__data_end__ <= ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT), "region FLASH_TEXT overflowed with text and data") diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c index c039917856..854ae4dee9 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/clocks.c @@ -129,19 +129,6 @@ void clocks_init(void) { CLOCK_DisableClock(kCLOCK_Pit); /* Set PERCLK_PODF. */ CLOCK_SetDiv(kCLOCK_PerclkDiv, 1); - /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. - * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left - * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as - * well.*/ -#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) - /* Disable Flexspi clock gate. */ - CLOCK_DisableClock(kCLOCK_FlexSpi); - /* Set FLEXSPI_PODF. */ - CLOCK_SetDiv(kCLOCK_FlexspiDiv, 3); - /* Set Flexspi clock source. */ - CLOCK_SetMux(kCLOCK_FlexspiMux, 0); - CLOCK_SetMux(kCLOCK_FlexspiSrcMux, 0); -#endif /* Disable ADC_ACLK_EN clock gate. */ CCM->CSCMR2 &= ~CCM_CSCMR2_ADC_ACLK_EN_MASK; /* Set ADC_ACLK_PODF. */ @@ -219,24 +206,6 @@ void clocks_init(void) { CLOCK_InitSysPfd(kCLOCK_Pfd2, 18); /* Init System pfd3. */ CLOCK_InitSysPfd(kCLOCK_Pfd3, 18); - /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. - * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left - * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as - * well.*/ -#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) - /* Init Usb1 PLL. */ - CLOCK_InitUsb1Pll(&usb1PllConfig_BOARD_BootClockRUN); - /* Init Usb1 pfd0. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 22); - /* Init Usb1 pfd1. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd1, 16); - /* Init Usb1 pfd2. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd2, 17); - /* Init Usb1 pfd3. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd3, 18); - /* Disable Usb1 PLL output for USBPHY1. */ - CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; -#endif /* DeInit Audio PLL. */ CLOCK_DeinitAudioPll(); /* Bypass Audio PLL. */ diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c index 7dc08f6dde..cb9dd34c90 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/clocks.c @@ -176,18 +176,6 @@ void clocks_init(void) { CLOCK_SetMux(kCLOCK_SemcAltMux, 0); /* Set Semc clock source. */ CLOCK_SetMux(kCLOCK_SemcMux, 0); -#endif - /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. - * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left - * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as - * well.*/ -#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) - /* Disable Flexspi clock gate. */ - CLOCK_DisableClock(kCLOCK_FlexSpi); - /* Set FLEXSPI_PODF. */ - CLOCK_SetDiv(kCLOCK_FlexspiDiv, 3); - /* Set Flexspi clock source. */ - CLOCK_SetMux(kCLOCK_FlexspiMux, 2); #endif /* Disable LPSPI clock gate. */ CLOCK_DisableClock(kCLOCK_Lpspi1); @@ -294,24 +282,6 @@ void clocks_init(void) { CLOCK_InitSysPfd(kCLOCK_Pfd2, 18); /* Init System pfd3. */ CLOCK_InitSysPfd(kCLOCK_Pfd3, 18); -#endif - /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. - * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left - * unchanged. Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as - * well.*/ -#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) - /* Init Usb1 PLL. */ - CLOCK_InitUsb1Pll(&usb1PllConfig_BOARD_BootClockRUN); - /* Init Usb1 pfd0. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 22); - /* Init Usb1 pfd1. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd1, 16); - /* Init Usb1 pfd2. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd2, 17); - /* Init Usb1 pfd3. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd3, 18); - /* Disable Usb1 PLL output for USBPHY1. */ - CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; #endif /* DeInit Audio PLL. */ CLOCK_DeinitAudioPll(); diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c index cafc8efc3b..7b9af3a6a5 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/clocks.c @@ -129,17 +129,6 @@ void clocks_init(void) { CLOCK_SetMux(kCLOCK_SemcAltMux, 0); /* Set Semc clock source. */ CLOCK_SetMux(kCLOCK_SemcMux, 0); -#endif - /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. - * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left unchanged. - * Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as well.*/ -#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) - /* Disable Flexspi clock gate. */ - CLOCK_DisableClock(kCLOCK_FlexSpi); - /* Set FLEXSPI_PODF. */ - CLOCK_SetDiv(kCLOCK_FlexspiDiv, 1); - /* Set Flexspi clock source. */ - CLOCK_SetMux(kCLOCK_FlexspiMux, 3); #endif /* Disable LPSPI clock gate. */ CLOCK_DisableClock(kCLOCK_Lpspi1); @@ -254,23 +243,6 @@ void clocks_init(void) { CLOCK_InitSysPfd(kCLOCK_Pfd2, 24); /* Init System pfd3. */ CLOCK_InitSysPfd(kCLOCK_Pfd3, 16); -#endif - /* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd. - * With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left unchanged. - * Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as well.*/ -#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) - /* Init Usb1 PLL. */ - CLOCK_InitUsb1Pll(&usb1PllConfig_BOARD_BootClockRUN); - /* Init Usb1 pfd0. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 33); - /* Init Usb1 pfd1. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd1, 16); - /* Init Usb1 pfd2. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd2, 17); - /* Init Usb1 pfd3. */ - CLOCK_InitUsb1Pfd(kCLOCK_Pfd3, 19); - /* Disable Usb1 PLL output for USBPHY1. */ - CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; #endif /* DeInit Audio PLL. */ CLOCK_DeinitAudioPll(); diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c index e20c67fa34..71252d6776 100644 --- a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -16,19 +16,10 @@ static inline void flexspi_clock_init(void) { -#if defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1) /* Switch to PLL2 for XIP to avoid hardfault during re-initialize clock. */ CLOCK_InitSysPfd(kCLOCK_Pfd2, 24); /* Set PLL2 PFD2 clock 396MHZ. */ CLOCK_SetMux(kCLOCK_FlexspiMux, 0x2); /* Choose PLL2 PFD2 clock as flexspi source clock. */ CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2); /* flexspi clock 133M. */ -#else - const clock_usb_pll_config_t g_ccmConfigUsbPll = {.loopDivider = 0U}; - - CLOCK_InitUsb1Pll(&g_ccmConfigUsbPll); - CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 24); /* Set PLL3 PFD0 clock 360MHZ. */ - CLOCK_SetMux(kCLOCK_FlexspiMux, 0x3); /* Choose PLL3 PFD0 clock as flexspi source clock. */ - CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2); /* flexspi clock 120M. */ -#endif } extern flexspi_device_config_t deviceconfig; diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index e141bc6b8e..2c5e838e27 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -83,28 +83,38 @@ #define NO_SUBREGIONS 0 extern uint32_t _ld_flash_size; +extern uint32_t _ld_stack_top; -extern uint8_t _ld_dtcm_bss_start; -extern uint8_t _ld_dtcm_bss_end; -extern uint8_t _ld_dtcm_data_destination; -extern uint8_t _ld_dtcm_data_size; -extern uint8_t _ld_dtcm_data_flash_copy; -extern uint8_t _ld_itcm_destination; -extern uint8_t _ld_itcm_size; -extern uint8_t _ld_itcm_flash_copy; +extern uint32_t __isr_vector[]; + +extern uint32_t _ld_ocram_bss_start; +extern uint32_t _ld_ocram_bss_size; +extern uint32_t _ld_ocram_data_destination; +extern uint32_t _ld_ocram_data_size; +extern uint32_t _ld_ocram_data_flash_copy; +extern uint32_t _ld_dtcm_bss_start; +extern uint32_t _ld_dtcm_bss_size; +extern uint32_t _ld_dtcm_data_destination; +extern uint32_t _ld_dtcm_data_size; +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 void main(void); + +// This replaces the Reset_Handler in startup_*.S and SystemInit in system_*.c. +__attribute__((used, naked)) void Reset_Handler(void) { + __disable_irq(); + SCB->VTOR = (uint32_t) &__isr_vector; + __set_MSP((uint32_t) &_ld_stack_top); -// This is called before RAM is setup! Be very careful what you do here. -void SystemInitHook(void) { - // asm("bkpt"); /* Disable I cache and D cache */ - if (SCB_CCR_IC_Msk == (SCB_CCR_IC_Msk & SCB->CCR)) - { - SCB_DisableICache(); - } - if (SCB_CCR_DC_Msk == (SCB_CCR_DC_Msk & SCB->CCR)) - { - SCB_DisableDCache(); - } + SCB_DisableICache(); + SCB_DisableDCache(); + + // Changing the FlexRAM must happen here where the stack is empty. If it is in a function call, + // then the return will jump to an invalid address. // Configure FlexRAM. The e is one block of ITCM (0b11) and DTCM (0b10). The rest is two OCRAM // (0b01). We shift in zeroes for all unimplemented banks. IOMUXC_GPR->GPR17 = (0xe5555555) >> (32 - 2 * FSL_FEATURE_FLEXRAM_INTERNAL_RAM_TOTAL_BANK_NUMBERS); @@ -120,17 +130,35 @@ void SystemInitHook(void) { current_gpr14 |= IOMUXC_GPR_GPR14_CM7_CFGITCMSZ(0x6); IOMUXC_GPR->GPR14 = current_gpr14; + #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)) */ + + /* Disable Watchdog Power Down Counter */ + WDOG1->WMCR &= ~WDOG_WMCR_PDE_MASK; + WDOG2->WMCR &= ~WDOG_WMCR_PDE_MASK; + + /* Watchdog disable */ + WDOG1->WCR &= ~WDOG_WCR_WDE_MASK; + WDOG2->WCR &= ~WDOG_WCR_WDE_MASK; + RTWDOG->CNT = 0xD928C520U; /* 0xD928C520U is the update key */ + RTWDOG->TOVAL = 0xFFFF; + RTWDOG->CS = (uint32_t) ((RTWDOG->CS) & ~RTWDOG_CS_EN_MASK) | RTWDOG_CS_UPDATE_MASK; + + /* Disable Systick which might be enabled by bootrom */ + if (SysTick->CTRL & SysTick_CTRL_ENABLE_Msk) + { + SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; + } + /* Disable MPU */ ARM_MPU_Disable(); - // Copy all of the code to run from ITCM. - memcpy(&_ld_itcm_destination, &_ld_itcm_flash_copy, (size_t) &_ld_itcm_size); - - // Copy all of the data to run from DTCM. - memcpy(&_ld_dtcm_data_destination, &_ld_dtcm_data_flash_copy, (size_t) &_ld_dtcm_data_size); - - // Clear DTCM bss. - memset(&_ld_dtcm_bss_start, 0, (size_t) (&_ld_dtcm_bss_end - &_ld_dtcm_bss_start)); + // Copy all of the code to run from ITCM. Do this while the MPU is disabled because we write + // protect it. + for (uint32_t i = 0; i < ((size_t) &_ld_itcm_size) / 4; i++) { + (&_ld_itcm_destination)[i] = (&_ld_itcm_flash_copy)[i]; + } // 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. @@ -187,9 +215,32 @@ void SystemInitHook(void) { /* Enable MPU */ ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); - /* Enable I cache and D cache */ + /* We're done mucking with memory so enable I cache and D cache */ SCB_EnableDCache(); SCB_EnableICache(); + + // Copy all of the data to run from DTCM. + for (uint32_t i = 0; i < ((size_t) &_ld_dtcm_data_size) / 4; i++) { + (&_ld_dtcm_data_destination)[i] = (&_ld_dtcm_data_flash_copy)[i]; + } + + // Clear DTCM bss. + for (uint32_t i = 0; i < ((size_t) &_ld_dtcm_bss_size) / 4; i++) { + (&_ld_dtcm_bss_start)[i] = 0; + } + + // Copy all of the data to run from OCRAM. + for (uint32_t i = 0; i < ((size_t) &_ld_ocram_data_size) / 4; i++) { + (&_ld_ocram_data_destination)[i] = (&_ld_ocram_data_flash_copy)[i]; + } + + // Clear OCRAM bss. + for (uint32_t i = 0; i < ((size_t) &_ld_ocram_bss_size) / 4; i++) { + (&_ld_ocram_bss_start)[i] = 0; + } + + __enable_irq(); + main(); } safe_mode_t port_init(void) { From 834259a2cf0da61a9e5a72e49abf8bc0eb62dcda Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Sat, 18 Jan 2020 11:57:57 -0800 Subject: [PATCH 354/531] Update translations and translation sources --- Makefile | 2 +- locale/ID.po | 236 ++++++++++++++++++++++++++++++++++---- locale/circuitpython.pot | 224 ++++++++++++++++++++++++++++++++++-- locale/de_DE.po | 236 ++++++++++++++++++++++++++++++++++---- locale/en_US.po | 236 ++++++++++++++++++++++++++++++++++---- locale/en_x_pirate.po | 236 ++++++++++++++++++++++++++++++++++---- locale/es.po | 239 +++++++++++++++++++++++++++++++++++---- locale/fil.po | 236 ++++++++++++++++++++++++++++++++++---- locale/fr.po | 239 +++++++++++++++++++++++++++++++++++---- locale/it_IT.po | 239 +++++++++++++++++++++++++++++++++++---- locale/ko.po | 236 ++++++++++++++++++++++++++++++++++---- locale/pl.po | 239 +++++++++++++++++++++++++++++++++++---- locale/pt_BR.po | 236 ++++++++++++++++++++++++++++++++++---- locale/zh_Latn_pinyin.po | 239 +++++++++++++++++++++++++++++++++++---- 14 files changed, 2833 insertions(+), 240 deletions(-) diff --git a/Makefile b/Makefile index d7127b517d..7eff665c08 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(BASEOPTS) # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(BASEOPTS) -TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/nrf py shared-bindings shared-module supervisor +TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/cxd56 ports/mimxrt10xx ports/nrf ports/stm32f4 py shared-bindings shared-module supervisor .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext stubs diff --git a/locale/ID.po b/locale/ID.po index e6d19cc2c4..6bdb0d4c04 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -273,6 +273,7 @@ msgstr "Semua timer untuk pin ini sedang digunakan" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -283,6 +284,12 @@ msgstr "Semua timer sedang digunakan" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "fungsionalitas AnalogOut tidak didukung" @@ -296,6 +303,7 @@ msgid "AnalogOut not supported on given pin" msgstr "pin yang dipakai tidak mendukung AnalogOut" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Send yang lain sudah aktif" @@ -410,6 +418,7 @@ msgid "Cannot delete values" msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "Tidak bisa mendapatkan pull pada saat mode output" @@ -442,6 +451,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "" #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Tidak dapat melakukan reset ke bootloader karena tidak ada bootloader yang " @@ -463,6 +474,10 @@ msgstr "" msgid "Cannot unambiguously get sizeof scalar" msgstr "tidak dapat mendapatkan ukuran scalar secara tidak ambigu" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "" @@ -519,25 +534,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "Tidak dapat menginisialisasi UART" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "" @@ -545,6 +588,14 @@ msgstr "" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC sudah digunakan" @@ -571,6 +622,10 @@ msgstr "" msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -587,6 +642,7 @@ msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "Channel EXTINT sedang digunakan" @@ -636,11 +692,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Gagal untuk mengalokasikan buffer RX" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -654,7 +712,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -671,14 +729,14 @@ msgstr "" msgid "File exists" msgstr "" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -693,10 +751,22 @@ msgstr "" msgid "Group full" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "operasi I/O pada file tertutup" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "operasi I2C tidak didukung" @@ -723,20 +793,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "%q pada tidak valid" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Frekuensi PWM tidak valid" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "" @@ -745,7 +841,7 @@ msgstr "" msgid "Invalid bits per value" msgstr "" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "Ukuran buffer tidak valid" @@ -773,6 +869,14 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "" @@ -799,7 +903,9 @@ msgstr "Pin untuk channel kanan tidak valid" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Pin-pin tidak valid" @@ -831,6 +937,10 @@ msgstr "" msgid "Invalid wave file" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "LHS dari keyword arg harus menjadi sebuah id" @@ -876,10 +986,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -889,6 +1007,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Tidak ada DAC (Digital Analog Converter) di dalam chip" @@ -897,11 +1016,23 @@ msgstr "Tidak ada DAC (Digital Analog Converter) di dalam chip" msgid "No DMA channel found" msgstr "tidak ada channel DMA ditemukan" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Tidak pin RX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Tidak ada pin TX" @@ -930,6 +1061,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "Tidak ada dukungan hardware untuk pin" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -997,12 +1132,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)" @@ -1032,6 +1174,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" @@ -1040,6 +1199,10 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "" @@ -1082,6 +1245,14 @@ msgstr "" msgid "SDA or SCL needs a pull up" msgstr "SDA atau SCL membutuhkan pull up" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "" @@ -1121,6 +1292,10 @@ msgstr "" msgid "Stream missing readinto() or write() method." msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1194,6 +1369,26 @@ msgstr "" msgid "Tuple or struct_time argument required" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "" @@ -1275,7 +1470,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Baudrate tidak didukung" @@ -1800,7 +1995,7 @@ msgstr "argumen keyword ekstra telah diberikan" msgid "extra positional arguments given" msgstr "argumen posisi ekstra telah diberikan" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -1910,6 +2105,7 @@ msgid "incorrect padding" msgstr "lapisan (padding) tidak benar" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index keluar dari jangkauan" @@ -2303,6 +2499,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "Muncul dari PulseIn yang kosong" @@ -2509,7 +2706,8 @@ msgstr "" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "tx dan rx keduanya tidak boleh kosong" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index a60d95aa24..35cd63edd8 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-13 18:15-0500\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -271,6 +271,7 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -281,6 +282,12 @@ msgstr "" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "" @@ -294,6 +301,7 @@ msgid "AnalogOut not supported on given pin" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "" @@ -405,6 +413,7 @@ msgid "Cannot delete values" msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "" @@ -434,6 +443,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "" #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" @@ -453,6 +464,10 @@ msgstr "" msgid "Cannot unambiguously get sizeof scalar" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "" @@ -509,10 +524,38 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" @@ -535,6 +578,14 @@ msgstr "" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "" @@ -560,6 +611,10 @@ msgstr "" msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -576,6 +631,7 @@ msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "" @@ -620,16 +676,18 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/sd.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -647,7 +705,7 @@ msgstr "" msgid "Failed to parse MP3 file" msgstr "" -#: ports/nrf/sd.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "" @@ -664,6 +722,10 @@ msgstr "" msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -678,10 +740,22 @@ msgstr "" msgid "Group full" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "" @@ -708,20 +782,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "" @@ -730,7 +830,7 @@ msgstr "" msgid "Invalid bits per value" msgstr "" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "" @@ -758,6 +858,14 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "" @@ -784,7 +892,9 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "" @@ -816,6 +926,10 @@ msgstr "" msgid "Invalid wave file" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "" @@ -861,10 +975,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -874,6 +996,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "" @@ -882,11 +1005,23 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "" @@ -915,6 +1050,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -981,12 +1120,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "" @@ -1014,6 +1160,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" @@ -1022,6 +1185,10 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "" @@ -1062,6 +1229,14 @@ msgstr "" msgid "SDA or SCL needs a pull up" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "" @@ -1101,6 +1276,10 @@ msgstr "" msgid "Stream missing readinto() or write() method." msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1174,6 +1353,26 @@ msgstr "" msgid "Tuple or struct_time argument required" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "" @@ -1255,7 +1454,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "" @@ -1882,6 +2081,7 @@ msgid "incorrect padding" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2274,6 +2474,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "" @@ -2479,7 +2680,8 @@ msgstr "" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index f38a036899..8fa78d64e6 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -273,6 +273,7 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -283,6 +284,12 @@ msgstr "Alle timer werden benutzt" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "AnalogOut-Funktion wird nicht unterstützt" @@ -296,6 +303,7 @@ msgid "AnalogOut not supported on given pin" msgstr "AnalogOut ist an diesem Pin nicht unterstützt" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Ein anderer Sendevorgang ist schon aktiv" @@ -409,6 +417,7 @@ msgid "Cannot delete values" msgstr "Kann Werte nicht löschen" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "Pull up im Ausgabemodus nicht möglich" @@ -438,6 +447,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "Kann '/' nicht remounten when USB aktiv ist" #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Reset zum bootloader nicht möglich da bootloader nicht vorhanden" @@ -457,6 +468,10 @@ msgstr "Übertragung ohne MOSI- und MISO-Pins nicht möglich." msgid "Cannot unambiguously get sizeof scalar" msgstr "sizeof scalar kann nicht eindeutig bestimmt werden" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "Kann nicht ohne MOSI-Pin schreiben." @@ -513,25 +528,53 @@ msgstr "Beschädigte .mpy Datei" msgid "Corrupt raw code" msgstr "Beschädigter raw code" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "Konnte UART nicht initialisieren" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "Konnte first buffer nicht zuteilen" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "Konnte second buffer nicht zuteilen" @@ -539,6 +582,14 @@ msgstr "Konnte second buffer nicht zuteilen" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC wird schon benutzt" @@ -564,6 +615,10 @@ msgstr "Die Zielkapazität ist kleiner als destination_length." msgid "Device in use" msgstr "Gerät in Benutzung" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "Display muss einen 16 Bit Farbraum haben." @@ -580,6 +635,7 @@ msgstr "Drive mode wird nicht verwendet, wenn die Richtung input ist." #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "EXTINT Kanal ist schon in Benutzung" @@ -629,11 +685,13 @@ msgstr "Kommando nicht gesendet." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Konnte keinen RX Buffer allozieren" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -647,7 +705,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "Verbindung nicht erfolgreich: timeout" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -664,16 +722,16 @@ msgstr "" msgid "File exists" msgstr "Datei existiert" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" "Die aufgezeichnete Frequenz liegt über der Leistungsgrenze. Aufnahme " "angehalten." +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -688,10 +746,22 @@ msgstr "Gruppe schon benutzt" msgid "Group full" msgstr "Gruppe voll" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "Lese/Schreibe-operation an geschlossener Datei" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "I2C-operation nicht unterstützt" @@ -720,20 +790,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Ungültiger %q pin" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "Ungültige BMP-Datei" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Ungültige PWM Frequenz" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Ungültiges Argument" @@ -742,7 +838,7 @@ msgstr "Ungültiges Argument" msgid "Invalid bits per value" msgstr "Ungültige Bits pro Wert" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "Ungültige Puffergröße" @@ -770,6 +866,14 @@ msgstr "Ungültige Datei" msgid "Invalid format chunk size" msgstr "Ungültige format chunk size" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Ungültige Anzahl von Bits" @@ -796,7 +900,9 @@ msgstr "Ungültiger Pin für rechten Kanal" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Ungültige Pins" @@ -828,6 +934,10 @@ msgstr "Ungültige Anzahl von Stimmen" msgid "Invalid wave file" msgstr "Ungültige wave Datei" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "LHS des Schlüsselwortarguments muss eine id sein" @@ -874,10 +984,18 @@ msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" "Die Startverzögerung des Mikrofons muss im Bereich von 0,0 bis 1,0 liegen" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "Muss eine %q Unterklasse sein." +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -887,6 +1005,7 @@ msgid "No CCCD for this Characteristic" msgstr "Kein CCCD für diese Charakteristik" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Kein DAC im Chip vorhanden" @@ -895,11 +1014,23 @@ msgstr "Kein DAC im Chip vorhanden" msgid "No DMA channel found" msgstr "Kein DMA Kanal gefunden" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Kein RX Pin" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Kein TX Pin" @@ -928,6 +1059,10 @@ msgstr "Keine Hardwareunterstützung am clk Pin" msgid "No hardware support on pin" msgstr "Keine Hardwareunterstützung an diesem Pin" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Kein Pulldown Widerstand am Pin; 1Mohm wird vorgeschlagen" @@ -1000,12 +1135,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "Die PWM-Frequenz ist nicht schreibbar wenn variable_Frequenz = False." +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Zugang verweigert" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Pin hat keine ADC Funktionalität" @@ -1035,6 +1177,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "Pull wird nicht verwendet, wenn die Richtung output ist." +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Die RTC-Kalibrierung wird auf diesem Board nicht unterstützt" @@ -1043,6 +1202,10 @@ msgstr "Die RTC-Kalibrierung wird auf diesem Board nicht unterstützt" msgid "RTC is not supported on this board" msgstr "Eine RTC wird auf diesem Board nicht unterstützt" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "Bereich außerhalb der Grenzen" @@ -1083,6 +1246,14 @@ msgstr "Sicherheitsmodus aktiv! Gespeicherter Code wird nicht ausgeführt\n" msgid "SDA or SCL needs a pull up" msgstr "SDA oder SCL brauchen pull up" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "Abtastrate muss positiv sein" @@ -1122,6 +1293,10 @@ msgstr "Die Stackgröße sollte mindestens 256 sein" msgid "Stream missing readinto() or write() method." msgstr "Stream fehlt readinto() oder write() Methode." +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1197,6 +1372,26 @@ msgstr "Zurückverfolgung (jüngste Aufforderung zuletzt):\n" msgid "Tuple or struct_time argument required" msgstr "Tuple- oder struct_time-Argument erforderlich" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "USB beschäftigt" @@ -1280,7 +1475,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Baudrate wird nicht unterstützt" @@ -1805,7 +2000,7 @@ msgstr "Es wurden zusätzliche Keyword-Argumente angegeben" msgid "extra positional arguments given" msgstr "Es wurden zusätzliche Argumente ohne Keyword angegeben" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" @@ -1916,6 +2111,7 @@ msgid "incorrect padding" msgstr "padding ist inkorrekt" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index außerhalb der Reichweite" @@ -2316,6 +2512,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader muss displayio.Palette oder displayio.ColorConverter sein" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "pop von einem leeren PulseIn" @@ -2524,7 +2721,8 @@ msgstr "tupel/list hat falsche Länge" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "tx und rx können nicht beide None sein" diff --git a/locale/en_US.po b/locale/en_US.po index 136d0699de..df73627e69 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -271,6 +271,7 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -281,6 +282,12 @@ msgstr "" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "" @@ -294,6 +301,7 @@ msgid "AnalogOut not supported on given pin" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "" @@ -405,6 +413,7 @@ msgid "Cannot delete values" msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "" @@ -434,6 +443,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "" #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" @@ -453,6 +464,10 @@ msgstr "" msgid "Cannot unambiguously get sizeof scalar" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "" @@ -509,25 +524,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "" @@ -535,6 +578,14 @@ msgstr "" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "" @@ -560,6 +611,10 @@ msgstr "" msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -576,6 +631,7 @@ msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "" @@ -625,11 +681,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -643,7 +701,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -660,14 +718,14 @@ msgstr "" msgid "File exists" msgstr "" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -682,10 +740,22 @@ msgstr "" msgid "Group full" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "" @@ -712,20 +782,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "" @@ -734,7 +830,7 @@ msgstr "" msgid "Invalid bits per value" msgstr "" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "" @@ -762,6 +858,14 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "" @@ -788,7 +892,9 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "" @@ -820,6 +926,10 @@ msgstr "" msgid "Invalid wave file" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "" @@ -865,10 +975,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -878,6 +996,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "" @@ -886,11 +1005,23 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "" @@ -919,6 +1050,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -985,12 +1120,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "" @@ -1018,6 +1160,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" @@ -1026,6 +1185,10 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "" @@ -1066,6 +1229,14 @@ msgstr "" msgid "SDA or SCL needs a pull up" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "" @@ -1105,6 +1276,10 @@ msgstr "" msgid "Stream missing readinto() or write() method." msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1178,6 +1353,26 @@ msgstr "" msgid "Tuple or struct_time argument required" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "" @@ -1259,7 +1454,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "" @@ -1776,7 +1971,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -1886,6 +2081,7 @@ msgid "incorrect padding" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2278,6 +2474,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "" @@ -2483,7 +2680,8 @@ msgstr "" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 81e05f7dc3..58fdf9f704 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -273,6 +273,7 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -283,6 +284,12 @@ msgstr "" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "" @@ -296,6 +303,7 @@ msgid "AnalogOut not supported on given pin" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Belay that! thar be another active send" @@ -409,6 +417,7 @@ msgid "Cannot delete values" msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "" @@ -438,6 +447,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "" #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" @@ -457,6 +468,10 @@ msgstr "" msgid "Cannot unambiguously get sizeof scalar" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "" @@ -513,25 +528,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "" @@ -539,6 +582,14 @@ msgstr "" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "" @@ -564,6 +615,10 @@ msgstr "" msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -580,6 +635,7 @@ msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "Avast! EXTINT channel already in use" @@ -629,11 +685,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -647,7 +705,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -664,14 +722,14 @@ msgstr "" msgid "File exists" msgstr "" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -686,10 +744,22 @@ msgstr "" msgid "Group full" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "" @@ -716,20 +786,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Avast! %q pin be invalid" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "" @@ -738,7 +834,7 @@ msgstr "" msgid "Invalid bits per value" msgstr "" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "" @@ -766,6 +862,14 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "" @@ -792,7 +896,9 @@ msgstr "Belay that! Invalid pin for starboard-side channel" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "" @@ -824,6 +930,10 @@ msgstr "" msgid "Invalid wave file" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "" @@ -869,10 +979,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -882,6 +1000,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Shiver me timbers! There be no DAC on this chip" @@ -890,11 +1009,23 @@ msgstr "Shiver me timbers! There be no DAC on this chip" msgid "No DMA channel found" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "" @@ -923,6 +1054,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -989,12 +1124,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Belay that! Th' Pin be not ADC capable" @@ -1022,6 +1164,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" @@ -1030,6 +1189,10 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "" @@ -1070,6 +1233,14 @@ msgstr "Runnin' in safe mode! Nay runnin' saved code.\n" msgid "SDA or SCL needs a pull up" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "" @@ -1109,6 +1280,10 @@ msgstr "" msgid "Stream missing readinto() or write() method." msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1182,6 +1357,26 @@ msgstr "" msgid "Tuple or struct_time argument required" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "" @@ -1263,7 +1458,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "" @@ -1780,7 +1975,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -1890,6 +2085,7 @@ msgid "incorrect padding" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2282,6 +2478,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "" @@ -2487,7 +2684,8 @@ msgstr "" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "" diff --git a/locale/es.po b/locale/es.po index a8f6afb2a1..6521921a97 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -275,6 +275,7 @@ msgstr "Todos los timers para este pin están siendo utilizados" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -285,6 +286,12 @@ msgstr "Todos los timers en uso" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "Funcionalidad AnalogOut no soportada" @@ -298,6 +305,7 @@ msgid "AnalogOut not supported on given pin" msgstr "El pin proporcionado no soporta AnalogOut" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Otro envío ya está activo" @@ -411,6 +419,7 @@ msgid "Cannot delete values" msgstr "No se puede eliminar valores" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "No puede ser pull mientras este en modo de salida" @@ -440,6 +449,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "No se puede volver a montar '/' cuando el USB esta activo." #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "No se puede reiniciar a bootloader porque no hay bootloader presente." @@ -459,6 +470,10 @@ msgstr "No se puede transmitir sin pines MOSI y MISO." msgid "Cannot unambiguously get sizeof scalar" msgstr "No se puede obtener inequívocamente sizeof escalar" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "No se puede escribir sin pin MOSI." @@ -515,25 +530,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "No se puede inicializar la UART" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "No se pudo asignar el primer buffer" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "No se pudo asignar el segundo buffer" @@ -541,6 +584,14 @@ msgstr "No se pudo asignar el segundo buffer" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC ya está siendo utilizado" @@ -566,6 +617,10 @@ msgstr "Capacidad de destino es mas pequeña que destination_length." msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -582,6 +637,7 @@ msgstr "Modo Drive no se usa cuando la dirección es input." #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "El canal EXTINT ya está siendo utilizado" @@ -631,11 +687,13 @@ msgstr "Fallo enviando comando" msgid "Failed to acquire mutex, err 0x%04x" msgstr "No se puede adquirir el mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Ha fallado la asignación del buffer RX" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -649,7 +707,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -666,14 +724,14 @@ msgstr "" msgid "File exists" msgstr "El archivo ya existe" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "Falló la escritura" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "Frecuencia capturada por encima de la capacidad. Captura en pausa." +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -688,10 +746,22 @@ msgstr "" msgid "Group full" msgstr "Group lleno" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "Operación I/O en archivo cerrado" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "operación I2C no soportada" @@ -720,20 +790,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Pin %q inválido" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "Archivo BMP inválido" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Frecuencia PWM inválida" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Argumento inválido" @@ -742,7 +838,7 @@ msgstr "Argumento inválido" msgid "Invalid bits per value" msgstr "Inválido bits por valor" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "Tamaño de buffer inválido" @@ -770,6 +866,14 @@ msgstr "Archivo inválido" msgid "Invalid format chunk size" msgstr "Formato de fragmento de formato no válido" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Numero inválido de bits" @@ -796,7 +900,9 @@ msgstr "Pin inválido para canal derecho" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "pines inválidos" @@ -828,6 +934,10 @@ msgstr "Cuenta de voces inválida" msgid "Invalid wave file" msgstr "Archivo wave inválido" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "LHS del agumento por palabra clave deberia ser un identificador" @@ -873,10 +983,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Micrófono demora de inicio debe estar en el rango 0.0 a 1.0" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "Debe de ser una subclase de %q" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -886,6 +1004,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "El chip no tiene DAC" @@ -894,11 +1013,23 @@ msgstr "El chip no tiene DAC" msgid "No DMA channel found" msgstr "No se encontró el canal DMA" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Sin pin RX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Sin pin TX" @@ -927,6 +1058,10 @@ msgstr "Sin soporte de hardware en el pin clk" msgid "No hardware support on pin" msgstr "Sin soporte de hardware en pin" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -999,12 +1134,19 @@ msgstr "" "PWM frecuencia no esta escrito cuando el variable_frequency es falso en " "construcion" +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Permiso denegado" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Pin no tiene capacidad ADC" @@ -1034,6 +1176,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "Pull no se usa cuando la dirección es output." +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Calibración de RTC no es soportada en esta placa" @@ -1042,6 +1201,10 @@ msgstr "Calibración de RTC no es soportada en esta placa" msgid "RTC is not supported on this board" msgstr "RTC no soportado en esta placa" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c #, fuzzy msgid "Range out of bounds" @@ -1084,6 +1247,14 @@ msgstr "Ejecutando en modo seguro! No se esta ejecutando el código guardado.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA o SCL necesitan una pull up" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "Sample rate debe ser positivo" @@ -1123,6 +1294,10 @@ msgstr "El tamaño de la pila debe ser de al menos 256" msgid "Stream missing readinto() or write() method." msgstr "A Stream le falta el método readinto() o write()." +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1196,6 +1371,26 @@ msgstr "Traceback (ultima llamada reciente):\n" msgid "Tuple or struct_time argument required" msgstr "Argumento tuple o struct_time requerido" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "USB ocupado" @@ -1277,7 +1472,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Baudrate no soportado" @@ -1808,7 +2003,7 @@ msgstr "argumento(s) por palabra clave adicionales fueron dados" msgid "extra positional arguments given" msgstr "argumento posicional adicional dado" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "el archivo deberia ser una archivo abierto en modo byte" @@ -1918,6 +2113,7 @@ msgid "incorrect padding" msgstr "relleno (padding) incorrecto" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index fuera de rango" @@ -2317,6 +2513,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader debe ser displayio.Palette o displayio.ColorConverter" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "pop de un PulseIn vacío" @@ -2525,7 +2722,8 @@ msgstr "tupla/lista tiene una longitud incorrecta" msgid "tuple/list required on RHS" msgstr "tuple/lista se require en RHS" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "Ambos tx y rx no pueden ser None" @@ -2850,6 +3048,9 @@ msgstr "paso cero" #~ msgid "Flash erase failed to start, err 0x%04x" #~ msgstr "Falló el iniciar borrado de flash, err 0x%04x" +#~ msgid "Flash write failed" +#~ msgstr "Falló la escritura" + #~ msgid "Flash write failed to start, err 0x%04x" #~ msgstr "Falló el iniciar la escritura de flash, err 0x%04x" diff --git a/locale/fil.po b/locale/fil.po index 3c1d13fa85..69d7e169a4 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -275,6 +275,7 @@ msgstr "Lahat ng timers para sa pin na ito ay ginagamit" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -285,6 +286,12 @@ msgstr "Lahat ng timer ginagamit" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "Hindi supportado ang AnalogOut" @@ -298,6 +305,7 @@ msgid "AnalogOut not supported on given pin" msgstr "Hindi supportado ang AnalogOut sa ibinigay na pin" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Isa pang send ay aktibo na" @@ -412,6 +420,7 @@ msgid "Cannot delete values" msgstr "Hindi mabura ang values" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "Hindi makakakuha ng pull habang nasa output mode" @@ -442,6 +451,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "Hindi ma-remount '/' kapag aktibo ang USB." #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Hindi ma-reset sa bootloader dahil walang bootloader." @@ -461,6 +472,10 @@ msgstr "Hindi maaaring ilipat kapag walang MOSI at MISO pin." msgid "Cannot unambiguously get sizeof scalar" msgstr "Hindi puedeng hindi sigurado ang get sizeof scalar" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "Hindi maaring isulat kapag walang MOSI pin." @@ -518,25 +533,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "Hindi ma-initialize ang UART" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "Hindi ma-iallocate ang first buffer" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "Hindi ma-iallocate ang second buffer" @@ -544,6 +587,14 @@ msgstr "Hindi ma-iallocate ang second buffer" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "Ginagamit na ang DAC" @@ -572,6 +623,10 @@ msgstr "" msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -588,6 +643,7 @@ msgstr "Drive mode ay hindi ginagamit kapag ang direksyon ay input." #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "Ginagamit na ang EXTINT channel" @@ -639,11 +695,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Nabigong ilaan ang RX buffer" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -657,7 +715,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -674,14 +732,14 @@ msgstr "" msgid "File exists" msgstr "Mayroong file" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -696,10 +754,22 @@ msgstr "" msgid "Group full" msgstr "Puno ang group" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "I/O operasyon sa saradong file" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "Hindi supportado ang operasyong I2C" @@ -728,20 +798,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Mali ang %q pin" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "Mali ang BMP file" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Mali ang PWM frequency" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Maling argumento" @@ -750,7 +846,7 @@ msgstr "Maling argumento" msgid "Invalid bits per value" msgstr "" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "Mali ang buffer size" @@ -778,6 +874,14 @@ msgstr "Mali ang file" msgid "Invalid format chunk size" msgstr "Mali ang format ng chunk size" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Mali ang bilang ng bits" @@ -804,7 +908,9 @@ msgstr "Mali ang pin para sa kanang channel" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Mali ang pins" @@ -836,6 +942,10 @@ msgstr "Maling bilang ng voice" msgid "Invalid wave file" msgstr "May hindi tama sa wave file" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "LHS ng keyword arg ay dapat na id" @@ -881,10 +991,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Ang delay ng startup ng mikropono ay dapat na nasa 0.0 hanggang 1.0" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -894,6 +1012,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Walang DAC sa chip" @@ -902,11 +1021,23 @@ msgstr "Walang DAC sa chip" msgid "No DMA channel found" msgstr "Walang DMA channel na mahanap" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Walang RX pin" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Walang TX pin" @@ -935,6 +1066,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "Walang support sa hardware ang pin" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1005,12 +1140,19 @@ msgid "" msgstr "" "PWM frequency hindi writable kapag variable_frequency ay False sa pag buo." +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Walang pahintulot" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Ang pin ay walang kakayahan sa ADC" @@ -1040,6 +1182,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "Pull hindi ginagamit kapag ang direksyon ay output." +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "RTC calibration ay hindi supportado ng board na ito" @@ -1048,6 +1207,10 @@ msgstr "RTC calibration ay hindi supportado ng board na ito" msgid "RTC is not supported on this board" msgstr "Hindi supportado ang RTC sa board na ito" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c #, fuzzy msgid "Range out of bounds" @@ -1090,6 +1253,14 @@ msgstr "Tumatakbo sa safe mode! Hindi tumatakbo ang nai-save na code.\n" msgid "SDA or SCL needs a pull up" msgstr "Kailangan ng pull up resistors ang SDA o SCL" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "Sample rate ay dapat positibo" @@ -1129,6 +1300,10 @@ msgstr "Ang laki ng stack ay dapat na hindi bababa sa 256" msgid "Stream missing readinto() or write() method." msgstr "Stream kulang ng readinto() o write() method." +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1202,6 +1377,26 @@ msgstr "Traceback (pinakahuling huling tawag): \n" msgid "Tuple or struct_time argument required" msgstr "Tuple o struct_time argument kailangan" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "Busy ang USB" @@ -1284,7 +1479,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Hindi supportadong baudrate" @@ -1822,7 +2017,7 @@ msgstr "dagdag na keyword argument na ibinigay" msgid "extra positional arguments given" msgstr "dagdag na positional argument na ibinigay" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "file ay dapat buksan sa byte mode" @@ -1933,6 +2128,7 @@ msgid "incorrect padding" msgstr "mali ang padding" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index wala sa sakop" @@ -2331,6 +2527,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader ay dapat displayio.Palette o displayio.ColorConverter" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "pop mula sa walang laman na PulseIn" @@ -2540,7 +2737,8 @@ msgstr "mali ang haba ng tuple/list" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "tx at rx hindi pwedeng parehas na None" diff --git a/locale/fr.po b/locale/fr.po index df189306c9..a9124679f3 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -278,6 +278,7 @@ msgstr "Tous les timers pour cette broche sont utilisés" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -288,6 +289,12 @@ msgstr "Tous les timers sont utilisés" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "Fonctionnalité AnalogOut non supportée" @@ -302,6 +309,7 @@ msgid "AnalogOut not supported on given pin" msgstr "'AnalogOut' n'est pas supporté sur la broche indiquée" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Un autre envoi est déjà actif" @@ -416,6 +424,7 @@ msgid "Cannot delete values" msgstr "Impossible de supprimer les valeurs" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "Ne peut être tiré ('pull') en mode 'output'" @@ -446,6 +455,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "'/' ne peut être remonté quand l'USB est actif." #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Ne peut être redémarré vers le bootloader car il n'y a pas de bootloader." @@ -466,6 +477,10 @@ msgstr "Pas de transfert sans broches MOSI et MISO." msgid "Cannot unambiguously get sizeof scalar" msgstr "Impossible d'obtenir la taille du scalaire sans ambigüité" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "Impossible d'écrire sans broche MOSI." @@ -523,25 +538,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "L'UART n'a pu être initialisé" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "Impossible d'allouer le 1er tampon" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "Impossible d'allouer le 2e tampon" @@ -549,6 +592,14 @@ msgstr "Impossible d'allouer le 2e tampon" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC déjà utilisé" @@ -575,6 +626,10 @@ msgstr "La capacité de destination est plus petite que 'destination_length'." msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -591,6 +646,7 @@ msgstr "Le mode Drive n'est pas utilisé quand la direction est 'input'." #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "Canal EXTINT déjà utilisé" @@ -642,11 +698,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Echec de l'obtention de mutex, err 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Echec de l'allocation du tampon RX" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -660,7 +718,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -677,14 +735,14 @@ msgstr "" msgid "File exists" msgstr "Le fichier existe" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "L'écriture de la flash échoué" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "La fréquence capturée est au delà des capacités. Capture en pause." +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -699,10 +757,22 @@ msgstr "" msgid "Group full" msgstr "Groupe plein" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "opération d'E/S sur un fichier fermé" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "opération sur I2C non supportée" @@ -731,21 +801,47 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Broche invalide pour '%q'" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, fuzzy msgid "Invalid BMP file" msgstr "Fichier BMP invalide" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Fréquence de PWM invalide" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Argument invalide" @@ -754,7 +850,7 @@ msgstr "Argument invalide" msgid "Invalid bits per value" msgstr "Bits par valeur invalides" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c #, fuzzy msgid "Invalid buffer size" msgstr "Longueur de tampon invalide" @@ -784,6 +880,14 @@ msgstr "Fichier invalide" msgid "Invalid format chunk size" msgstr "Taille de bloc de formatage invalide" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Nombre de bits invalide" @@ -810,7 +914,9 @@ msgstr "Broche invalide pour le canal droit" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Broches invalides" @@ -843,6 +949,10 @@ msgstr "Nombre de voix invalide" msgid "Invalid wave file" msgstr "Fichier WAVE invalide" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "La partie gauche de l'argument nommé doit être un identifiant" @@ -888,10 +998,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -901,6 +1019,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Pas de DAC sur la puce" @@ -909,11 +1028,23 @@ msgstr "Pas de DAC sur la puce" msgid "No DMA channel found" msgstr "Aucun canal DMA trouvé" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Pas de broche RX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Pas de broche TX" @@ -942,6 +1073,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "Pas de support matériel pour cette broche" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1019,12 +1154,19 @@ msgstr "" "La fréquence de PWM n'est pas modifiable quand variable_frequency est False " "à la construction." +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Permission refusée" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "La broche ne peut être utilisée pour l'ADC" @@ -1053,6 +1195,23 @@ msgstr "Appuyez sur une touche pour entrer sur REPL ou CTRL-D pour recharger." msgid "Pull not used when direction is output." msgstr "Le tirage 'pull' n'est pas utilisé quand la direction est 'output'." +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "étalonnage de la RTC non supportée sur cette carte" @@ -1061,6 +1220,10 @@ msgstr "étalonnage de la RTC non supportée sur cette carte" msgid "RTC is not supported on this board" msgstr "RTC non supportée sur cette carte" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c #, fuzzy msgid "Range out of bounds" @@ -1103,6 +1266,14 @@ msgstr "Mode sans-échec! Le code sauvegardé n'est pas éxecuté.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA ou SCL a besoin d'une résistance de tirage ('pull up')" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c #, fuzzy msgid "Sample rate must be positive" @@ -1143,6 +1314,10 @@ msgstr "La pile doit être au moins de 256" msgid "Stream missing readinto() or write() method." msgstr "Il manque une méthode readinto() ou write() au flux." +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1217,6 +1392,26 @@ msgstr "Trace (appels les plus récents en dernier):\n" msgid "Tuple or struct_time argument required" msgstr "Argument de type tuple ou struct_time nécessaire" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "USB occupé" @@ -1303,7 +1498,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Débit non supporté" @@ -1848,7 +2043,7 @@ msgstr "argument(s) nommé(s) supplémentaire(s) donné(s)" msgid "extra positional arguments given" msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "le fichier doit être un fichier ouvert en mode 'byte'" @@ -1958,6 +2153,7 @@ msgid "incorrect padding" msgstr "espacement incorrect" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index hors gamme" @@ -2364,6 +2560,7 @@ msgstr "" "pixel_shader doit être un objet displayio.Palette ou displayio.ColorConverter" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "'pop' d'une entrée PulseIn vide" @@ -2574,7 +2771,8 @@ msgstr "tuple/liste a une mauvaise longueur" msgid "tuple/list required on RHS" msgstr "tuple ou liste requis en partie droite" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "tx et rx ne peuvent être 'None' tous les deux" @@ -2912,6 +3110,9 @@ msgstr "'step' nul" #~ msgid "Flash erase failed to start, err 0x%04x" #~ msgstr "Echec du démarrage de l'effacement de la flash, err 0x%04x" +#~ msgid "Flash write failed" +#~ msgstr "L'écriture de la flash échoué" + #~ msgid "Flash write failed to start, err 0x%04x" #~ msgstr "Echec du démarrage de l'écriture de la flash, err 0x%04x" diff --git a/locale/it_IT.po b/locale/it_IT.po index 3a6a710063..6164f6cf83 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -274,6 +274,7 @@ msgstr "Tutti i timer per questo pin sono in uso" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -284,6 +285,12 @@ msgstr "Tutti i timer utilizzati" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "funzionalità AnalogOut non supportata" @@ -297,6 +304,7 @@ msgid "AnalogOut not supported on given pin" msgstr "AnalogOut non supportato sul pin scelto" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Another send è gia activato" @@ -412,6 +420,7 @@ msgid "Cannot delete values" msgstr "Impossibile cancellare valori" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "non si può tirare quando nella modalita output" @@ -442,6 +451,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "Non è possibile rimontare '/' mentre l'USB è attiva." #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" "Impossibile resettare nel bootloader poiché nessun bootloader è presente." @@ -462,6 +473,10 @@ msgstr "Impossibile trasferire senza i pin MOSI e MISO." msgid "Cannot unambiguously get sizeof scalar" msgstr "Impossibile ricavare la grandezza scalare di sizeof inequivocabilmente" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "Impossibile scrivere senza pin MOSI." @@ -519,25 +534,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "Impossibile inizializzare l'UART" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "Impossibile allocare il primo buffer" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "Impossibile allocare il secondo buffer" @@ -545,6 +588,14 @@ msgstr "Impossibile allocare il secondo buffer" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC già in uso" @@ -572,6 +623,10 @@ msgstr "La capacità di destinazione è più piccola di destination_length." msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -588,6 +643,7 @@ msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "Canale EXTINT già in uso" @@ -639,11 +695,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Impossibile allocare buffer RX" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -657,7 +715,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -674,14 +732,14 @@ msgstr "" msgid "File exists" msgstr "File esistente" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "Impostazione di Flash fallito" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -696,10 +754,22 @@ msgstr "" msgid "Group full" msgstr "Gruppo pieno" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "operazione I/O su file chiuso" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "operazione I2C non supportata" @@ -728,20 +798,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Pin %q non valido" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "File BMP non valido" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Frequenza PWM non valida" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Argomento non valido" @@ -750,7 +846,7 @@ msgstr "Argomento non valido" msgid "Invalid bits per value" msgstr "bits per valore invalido" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c #, fuzzy msgid "Invalid buffer size" msgstr "lunghezza del buffer non valida" @@ -780,6 +876,14 @@ msgstr "File non valido" msgid "Invalid format chunk size" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Numero di bit non valido" @@ -806,7 +910,9 @@ msgstr "Pin non valido per il canale destro" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Pin non validi" @@ -839,6 +945,10 @@ msgstr "Tipo di servizio non valido" msgid "Invalid wave file" msgstr "File wave non valido" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "" @@ -885,10 +995,18 @@ msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" "Il ritardo di avvio del microfono deve essere nell'intervallo tra 0.0 e 1.0" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -898,6 +1016,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Nessun DAC sul chip" @@ -906,11 +1025,23 @@ msgstr "Nessun DAC sul chip" msgid "No DMA channel found" msgstr "Nessun canale DMA trovato" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Nessun pin RX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Nessun pin TX" @@ -939,6 +1070,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "Nessun supporto hardware sul pin" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1014,12 +1149,19 @@ msgstr "" "frequenza PWM frequency non è scrivibile quando variable_frequency è " "impostato nel costruttore a False." +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Permesso negato" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Il pin non ha capacità di ADC" @@ -1049,6 +1191,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "calibrazione RTC non supportata su questa scheda" @@ -1057,6 +1216,10 @@ msgstr "calibrazione RTC non supportata su questa scheda" msgid "RTC is not supported on this board" msgstr "RTC non supportato su questa scheda" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c #, fuzzy msgid "Range out of bounds" @@ -1099,6 +1262,14 @@ msgstr "Modalità sicura in esecuzione! Codice salvato non in esecuzione.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA o SCL necessitano un pull-up" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c #, fuzzy msgid "Sample rate must be positive" @@ -1140,6 +1311,10 @@ msgstr "La dimensione dello stack deve essere almeno 256" msgid "Stream missing readinto() or write() method." msgstr "Metodi mancanti readinto() o write() allo stream." +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1213,6 +1388,26 @@ msgstr "Traceback (chiamata più recente per ultima):\n" msgid "Tuple or struct_time argument required" msgstr "Tupla o struct_time richiesto come argomento" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "USB occupata" @@ -1295,7 +1490,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "baudrate non supportato" @@ -1823,7 +2018,7 @@ msgstr "argomento nominato aggiuntivo fornito" msgid "extra positional arguments given" msgstr "argomenti posizonali extra dati" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -1934,6 +2129,7 @@ msgid "incorrect padding" msgstr "padding incorretto" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "indice fuori intervallo" @@ -2338,6 +2534,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader deve essere displayio.Palette o displayio.ColorConverter" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "pop sun un PulseIn vuoto" @@ -2547,7 +2744,8 @@ msgstr "tupla/lista ha la lunghezza sbagliata" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "tx e rx non possono essere entrambi None" @@ -2869,6 +3067,9 @@ msgstr "zero step" #~ msgid "Flash erase failed to start, err 0x%04x" #~ msgstr "Iniziamento di Cancellamento di Flash fallito, err 0x%04x" +#~ msgid "Flash write failed" +#~ msgstr "Impostazione di Flash fallito" + #~ msgid "Flash write failed to start, err 0x%04x" #~ msgstr "Iniziamento di Impostazione di Flash dallito, err 0x%04x" diff --git a/locale/ko.po b/locale/ko.po index d8c9cbfba5..ee48006266 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -273,6 +273,7 @@ msgstr "핀의 모든 타이머가 사용 중입니다" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -283,6 +284,12 @@ msgstr "모든 타이머가 사용 중입니다" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "" @@ -296,6 +303,7 @@ msgid "AnalogOut not supported on given pin" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "" @@ -409,6 +417,7 @@ msgid "Cannot delete values" msgstr "값을 삭제할 수 없습니다" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "" @@ -438,6 +447,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "" #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" @@ -457,6 +468,10 @@ msgstr "" msgid "Cannot unambiguously get sizeof scalar" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "" @@ -513,25 +528,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "" @@ -539,6 +582,14 @@ msgstr "" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC가 현재 사용 중입니다" @@ -564,6 +615,10 @@ msgstr "" msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -580,6 +635,7 @@ msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "" @@ -629,11 +685,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -647,7 +705,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -664,14 +722,14 @@ msgstr "" msgid "File exists" msgstr "" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -686,10 +744,22 @@ msgstr "" msgid "Group full" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "" @@ -716,20 +786,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "" @@ -738,7 +834,7 @@ msgstr "" msgid "Invalid bits per value" msgstr "" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "" @@ -766,6 +862,14 @@ msgstr "파일이 유효하지 않습니다" msgid "Invalid format chunk size" msgstr "형식 청크 크기가 잘못되었습니다" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "비트 수가 유효하지 않습니다" @@ -792,7 +896,9 @@ msgstr "오른쪽 채널 핀이 잘못되었습니다" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "핀이 유효하지 않습니다" @@ -824,6 +930,10 @@ msgstr "" msgid "Invalid wave file" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "" @@ -869,10 +979,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -882,6 +1000,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "" @@ -890,11 +1009,23 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "" @@ -923,6 +1054,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -989,12 +1124,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "" @@ -1022,6 +1164,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "" @@ -1030,6 +1189,10 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "" @@ -1070,6 +1233,14 @@ msgstr "" msgid "SDA or SCL needs a pull up" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "" @@ -1109,6 +1280,10 @@ msgstr "" msgid "Stream missing readinto() or write() method." msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1182,6 +1357,26 @@ msgstr "" msgid "Tuple or struct_time argument required" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "" @@ -1264,7 +1459,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "" @@ -1781,7 +1976,7 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -1891,6 +2086,7 @@ msgid "incorrect padding" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2283,6 +2479,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "" @@ -2488,7 +2685,8 @@ msgstr "" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 6a16b2437a..6a009357d5 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -272,6 +272,7 @@ msgstr "Wszystkie timery tej nóżki w użyciu" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -282,6 +283,12 @@ msgstr "Wszystkie timery w użyciu" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "AnalogOut jest niewspierane" @@ -295,6 +302,7 @@ msgid "AnalogOut not supported on given pin" msgstr "AnalogOut niewspierany na tej nóżce" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Wysyłanie jest już w toku" @@ -408,6 +416,7 @@ msgid "Cannot delete values" msgstr "Nie można usunąć" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "Nie ma podciągnięcia w trybie wyjścia" @@ -437,6 +446,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "Nie można przemontować '/' gdy USB działa." #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Nie można zrestartować -- nie ma bootloadera." @@ -456,6 +467,10 @@ msgstr "Nie można przesyłać bez nóżek MOSI i MISO." msgid "Cannot unambiguously get sizeof scalar" msgstr "Wielkość skalara jest niejednoznaczna" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "Nie można pisać bez nóżki MOSI." @@ -512,25 +527,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "Ustawienie UART nie powiodło się" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "Nie udała się alokacja pierwszego bufora" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "Nie udała się alokacja drugiego bufora" @@ -538,6 +581,14 @@ msgstr "Nie udała się alokacja drugiego bufora" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC w użyciu" @@ -563,6 +614,10 @@ msgstr "Pojemność celu mniejsza od destination_length." msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -579,6 +634,7 @@ msgstr "Tryb sterowania nieużywany w trybie wejścia." #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "Kanał EXTINT w użyciu" @@ -628,11 +684,13 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nie udało się uzyskać blokady, błąd 0x$04x" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Nie udała się alokacja bufora RX" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -646,7 +704,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -663,14 +721,14 @@ msgstr "" msgid "File exists" msgstr "Plik istnieje" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "Zapis do flash nie powiódł się" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "Uzyskana częstotliwość jest niemożliwa. Spauzowano." +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -685,10 +743,22 @@ msgstr "" msgid "Group full" msgstr "Grupa pełna" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "Operacja I/O na zamkniętym pliku" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "Operacja I2C nieobsługiwana" @@ -717,20 +787,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Zła nóżka %q" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "Zły BMP" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Zła częstotliwość PWM" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Zły argument" @@ -739,7 +835,7 @@ msgstr "Zły argument" msgid "Invalid bits per value" msgstr "Zła liczba bitów wartości" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "Zła wielkość bufora" @@ -767,6 +863,14 @@ msgstr "Zły plik" msgid "Invalid format chunk size" msgstr "Zła wielkość fragmentu formatu" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Zła liczba bitów" @@ -793,7 +897,9 @@ msgstr "Zła nóżka dla prawego kanału" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Złe nóżki" @@ -825,6 +931,10 @@ msgstr "Zła liczba głosów" msgid "Invalid wave file" msgstr "Zły plik wave" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "Lewa strona argumentu nazwanego musi być nazwą" @@ -870,10 +980,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Opóźnienie włączenia mikrofonu musi być w zakresie od 0.0 do 1.0" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -883,6 +1001,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Brak DAC" @@ -891,11 +1010,23 @@ msgstr "Brak DAC" msgid "No DMA channel found" msgstr "Nie znaleziono kanału DMA" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Brak nóżki RX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Brak nóżki TX" @@ -924,6 +1055,10 @@ msgstr "" msgid "No hardware support on pin" msgstr "Brak sprzętowej obsługi na nóżce" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -990,12 +1125,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "Nie można zmienić częstotliwości PWM gdy variable_frequency=False." +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Odmowa dostępu" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Nóżka nie obsługuje ADC" @@ -1023,6 +1165,23 @@ msgstr "Dowolny klawisz aby uruchomić konsolę. CTRL-D aby przeładować." msgid "Pull not used when direction is output." msgstr "Podciągnięcie nieużywane w trybie wyjścia." +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Brak obsługi kalibracji RTC" @@ -1031,6 +1190,10 @@ msgstr "Brak obsługi kalibracji RTC" msgid "RTC is not supported on this board" msgstr "Brak obsługi RTC" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "Zakres poza granicami" @@ -1071,6 +1234,14 @@ msgstr "Uruchomiony tryb bezpieczeństwa! Zapisany kod nie jest uruchamiany.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA lub SCL wymagają podciągnięcia" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "Częstotliwość próbkowania musi być dodatnia" @@ -1110,6 +1281,10 @@ msgstr "Stos musi mieć co najmniej 256 bajtów" msgid "Stream missing readinto() or write() method." msgstr "Strumień nie ma metod readinto() lub write()." +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1183,6 +1358,26 @@ msgstr "Ślad wyjątku (najnowsze wywołanie na końcu):\n" msgid "Tuple or struct_time argument required" msgstr "Wymagana krotka lub struct_time" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "USB Zajęte" @@ -1264,7 +1459,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Zła szybkość transmisji" @@ -1785,7 +1980,7 @@ msgstr "nadmiarowe argumenty nazwane" msgid "extra positional arguments given" msgstr "nadmiarowe argumenty pozycyjne" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "file musi być otwarte w trybie bajtowym" @@ -1895,6 +2090,7 @@ msgid "incorrect padding" msgstr "złe wypełnienie" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "indeks poza zakresem" @@ -2288,6 +2484,7 @@ msgstr "" "pixel_shader musi być typu displayio.Palette lub dispalyio.ColorConverter" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "pop z pustego PulseIn" @@ -2494,7 +2691,8 @@ msgstr "krotka/lista ma złą długość" msgid "tuple/list required on RHS" msgstr "wymagana krotka/lista po prawej stronie" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "tx i rx nie mogą być oba None" @@ -2768,6 +2966,9 @@ msgstr "zerowy krok" #~ msgid "Flash erase failed to start, err 0x%04x" #~ msgstr "Nie udało się rozpocząć kasowania flash, błąd 0x%04x" +#~ msgid "Flash write failed" +#~ msgstr "Zapis do flash nie powiódł się" + #~ msgid "Flash write failed to start, err 0x%04x" #~ msgstr "Nie udało się rozpocząć zapisu do flash, błąd 0x%04x" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 7fb8fe9d7f..0d6592201e 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -274,6 +274,7 @@ msgstr "Todos os temporizadores para este pino estão em uso" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -284,6 +285,12 @@ msgstr "Todos os temporizadores em uso" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "Funcionalidade AnalogOut não suportada" @@ -297,6 +304,7 @@ msgid "AnalogOut not supported on given pin" msgstr "Saída analógica não suportada no pino fornecido" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Outro envio já está ativo" @@ -409,6 +417,7 @@ msgid "Cannot delete values" msgstr "Não é possível excluir valores" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "" @@ -439,6 +448,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "Não é possível remontar '/' enquanto o USB estiver ativo." #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "" @@ -458,6 +469,10 @@ msgstr "Não é possível transferir sem os pinos MOSI e MISO." msgid "Cannot unambiguously get sizeof scalar" msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "Não é possível ler sem um pino MOSI" @@ -515,25 +530,53 @@ msgstr "" msgid "Corrupt raw code" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "Não foi possível inicializar o UART" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "Não pôde alocar primeiro buffer" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "Não pôde alocar segundo buffer" @@ -541,6 +584,14 @@ msgstr "Não pôde alocar segundo buffer" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "DAC em uso" @@ -567,6 +618,10 @@ msgstr "" msgid "Device in use" msgstr "" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "" @@ -583,6 +638,7 @@ msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "Canal EXTINT em uso" @@ -634,11 +690,13 @@ msgstr "Falha ao enviar comando." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Falha ao alocar buffer RX" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -652,7 +710,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -669,14 +727,14 @@ msgstr "" msgid "File exists" msgstr "Arquivo já existe" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -691,10 +749,22 @@ msgstr "" msgid "Group full" msgstr "Grupo cheio" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "Operação I/O no arquivo fechado" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "I2C operação não suportada" @@ -721,20 +791,46 @@ msgstr "" msgid "Insufficient encryption" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Pino do %q inválido" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "Arquivo BMP inválido" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Frequência PWM inválida" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Argumento inválido" @@ -743,7 +839,7 @@ msgstr "Argumento inválido" msgid "Invalid bits per value" msgstr "" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c #, fuzzy msgid "Invalid buffer size" msgstr "Arquivo inválido" @@ -773,6 +869,14 @@ msgstr "Arquivo inválido" msgid "Invalid format chunk size" msgstr "Tamanho do pedaço de formato inválido" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Número inválido de bits" @@ -799,7 +903,9 @@ msgstr "Pino inválido para canal direito" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Pinos inválidos" @@ -832,6 +938,10 @@ msgstr "certificado inválido" msgid "Invalid wave file" msgstr "Aqruivo de ondas inválido" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "" @@ -877,10 +987,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -890,6 +1008,7 @@ msgid "No CCCD for this Characteristic" msgstr "" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Nenhum DAC no chip" @@ -898,11 +1017,23 @@ msgstr "Nenhum DAC no chip" msgid "No DMA channel found" msgstr "Nenhum canal DMA encontrado" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Nenhum pino RX" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Nenhum pino TX" @@ -931,6 +1062,10 @@ msgstr "Sem suporte de hardware no pino de clock" msgid "No hardware support on pin" msgstr "Nenhum suporte de hardware no pino" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1000,12 +1135,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Permissão negada" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "O pino não tem recursos de ADC" @@ -1034,6 +1176,23 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "" +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "A calibração RTC não é suportada nesta placa" @@ -1042,6 +1201,10 @@ msgstr "A calibração RTC não é suportada nesta placa" msgid "RTC is not supported on this board" msgstr "O RTC não é suportado nesta placa" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "" @@ -1083,6 +1246,14 @@ msgstr "Rodando em modo seguro! Não está executando o código salvo.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA ou SCL precisa de um pull up" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "" @@ -1122,6 +1293,10 @@ msgstr "O tamanho da pilha deve ser pelo menos 256" msgid "Stream missing readinto() or write() method." msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1195,6 +1370,26 @@ msgstr "" msgid "Tuple or struct_time argument required" msgstr "" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "USB ocupada" @@ -1276,7 +1471,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Taxa de transmissão não suportada" @@ -1798,7 +1993,7 @@ msgstr "argumentos extras de palavras-chave passados" msgid "extra positional arguments given" msgstr "argumentos extra posicionais passados" -#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -1908,6 +2103,7 @@ msgid "incorrect padding" msgstr "preenchimento incorreto" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "Índice fora do intervalo" @@ -2300,6 +2496,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "" @@ -2507,7 +2704,8 @@ msgstr "" msgid "tuple/list required on RHS" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "TX e RX não podem ser ambos" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 9f1c0ea5b6..d3ecc630c4 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-07 14:31-0800\n" +"POT-Creation-Date: 2020-01-18 11:56-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -273,6 +273,7 @@ msgstr "Cǐ yǐn jiǎo de suǒyǒu jìshí qì zhèngzài shǐyòng" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c @@ -283,6 +284,12 @@ msgstr "Suǒyǒu jìshí qì shǐyòng" msgid "Already advertising." msgstr "" +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "Bù zhīchí AnalogOut gōngnéng" @@ -296,6 +303,7 @@ msgid "AnalogOut not supported on given pin" msgstr "Wèi zhīchí zhǐdìng de yǐn jiǎo AnalogOut" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c msgid "Another send is already active" msgstr "Lìng yīgè fāsòng yǐjīng jīhuó" @@ -409,6 +417,7 @@ msgid "Cannot delete values" msgstr "Wúfǎ shānchú zhí" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "Zài shūchū móshì xià wúfǎ huòqǔ lādòng" @@ -438,6 +447,8 @@ msgid "Cannot remount '/' when USB is active." msgstr "USB jīhuó shí wúfǎ chóngxīn bǎng ding '/'." #: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." msgstr "Wúfǎ chóng zhì wèi bootloader, yīnwèi méiyǒu bootloader cúnzài." @@ -457,6 +468,10 @@ msgstr "Méiyǒu MOSI/MISO jiù wúfǎ zhuǎnyí." msgid "Cannot unambiguously get sizeof scalar" msgstr "Wúfǎ míngquè de huòdé biāoliàng de dàxiǎo" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." msgstr "Wúfǎ xiě rù MOSI de yǐn jiǎo." @@ -513,25 +528,53 @@ msgstr "Fǔbài de .mpy wénjiàn" msgid "Corrupt raw code" msgstr "Sǔnhuài de yuánshǐ dàimǎ" -#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c msgid "Could not initialize UART" msgstr "Wúfǎ chūshǐhuà UART" -#: shared-module/audiomp3/MP3File.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not initialize timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate first buffer" msgstr "Wúfǎ fēnpèi dì yī gè huǎnchōng qū" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" msgstr "" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate second buffer" msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū" @@ -539,6 +582,14 @@ msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū" msgid "Crash into the HardFault_Handler." msgstr "" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" msgstr "Fā yuán huì yǐjīng shǐyòng" @@ -564,6 +615,10 @@ msgstr "Mùbiāo róngliàng xiǎoyú mùdì de_chángdù." msgid "Device in use" msgstr "Zhèngzài shǐyòng de shèbèi" +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." msgstr "Xiǎnshì bìxū jùyǒu 16 wèi yánsè kōngjiān." @@ -580,6 +635,7 @@ msgstr "Fāngxiàng shūrù shí qūdòng móshì méiyǒu shǐyòng." #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/ps2io/Ps2.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c msgid "EXTINT channel already in use" msgstr "EXTINT píndào yǐjīng shǐyòng" @@ -629,11 +685,13 @@ msgstr "Fāsòng mìnglìng shībài." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Wúfǎ huòdé mutex, err 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Fēnpèi RX huǎnchōng shībài" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c #, c-format msgid "Failed to allocate RX buffer of %d bytes" @@ -647,7 +705,7 @@ msgstr "" msgid "Failed to connect: timeout" msgstr "Liánjiē shībài: Chāoshí" -#: shared-module/audiomp3/MP3File.c +#: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" msgstr "" @@ -664,14 +722,14 @@ msgstr "" msgid "File exists" msgstr "Wénjiàn cúnzài" -#: ports/nrf/common-hal/nvm/ByteArray.c -msgid "Flash write failed" -msgstr "Flash xiě rù shībài" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Frequency captured is above capability. Capture Paused." msgstr "Pínlǜ bǔhuò gāo yú nénglì. Bǔhuò zàntíng." +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c msgid "Function requires lock" @@ -686,10 +744,22 @@ msgstr "Jítuán yǐjīng shǐyòngguò" msgid "Group full" msgstr "Fēnzǔ yǐ mǎn" +#: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" msgstr "Wénjiàn shàng de I/ O cāozuò" +#: ports/stm32f4/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + #: extmod/machine_i2c.c msgid "I2C operation not supported" msgstr "I2C cāozuò bù zhīchí" @@ -718,20 +788,46 @@ msgstr "Rènzhèng bùzú" msgid "Insufficient encryption" msgstr "Jiāmì bùzú" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Invalid %q pin" msgstr "Wúxiào de %q yǐn jiǎo" +#: ports/stm32f4/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" msgstr "Wúxiào de BMP wénjiàn" +#: ports/stm32f4/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c +msgid "Invalid I2C pin selection" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PWMOut.c +#: ports/cxd56/common-hal/pulseio/PWMOut.c #: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c msgid "Invalid PWM frequency" msgstr "Wúxiào de PWM pínlǜ" +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c +msgid "Invalid SPI pin selection" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid UART pin selection" +msgstr "" + #: py/moduerrno.c msgid "Invalid argument" msgstr "Wúxiào de cānshù" @@ -740,7 +836,7 @@ msgstr "Wúxiào de cānshù" msgid "Invalid bits per value" msgstr "Měi gè zhí de wèi wúxiào" -#: ports/nrf/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c msgid "Invalid buffer size" msgstr "Wúxiào de huǎnchōng qū dàxiǎo" @@ -768,6 +864,14 @@ msgstr "Wúxiào de wénjiàn" msgid "Invalid format chunk size" msgstr "Géshì kuài dàxiǎo wúxiào" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "Invalid frequency supplied" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" msgstr "Wèi shù wúxiào" @@ -794,7 +898,9 @@ msgstr "Yòuxián tōngdào yǐn jiǎo wúxiào" #: ports/atmel-samd/common-hal/busio/SPI.c #: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c -#: ports/nrf/common-hal/busio/I2C.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid pins" msgstr "Wúxiào de yǐn jiǎo" @@ -826,6 +932,10 @@ msgstr "Wúxiào de yǔyīn jìshù" msgid "Invalid wave file" msgstr "Wúxiào de làng làngcháo wénjiàn" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + #: py/compile.c msgid "LHS of keyword arg must be an id" msgstr "Guānjiàn zì arg de LHS bìxū shì id" @@ -871,10 +981,18 @@ msgstr "" msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "Bìxū shì %q zi lèi." +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" msgstr "" @@ -884,6 +1002,7 @@ msgid "No CCCD for this Characteristic" msgstr "Zhège tèzhēng méiyǒu CCCD" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Méiyǒu DAC zài xīnpiàn shàng de" @@ -892,11 +1011,23 @@ msgstr "Méiyǒu DAC zài xīnpiàn shàng de" msgid "No DMA channel found" msgstr "Wèi zhǎodào DMA píndào" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No RX pin" msgstr "Wèi zhǎodào RX yǐn jiǎo" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/stm32f4/common-hal/busio/UART.c msgid "No TX pin" msgstr "Wèi zhǎodào TX yǐn jiǎo" @@ -925,6 +1056,10 @@ msgstr "Shízhōng yǐn jiǎo wú yìngjiàn zhīchí" msgid "No hardware support on pin" msgstr "Méiyǒu zài yǐn jiǎo shàng de yìngjiàn zhīchí" +#: ports/stm32f4/common-hal/pulseio/PWMOut.c +msgid "No more timers available on this pin." +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "Yǐn jiǎo shàng méiyǒu xiàlā; 1Mohm tuījiàn" @@ -995,12 +1130,19 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "Dāng biànliàng_pínlǜ shì False zài jiànzhú shí PWM pínlǜ bùkě xiě." +#: ports/stm32f4/common-hal/displayio/ParallelBus.c +msgid "ParallelBus not yet supported" +msgstr "" + #: py/moduerrno.c msgid "Permission denied" msgstr "Quánxiàn bèi jùjué" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "Pin méiyǒu ADC nénglì" @@ -1028,6 +1170,23 @@ msgstr "Àn xià rènhé jiàn jìnrù REPL. Shǐyòng CTRL-D chóngxīn jiāzà msgid "Pull not used when direction is output." msgstr "Fāngxiàng shūchū shí Pull méiyǒu shǐyòng." +#: ports/stm32f4/common-hal/pulseio/PulseIn.c +msgid "PulseIn not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/pulseio/PulseOut.c +msgid "PulseOut not yet supported" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm32f4/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" msgstr "Cǐ bǎn bù zhīchí RTC jiàozhǔn" @@ -1036,6 +1195,10 @@ msgstr "Cǐ bǎn bù zhīchí RTC jiàozhǔn" msgid "RTC is not supported on this board" msgstr "Cǐ bǎn bù zhīchí RTC" +#: ports/stm32f4/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Range out of bounds" msgstr "Fànwéi chāochū biānjiè" @@ -1076,6 +1239,14 @@ msgstr "Zài ānquán móshì xià yùnxíng! Bù yùnxíng yǐ bǎocún de dài msgid "SDA or SCL needs a pull up" msgstr "SDA huò SCL xūyào lādòng" +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "Cǎiyàng lǜ bìxū wèi zhèng shù" @@ -1115,6 +1286,10 @@ msgstr "Duīzhàn dàxiǎo bìxū zhìshǎo 256" msgid "Stream missing readinto() or write() method." msgstr "Liú quēshǎo readinto() huò write() fāngfǎ." +#: ports/stm32f4/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1190,6 +1365,26 @@ msgstr "Traceback (Zuìjìn yīcì dǎ diànhuà):\n" msgid "Tuple or struct_time argument required" msgstr "Xūyào Tuple huò struct_time cānshù" +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm32f4/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB Busy" msgstr "USB máng" @@ -1271,7 +1466,7 @@ msgid "" "declined or ignored." msgstr "" -#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "Bù zhīchí de baudrate" @@ -1796,7 +1991,7 @@ msgstr "éwài de guānjiàn cí cānshù" 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/MP3File.c +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.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" @@ -1906,6 +2101,7 @@ msgid "incorrect padding" msgstr "bù zhèngquè de tiánchōng" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "suǒyǐn chāochū fànwéi" @@ -2300,6 +2496,7 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader bìxū shì displayio.Palette huò displayio.ColorConverter" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c msgid "pop from an empty PulseIn" msgstr "cóng kōng de PulseIn dànchū dànchū" @@ -2507,7 +2704,8 @@ msgstr "yuán zǔ/lièbiǎo chángdù cuòwù" msgid "tuple/list required on RHS" msgstr "RHS yāoqiú de yuán zǔ/lièbiǎo" -#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "tx and rx cannot both be None" msgstr "tx hé rx bùnéng dōu shì wú" @@ -2807,6 +3005,9 @@ msgstr "líng bù" #~ msgid "Flash erase failed to start, err 0x%04x" #~ msgstr "Flash cā chú shībài, err 0x%04x" +#~ msgid "Flash write failed" +#~ msgstr "Flash xiě rù shībài" + #~ msgid "Flash write failed to start, err 0x%04x" #~ msgstr "Flash xiě rù shībài, err 0x%04x" From 1c3960634520749180e349cee5fe4ea76fb75937 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Sat, 18 Jan 2020 18:06:56 -0800 Subject: [PATCH 355/531] Fix other builds missing new heap bounds functions --- ports/atmel-samd/supervisor/port.c | 8 ++++++++ ports/cxd56/supervisor/port.c | 8 ++++++++ ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c | 6 ------ ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c | 6 ------ ports/nrf/supervisor/port.c | 8 ++++++++ ports/stm32f4/supervisor/port.c | 10 +++++++++- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 5662b159bc..0a4cc8c199 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -331,6 +331,14 @@ uint32_t *port_stack_get_top(void) { return &_estack; } +uint32_t *port_heap_get_bottom(void) { + return port_stack_get_limit(); +} + +uint32_t *port_heap_get_top(void) { + return port_stack_get_top(); +} + // Place the word to save 8k from the end of RAM so we and the bootloader don't clobber it. #ifdef SAMD21 uint32_t* safe_word = (uint32_t*) (HMCRAMC0_ADDR + HMCRAMC0_SIZE - 0x2000); diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c index f061334683..5d2957f350 100644 --- a/ports/cxd56/supervisor/port.c +++ b/ports/cxd56/supervisor/port.c @@ -85,6 +85,14 @@ uint32_t *port_stack_get_top(void) { return rtcb->adj_stack_ptr; } +uint32_t *port_heap_get_bottom(void) { + return port_stack_get_limit(); +} + +uint32_t *port_heap_get_top(void) { + return port_stack_get_top(); +} + extern uint32_t _ebss; // Place the word to save just after our BSS section that gets blanked. diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c index 805e62f010..7e8fb75b24 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c @@ -8,11 +8,6 @@ #include "fsl_flexspi_nor_boot.h" #include "fsl_flexspi_nor_config.h" -/* Component ID definition, used by tools. */ -#ifndef FSL_COMPONENT_ID -#define FSL_COMPONENT_ID "platform.drivers.xip_device" -#endif - __attribute__((section(".boot_hdr.ivt"))) /************************************* * IVT Data @@ -38,7 +33,6 @@ const BOOT_DATA_T boot_data = { PLUGIN_FLAG, /* Plugin flag*/ 0xFFFFFFFF /* empty - extra data word */ }; -#endif __attribute__((section(".boot_hdr.conf"))) // Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c index c51c59a519..7e046d4940 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c @@ -8,11 +8,6 @@ #include "fsl_flexspi_nor_boot.h" #include "fsl_flexspi_nor_config.h" -/* Component ID definition, used by tools. */ -#ifndef FSL_COMPONENT_ID -#define FSL_COMPONENT_ID "platform.drivers.xip_device" -#endif - __attribute__((section(".boot_hdr.ivt"))) /************************************* @@ -39,7 +34,6 @@ const BOOT_DATA_T boot_data = { PLUGIN_FLAG, /* Plugin flag*/ 0xFFFFFFFF /* empty - extra data word */ }; -#endif __attribute__((section(".boot_hdr.conf"))) // Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index af858aa4a1..84bf9cbb67 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -146,6 +146,14 @@ void reset_cpu(void) { NVIC_SystemReset(); } +uint32_t *port_heap_get_bottom(void) { + return port_stack_get_limit(); +} + +uint32_t *port_heap_get_top(void) { + return port_stack_get_top(); +} + uint32_t *port_stack_get_limit(void) { return &_ebss; } diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c index df5a70cd12..6df261b351 100644 --- a/ports/stm32f4/supervisor/port.c +++ b/ports/stm32f4/supervisor/port.c @@ -50,7 +50,7 @@ safe_mode_t port_init(void) { stm32f4_peripherals_gpio_init(); tick_init(); - board_init(); + board_init(); return NO_SAFE_MODE; } @@ -71,6 +71,14 @@ void reset_cpu(void) { NVIC_SystemReset(); } +uint32_t *port_heap_get_bottom(void) { + return port_stack_get_limit(); +} + +uint32_t *port_heap_get_top(void) { + return port_stack_get_top(); +} + uint32_t *port_stack_get_limit(void) { return &_ebss; } From 982c63a71712fc9092b35fca3ef34e4b404c03cb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 20 Jan 2020 14:08:32 -0600 Subject: [PATCH 356/531] Mixer: use MP_LIKELY macro instead of locally brewed one --- shared-module/audiomixer/Mixer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index 3c1c9a4912..9370adf010 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -140,8 +140,6 @@ static inline uint32_t pack8(uint32_t val) { return ((val & 0xff000000) >> 16) | ((val & 0xff00) >> 8); } -#define LIKELY(x) (__builtin_expect(!!(x), 1)) -#define UNLIKELY(x) (__builtin_expect(!!(x), 0)) static void mix_one_voice(audiomixer_mixer_obj_t* self, audiomixer_mixervoice_obj_t* voice, bool voices_active, uint32_t* word_buffer, uint32_t length) { @@ -172,8 +170,8 @@ static void mix_one_voice(audiomixer_mixer_obj_t* self, // First active voice gets copied over verbatim. if (!voices_active) { - if (LIKELY(self->bits_per_sample == 16)) { - if (LIKELY(self->samples_signed)) { + if (MP_LIKELY(self->bits_per_sample == 16)) { + if (MP_LIKELY(self->samples_signed)) { for (uint32_t i = 0; isamples_signed)) { + if (MP_LIKELY(!self->samples_signed)) { word = tosigned16(word); } word = mult16signed(word, level); @@ -198,8 +196,8 @@ static void mix_one_voice(audiomixer_mixer_obj_t* self, } } } else { - if (LIKELY(self->bits_per_sample == 16)) { - if (LIKELY(self->samples_signed)) { + if (MP_LIKELY(self->bits_per_sample == 16)) { + if (MP_LIKELY(self->samples_signed)) { for (uint32_t i = 0; isamples_signed)) { + if (MP_LIKELY(!self->samples_signed)) { word = tosigned16(word); } word = mult16signed(word, level); From b4ddee2bb6ae40a73efe15e30de8d33ab9ce8011 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 20 Jan 2020 14:06:39 -0600 Subject: [PATCH 357/531] Mixer: rename function based on review comment --- shared-module/audiomixer/Mixer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index 9370adf010..4a72dab28d 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -140,7 +140,7 @@ static inline uint32_t pack8(uint32_t val) { return ((val & 0xff000000) >> 16) | ((val & 0xff00) >> 8); } -static void mix_one_voice(audiomixer_mixer_obj_t* self, +static void mix_down_one_voice(audiomixer_mixer_obj_t* self, audiomixer_mixervoice_obj_t* voice, bool voices_active, uint32_t* word_buffer, uint32_t length) { bool voice_done = voice->sample == NULL; @@ -270,7 +270,7 @@ audioio_get_buffer_result_t audiomixer_mixer_get_buffer(audiomixer_mixer_obj_t* for (int32_t v = 0; v < self->voice_count; v++) { audiomixer_mixervoice_obj_t* voice = MP_OBJ_TO_PTR(self->voice[v]); - mix_one_voice(self, voice, voices_active, word_buffer, length); + mix_down_one_voice(self, voice, voices_active, word_buffer, length); voices_active = true; } From b66abd47b8411dfcb1d1482752a50e57806c8c68 Mon Sep 17 00:00:00 2001 From: tsupplis Date: Tue, 21 Jan 2020 19:45:20 +0000 Subject: [PATCH 358/531] Update fix (missing pragma gcc diagnostic push) Update fix (missing pragma gcc diagnostic push) --- py/emitnative.c | 1 + 1 file changed, 1 insertion(+) diff --git a/py/emitnative.c b/py/emitnative.c index 6d23bf0978..60f31d15f5 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -459,6 +459,7 @@ STATIC void emit_native_end_pass(emit_t *emit) { type_sig |= (emit->local_vtype[i] & 0xf) << (i * 4 + 4); } + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-align" mp_emit_glue_assign_native(emit->scope->raw_code, emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY, From e1840f6abcca0e2ef085332663fc7c0f42c41829 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Tue, 21 Jan 2020 22:03:47 +0100 Subject: [PATCH 359/531] Fix entry overrides in support matrix generation Fix #2539 The entries in the board's mpconfigboard.mk override any other entries. Also, fixed a warning for bad use of backslash in a string. --- docs/shared_bindings_matrix.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index ba0ec0e4f9..1e631c4691 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -185,7 +185,7 @@ def get_excluded_boards(base): board_is_excluded = True # check if module is specifically disabled for this board - re_pattern = "CIRCUITPY_{}\s=\s(\w)".format(module.upper()) + re_pattern = r"CIRCUITPY_{}\s=\s(\w)".format(module.upper()) find_module = re.search(re_pattern, contents) if not find_module: if base[module]["default_value"].isdigit(): @@ -204,9 +204,7 @@ def get_excluded_boards(base): ]): check_dependent_modules[module] = base[module]["default_value"] else: - if (find_module.group(1) == "0" and - find_module.group(1) != base[module]["default_value"]): - board_is_excluded = True + board_is_excluded = find_module.group(1) == "0" if board_is_excluded: if board_chip in base[module]["excluded"]: From 4923caf85e8fcda662f0ca4b0785a790f9a1d724 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 21 Jan 2020 18:53:55 -0500 Subject: [PATCH 360/531] Increase CPX stack size by 256 --- .../atmel-samd/boards/circuitplayground_express/mpconfigboard.h | 2 +- .../boards/circuitplayground_express_crickit/mpconfigboard.h | 2 +- .../boards/circuitplayground_express_displayio/mpconfigboard.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h index 6eb49b02c5..1d4fc9893c 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h @@ -28,7 +28,7 @@ #define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" // Increase stack size slightly due to CPX library import nesting -#define CIRCUITPY_DEFAULT_STACK_SIZE (4504) +#define CIRCUITPY_DEFAULT_STACK_SIZE (4760) //divisible by 8 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index e64997c0e4..1e657bb034 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -28,7 +28,7 @@ #define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" // Increase stack size slightly due to CPX library import nesting -#define CIRCUITPY_DEFAULT_STACK_SIZE (4504) +#define CIRCUITPY_DEFAULT_STACK_SIZE (4760) // divisible by 8 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index c9a7ce0405..5dbcf61aa3 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -28,7 +28,7 @@ #define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" // Increase stack size slightly due to CPX library import nesting. -#define CIRCUITPY_DEFAULT_STACK_SIZE (4504) // divisible by 8 +#define CIRCUITPY_DEFAULT_STACK_SIZE (4760) // divisible by 8 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) From 87344ff53a30ed2c41d58b6e30692f80a3968ee1 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 21 Jan 2020 18:32:19 -0800 Subject: [PATCH 361/531] Disable the DCache when USB is initialized. There are still issues enabling it. --- ports/mimxrt10xx/supervisor/usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/mimxrt10xx/supervisor/usb.c b/ports/mimxrt10xx/supervisor/usb.c index c38dd55b9d..051fcca9de 100644 --- a/ports/mimxrt10xx/supervisor/usb.c +++ b/ports/mimxrt10xx/supervisor/usb.c @@ -49,6 +49,10 @@ void init_usb_hardware(void) { phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK); phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06); usb_phy->TX = phytx; + + // Temporarily disable the data cache until we can sort out all of the spots in TinyUSB that + // need the cache invalidated or cleaned. + SCB_DisableDCache(); } void USB_OTG1_IRQHandler(void) { From 085242bf5c05fec4ae0450712879e78b7e35ac38 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 21 Jan 2020 18:45:00 -0800 Subject: [PATCH 362/531] Use new USB PIDs that aren't used yet. --- ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk | 4 ++-- ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk | 4 ++-- ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk b/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk index 62a2c90dee..7147fdf486 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/mpconfigboard.mk @@ -1,5 +1,5 @@ -USB_VID = 0x16C0 -USB_PID = 0x8888 +USB_VID = 0x239A +USB_PID = 0x8082 USB_PRODUCT = "iMX RT 1020 EVK" USB_MANUFACTURER = "NXP" diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk index a70d1deebc..e82d8ee743 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk @@ -1,5 +1,5 @@ -USB_VID = 0x16C0 -USB_PID = 0x8888 +USB_VID = 0x239A +USB_PID = 0x8084 USB_PRODUCT = "iMX RT 1060 EVK" USB_MANUFACTURER = "NXP" diff --git a/ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk b/ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk index 5913f9c9cb..7900d327ae 100644 --- a/ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/teensy40/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x8888 +USB_PID = 0x8086 USB_PRODUCT = "Teensy 4.0" USB_MANUFACTURER = "PJRC" From b326ee0a3d0f41d67a1d9dd4fc0ac6fd50d8e5f1 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 22 Jan 2020 12:12:27 -0500 Subject: [PATCH 363/531] fix microcontroller pin ommission --- ports/stm32f4/common-hal/microcontroller/Pin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/stm32f4/common-hal/microcontroller/Pin.c b/ports/stm32f4/common-hal/microcontroller/Pin.c index 615e483585..1d4d45b978 100644 --- a/ports/stm32f4/common-hal/microcontroller/Pin.c +++ b/ports/stm32f4/common-hal/microcontroller/Pin.c @@ -76,6 +76,7 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) { } // Clear claimed bit & reset claimed_pins[pin_port] &= ~(1< Date: Wed, 22 Jan 2020 19:26:01 +0100 Subject: [PATCH 364/531] Update CircuitPython differences in README --- README.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 03116be88e..280abdb171 100644 --- a/README.rst +++ b/README.rst @@ -94,13 +94,12 @@ Differences from `MicroPython `__ CircuitPython: -- includes ports for MicroChip SAMD21 (Commonly known as M0 in Adafruit - product names) and SAMD51 (M4). -- supports only SAMD21, SAMD51, and nRF52840 ports. -- tracks MicroPython's releases (not master). -- floats (aka decimals) are enabled for all builds. -- error messages are translated into 10+ languages. -- does not support concurrency within Python (including interrupts and threading). Some concurrency +- Supports native USB on all boards, allowing file editing without special tools. +- Supports only SAMD21, SAMD51, nRF52840, CXD56, STM32F4 and i.MX ports. +- Tracks MicroPython's releases (not master). +- Floats (aka decimals) are enabled for all builds. +- Error messages are translated into 10+ languages. +- Does not support concurrency within Python (including interrupts and threading). Some concurrency is achieved with native modules for tasks that require it such as audio file playback. Behavior From 2614671af15c525b939a0a6a561e5dfa783a3e54 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Wed, 22 Jan 2020 19:36:21 +0100 Subject: [PATCH 365/531] Update README.rst Co-Authored-By: Scott Shawcroft --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 280abdb171..51db41a8bc 100644 --- a/README.rst +++ b/README.rst @@ -95,7 +95,7 @@ Differences from `MicroPython `__ CircuitPython: - Supports native USB on all boards, allowing file editing without special tools. -- Supports only SAMD21, SAMD51, nRF52840, CXD56, STM32F4 and i.MX ports. +- Supports only SAMD21, SAMD51, nRF52840, CXD56, STM32F4 and i.MX RT ports. - Tracks MicroPython's releases (not master). - Floats (aka decimals) are enabled for all builds. - Error messages are translated into 10+ languages. From 36792926d24496860e021783c973a871076d7e76 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 22 Jan 2020 14:41:37 -0500 Subject: [PATCH 366/531] Revert dangling pointer issue in PWMOut --- ports/stm32f4/common-hal/pulseio/PWMOut.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index ea9f678817..0a5d0cc857 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -111,15 +111,13 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, bool tim_taken_f_mismatch = false; bool var_freq_mismatch = false; bool first_time_setup = true; - mcu_tim_pin_obj_t l_tim = {0}; for (uint i = 0; i < tim_num; i++) { - l_tim = mcu_tim_pin_list[i]; - uint8_t l_tim_index = l_tim.tim_index - 1; - uint8_t l_tim_channel = l_tim.channel_index - 1; + uint8_t l_tim_index = mcu_tim_pin_list[i].tim_index - 1; + uint8_t l_tim_channel = mcu_tim_pin_list[i].channel_index - 1; //if pin is same - if (l_tim.pin == pin) { + if (mcu_tim_pin_list[i].pin == pin) { //check if the timer has a channel active if (reserved_tim[l_tim_index] != 0) { //is it the same channel? (or all channels reserved by a var-freq) @@ -140,7 +138,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, first_time_setup = false; //skip setting up the timer } //No problems taken, so set it up - self->tim = &l_tim; + self->tim = &mcu_tim_pin_list[i]; break; } } From e9f9cee4d66ccfb81b4a0b1e8503e2bbbdb57077 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 22 Jan 2020 18:47:41 -0500 Subject: [PATCH 367/531] Invert duty cycle intensity --- ports/stm32f4/common-hal/pulseio/PWMOut.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 0a5d0cc857..000325be30 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -68,8 +68,9 @@ STATIC uint32_t timer_get_source_freq(uint32_t tim_id) { } STATIC uint32_t timer_get_internal_duty(uint16_t duty, uint32_t period) { - //duty cycle is duty/0xFFFF fraction x (number of pulses per period) - return (duty*period) / ((1 << 16) - 1); + //duty cycle is (0xFFFF - duty)/0xFFFF fraction x (number of pulses per period) + //Note that pulses are inverted, so duty cycle is inverted + return ((0xFFFF - duty)*period) / ((1 << 16) - 1); } STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, From 4675783545d782540d5e3d064dfe1a96b9e6c91e Mon Sep 17 00:00:00 2001 From: ndgarage Date: Thu, 23 Jan 2020 09:55:17 -0700 Subject: [PATCH 368/531] change-name-to-ndgarage_ndbit6 --- .github/workflows/build.yml | 2 +- ports/atmel-samd/boards/{ndbit6 => ndgarage_ndbit6}/board.c | 0 .../boards/{ndbit6 => ndgarage_ndbit6}/mpconfigboard.h | 0 .../boards/{ndbit6 => ndgarage_ndbit6}/mpconfigboard.mk | 2 +- ports/atmel-samd/boards/{ndbit6 => ndgarage_ndbit6}/pins.c | 0 5 files changed, 2 insertions(+), 2 deletions(-) rename ports/atmel-samd/boards/{ndbit6 => ndgarage_ndbit6}/board.c (100%) rename ports/atmel-samd/boards/{ndbit6 => ndgarage_ndbit6}/mpconfigboard.h (100%) rename ports/atmel-samd/boards/{ndbit6 => ndgarage_ndbit6}/mpconfigboard.mk (91%) rename ports/atmel-samd/boards/{ndbit6 => ndgarage_ndbit6}/pins.c (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3356b68427..e37963a63a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,7 +121,7 @@ jobs: - "metro_nrf52840_express" - "mini_sam_m4" - "monster_m4sk" - - "ndbit6" + - "ndgarage_ndbit6" - "particle_argon" - "particle_boron" - "particle_xenon" diff --git a/ports/atmel-samd/boards/ndbit6/board.c b/ports/atmel-samd/boards/ndgarage_ndbit6/board.c similarity index 100% rename from ports/atmel-samd/boards/ndbit6/board.c rename to ports/atmel-samd/boards/ndgarage_ndbit6/board.c diff --git a/ports/atmel-samd/boards/ndbit6/mpconfigboard.h b/ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.h similarity index 100% rename from ports/atmel-samd/boards/ndbit6/mpconfigboard.h rename to ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.h diff --git a/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk b/ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.mk similarity index 91% rename from ports/atmel-samd/boards/ndbit6/mpconfigboard.mk rename to ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.mk index 42840ac2a7..b73f0951ee 100644 --- a/ports/atmel-samd/boards/ndbit6/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.mk @@ -1,7 +1,7 @@ LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8066 -USB_PRODUCT = "ndBit6" +USB_PRODUCT = "Bit6" USB_MANUFACTURER = "ndGarage" CHIP_VARIANT = SAMD21E18A diff --git a/ports/atmel-samd/boards/ndbit6/pins.c b/ports/atmel-samd/boards/ndgarage_ndbit6/pins.c similarity index 100% rename from ports/atmel-samd/boards/ndbit6/pins.c rename to ports/atmel-samd/boards/ndgarage_ndbit6/pins.c From d8bc57c1dc159e8493b615fe8091f2722c513cf1 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 23 Jan 2020 17:17:02 -0500 Subject: [PATCH 369/531] Flash and display control --- ports/stm32f4/Makefile | 2 +- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 8 ++++---- ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 12 ++++++------ ports/stm32f4/boards/meowbit_v121/pins.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index d948996ea4..1b5b2eee24 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -22,7 +22,7 @@ # 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. -#DEBUG = 1 +DEBUG = 1 # Select the board to build for. ifeq ($(BOARD),) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 7c7f4ad745..72d4f1c88e 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -40,7 +40,7 @@ //#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader // On-board flash -// #define SPI_FLASH_MOSI_PIN (&pin_PB15) -// #define SPI_FLASH_MISO_PIN (&pin_PB14) -// #define SPI_FLASH_SCK_PIN (&pin_PB13) -// #define SPI_FLASH_CS_PIN (&pin_PB01) +#define SPI_FLASH_MOSI_PIN (&pin_PB15) +#define SPI_FLASH_MISO_PIN (&pin_PB14) +#define SPI_FLASH_SCK_PIN (&pin_PB13) +#define SPI_FLASH_CS_PIN (&pin_PB01) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index f24a2690cd..e45d2803f7 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -4,15 +4,15 @@ USB_PRODUCT = "Meowbit" USB_MANUFACTURER = "Kittenbot" USB_DEVICES = "CDC,MSC" -# SPI_FLASH_FILESYSTEM = 1 -# EXTERNAL_FLASH_DEVICE_COUNT = 1 -# EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ -# LONGINT_IMPL = MPZ +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ +LONGINT_IMPL = MPZ # BOOTLOADER_OFFSET = 0x8010000 -INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = NONE +# INTERNAL_FLASH_FILESYSTEM = 1 +# LONGINT_IMPL = NONE MCU_SERIES = m4 MCU_VARIANT = stm32f4 diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 66cbcd7d6f..0cdbefd59b 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -60,6 +60,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) }, - //{ MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) }, + { MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 68f9aee992ffcc12ed2e9f143f353b18fa12c1c3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 23 Jan 2020 20:03:55 -0500 Subject: [PATCH 370/531] reset NeoPixels on CPB on soft reload --- .../boards/circuitplayground_express/board.c | 12 +---- .../circuitplayground_express/mpconfigboard.h | 2 + .../circuitplayground_express_crickit/board.c | 12 +---- .../mpconfigboard.h | 2 + .../board.c | 12 +---- .../mpconfigboard.h | 2 + .../circuitplayground_bluefruit/board.c | 3 ++ .../mpconfigboard.h | 2 + .../nrf/common-hal/neopixel_write/__init__.c | 18 +++++--- supervisor/shared/board.c | 45 +++++++++++++++++++ supervisor/shared/board.h | 38 ++++++++++++++++ supervisor/supervisor.mk | 1 + 12 files changed, 113 insertions(+), 36 deletions(-) create mode 100644 supervisor/shared/board.c create mode 100644 supervisor/shared/board.h diff --git a/ports/atmel-samd/boards/circuitplayground_express/board.c b/ports/atmel-samd/boards/circuitplayground_express/board.c index 578963642d..85c37ee622 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express/board.c @@ -28,9 +28,8 @@ #include "boards/board.h" #include "common-hal/microcontroller/Pin.h" +#include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/neopixel_write/__init__.h" void board_init(void) { @@ -54,12 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - uint8_t empty[30]; - memset(empty, 0, 30); - digitalio_digitalinout_obj_t neopixel_pin; - common_hal_digitalio_digitalinout_construct(&neopixel_pin, &pin_PB23); - common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false, - DRIVE_MODE_PUSH_PULL); - common_hal_neopixel_write(&neopixel_pin, empty, 30); - common_hal_digitalio_digitalinout_deinit(&neopixel_pin); + board_reset_user_neopixels(); } diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h index 1d4fc9893c..0c5e5b7622 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h @@ -30,6 +30,8 @@ // Increase stack size slightly due to CPX library import nesting #define CIRCUITPY_DEFAULT_STACK_SIZE (4760) //divisible by 8 +#define USER_NEOPIXELS_PIN (&pin_PB23) + #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c b/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c index 578963642d..21217caac9 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c @@ -29,8 +29,7 @@ #include "boards/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/neopixel_write/__init__.h" +#include "supervisor/shared/board.h" void board_init(void) { @@ -54,12 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - uint8_t empty[30]; - memset(empty, 0, 30); - digitalio_digitalinout_obj_t neopixel_pin; - common_hal_digitalio_digitalinout_construct(&neopixel_pin, &pin_PB23); - common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false, - DRIVE_MODE_PUSH_PULL); - common_hal_neopixel_write(&neopixel_pin, empty, 30); - common_hal_digitalio_digitalinout_deinit(&neopixel_pin); + board_reset_user_neopixels(); } diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index 1e657bb034..312fd26268 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -24,6 +24,8 @@ #define CALIBRATE_CRYSTALLESS 1 +#define USER_NEOPIXELS_PIN (&pin_PB23) + // Explanation of how a user got into safe mode. #define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c b/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c index 578963642d..21217caac9 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c @@ -29,8 +29,7 @@ #include "boards/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/neopixel_write/__init__.h" +#include "supervisor/shared/board.h" void board_init(void) { @@ -54,12 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - uint8_t empty[30]; - memset(empty, 0, 30); - digitalio_digitalinout_obj_t neopixel_pin; - common_hal_digitalio_digitalinout_construct(&neopixel_pin, &pin_PB23); - common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false, - DRIVE_MODE_PUSH_PULL); - common_hal_neopixel_write(&neopixel_pin, empty, 30); - common_hal_digitalio_digitalinout_deinit(&neopixel_pin); + board_reset_user_neopixels(); } diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index 5dbcf61aa3..4796e90a51 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -30,6 +30,8 @@ // Increase stack size slightly due to CPX library import nesting. #define CIRCUITPY_DEFAULT_STACK_SIZE (4760) // divisible by 8 +#define USER_NEOPIXELS_PIN (&pin_PB23) + #define DEFAULT_I2C_BUS_SCL (&pin_PB03) #define DEFAULT_I2C_BUS_SDA (&pin_PB02) diff --git a/ports/nrf/boards/circuitplayground_bluefruit/board.c b/ports/nrf/boards/circuitplayground_bluefruit/board.c index 7c8ec8e9a2..3aa6857da2 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/board.c +++ b/ports/nrf/boards/circuitplayground_bluefruit/board.c @@ -28,6 +28,7 @@ #include "mpconfigboard.h" #include "py/obj.h" #include "peripherals/nrf/pins.h" +#include "supervisor/shared/board.h" #include "nrf_gpio.h" @@ -47,4 +48,6 @@ void reset_board(void) { NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE); nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false); + + board_reset_user_neopixels(); } diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index 7f9933b421..e401cecc16 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -54,6 +54,8 @@ // Disables onboard peripherals and neopixels to save power. #define POWER_SWITCH_PIN (&pin_P0_06) +#define USER_NEOPIXELS_PIN (&pin_P0_13) + #define DEFAULT_I2C_BUS_SCL (&pin_P0_04) #define DEFAULT_I2C_BUS_SDA (&pin_P0_05) diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index 3052e908dd..8495a359d7 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -102,7 +102,7 @@ uint32_t next_start_tick_us = 1000; void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) { // To support both the SoftDevice + Neopixels we use the EasyDMA - // feature from the NRF25. However this technique implies to + // feature from the NRF52. However this technique implies to // generate a pattern and store it on the memory. The actual // memory used in bytes corresponds to the following formula: // totalMem = numBytes*8*2+(2*2) @@ -113,22 +113,28 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // using DWT #define PATTERN_SIZE(numBytes) (numBytes * 8 * sizeof(uint16_t) + 2 * sizeof(uint16_t)) +// Allocate PWM space for up to STACK_PIXELS on the stack, to avoid malloc'ing. +// We may need to write to the status neopixel or to Circuit Playground NeoPixels +// when we cannot malloc, between VM instantiations. +// We need space for at least 10 pixels for Circuit Playground, but let's choose 24 +// to handle larger NeoPixel rings without malloc'ing. +#define STACK_PIXELS 24 uint32_t pattern_size = PATTERN_SIZE(numBytes); uint16_t* pixels_pattern = NULL; bool pattern_on_heap = false; - // Use the stack to store 1 pixels worth of PWM data for the status led. uint32_t to ensure alignment. - // Make it at least as big as PATTERN_SIZE(3), for one pixel of RGB data. + // Use the stack to store STACK_PIXEL's worth of PWM data. uint32_t to ensure alignment. + // It is 3*STACK_PIXELS to handle RGB. // PATTERN_SIZE is a multiple of 4, so we don't need round up to make sure one_pixel is large enough. - uint32_t one_pixel[PATTERN_SIZE(3)/sizeof(uint32_t)]; + uint32_t stack_pixels[PATTERN_SIZE(3 * STACK_PIXELS) / sizeof(uint32_t)]; NRF_PWM_Type* pwm = find_free_pwm(); // only malloc if there is PWM device available if ( pwm != NULL ) { - if (pattern_size <= sizeof(one_pixel)) { - pixels_pattern = (uint16_t *) one_pixel; + if (pattern_size <= sizeof(stack_pixels)) { + pixels_pattern = (uint16_t *) stack_pixels; } else { uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); diff --git a/supervisor/shared/board.c b/supervisor/shared/board.c new file mode 100644 index 0000000000..9e0f5a21e9 --- /dev/null +++ b/supervisor/shared/board.c @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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. + */ + +#include "supervisor/shared/board.h" + +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/neopixel_write/__init__.h" + +#ifdef USER_NEOPIXELS_PIN + +void board_reset_user_neopixels(void) { + // Turn off on-board NeoPixel string + uint8_t empty[30] = { 0 }; + digitalio_digitalinout_obj_t neopixel_pin; + common_hal_digitalio_digitalinout_construct(&neopixel_pin, USER_NEOPIXELS_PIN); + common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false, + DRIVE_MODE_PUSH_PULL); + common_hal_neopixel_write(&neopixel_pin, empty, 30); + common_hal_digitalio_digitalinout_deinit(&neopixel_pin); +} + +#endif diff --git a/supervisor/shared/board.h b/supervisor/shared/board.h new file mode 100644 index 0000000000..0e4d73455d --- /dev/null +++ b/supervisor/shared/board.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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. + */ + +#ifndef MICROPY_INCLUDED_SUPERVISOR_BOARD_H +#define MICROPY_INCLUDED_SUPERVISOR_BOARD_H + +#include "py/mpconfig.h" + +#ifdef USER_NEOPIXELS_PIN + +void board_reset_user_neopixels(void); + +#endif + +#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 96a14c25b4..52d60b52b3 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -2,6 +2,7 @@ SRC_SUPERVISOR = \ main.c \ supervisor/port.c \ supervisor/shared/autoreload.c \ + supervisor/shared/board.c \ supervisor/shared/display.c \ supervisor/shared/filesystem.c \ supervisor/shared/flash.c \ From 6f13979c9bed6f0810cfca9a9fd70cd9a196e6cd Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 24 Jan 2020 09:32:28 -0500 Subject: [PATCH 371/531] pygamer and pybadge boards were not resetting neopixels --- ports/atmel-samd/boards/pybadge/board.c | 2 ++ ports/atmel-samd/boards/pybadge/mpconfigboard.h | 2 ++ ports/atmel-samd/boards/pybadge_airlift/board.c | 2 ++ ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h | 2 ++ ports/atmel-samd/boards/pygamer/board.c | 2 ++ ports/atmel-samd/boards/pygamer/mpconfigboard.h | 2 ++ ports/atmel-samd/boards/pygamer_advance/board.c | 2 ++ ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h | 2 ++ supervisor/shared/board.c | 8 ++++++-- 9 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index 37f7991d15..f3ac7176ab 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -31,6 +31,7 @@ #include "shared-bindings/displayio/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" +#include "supervisor/shared/board.h" #include "tick.h" displayio_fourwire_obj_t board_display_obj; @@ -118,4 +119,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { + board_reset_user_neopixels(); } diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.h b/ports/atmel-samd/boards/pybadge/mpconfigboard.h index 435185322a..74a13eb1c2 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.h +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.h @@ -14,6 +14,8 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) +#define USER_NEOPIXELS_PIN (&pin_PA15) + #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/pybadge_airlift/board.c b/ports/atmel-samd/boards/pybadge_airlift/board.c index 7622de6f08..061f3d7772 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/board.c +++ b/ports/atmel-samd/boards/pybadge_airlift/board.c @@ -31,6 +31,7 @@ #include "shared-bindings/displayio/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" +#include "supervisor/shared/board.h" #include "tick.h" displayio_fourwire_obj_t board_display_obj; @@ -96,4 +97,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { + board_reset_user_neopixels(); } diff --git a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h index 229cfa3354..c6ab4ed8e0 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h +++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h @@ -14,6 +14,8 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) +#define USER_NEOPIXELS_PIN (&pin_PA15) + #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index b33ae4fb06..8c6fbca065 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -31,6 +31,7 @@ #include "shared-bindings/displayio/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" +#include "supervisor/shared/board.h" #include "tick.h" displayio_fourwire_obj_t board_display_obj; @@ -118,4 +119,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { + board_reset_user_neopixels(); } diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.h b/ports/atmel-samd/boards/pygamer/mpconfigboard.h index 102c259567..21f75d2728 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.h +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.h @@ -13,6 +13,8 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) +#define USER_NEOPIXELS_PIN (&pin_PA15) + #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/ports/atmel-samd/boards/pygamer_advance/board.c b/ports/atmel-samd/boards/pygamer_advance/board.c index 8eb501243f..ff2da34a26 100644 --- a/ports/atmel-samd/boards/pygamer_advance/board.c +++ b/ports/atmel-samd/boards/pygamer_advance/board.c @@ -31,6 +31,7 @@ #include "shared-bindings/displayio/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" +#include "supervisor/shared/board.h" #include "tick.h" displayio_fourwire_obj_t board_display_obj; @@ -96,4 +97,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { + board_reset_user_neopixels(); } diff --git a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h index fbe946b72f..7c631d1c37 100644 --- a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h +++ b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h @@ -13,6 +13,8 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) +#define USER_NEOPIXELS_PIN (&pin_PA15) + #define DEFAULT_I2C_BUS_SCL (&pin_PA13) #define DEFAULT_I2C_BUS_SDA (&pin_PA12) diff --git a/supervisor/shared/board.c b/supervisor/shared/board.c index 9e0f5a21e9..e3eb8fd0d7 100644 --- a/supervisor/shared/board.c +++ b/supervisor/shared/board.c @@ -31,14 +31,18 @@ #ifdef USER_NEOPIXELS_PIN +// The maximum number of user neopixels right now is 10, on Circuit Playgrounds. +// PyBadge and PyGamer have max 5 +#define USER_NEOPIXELS_MAX_COUNT 10 + void board_reset_user_neopixels(void) { // Turn off on-board NeoPixel string - uint8_t empty[30] = { 0 }; + uint8_t empty[USER_NEOPIXELS_MAX_COUNT * 3] = { 0 }; digitalio_digitalinout_obj_t neopixel_pin; common_hal_digitalio_digitalinout_construct(&neopixel_pin, USER_NEOPIXELS_PIN); common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false, DRIVE_MODE_PUSH_PULL); - common_hal_neopixel_write(&neopixel_pin, empty, 30); + common_hal_neopixel_write(&neopixel_pin, empty, USER_NEOPIXELS_MAX_COUNT * 3); common_hal_digitalio_digitalinout_deinit(&neopixel_pin); } From 2afca4e942df2f4aa656f6c8a6aa84de581682c9 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 24 Jan 2020 14:25:36 -0500 Subject: [PATCH 372/531] Fix flash-display conflict error --- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 1 + ports/stm32f4/common-hal/busio/SPI.c | 12 ++++++++++++ py/circuitpy_mpconfig.h | 1 + shared-bindings/board/__init__.h | 2 ++ shared-module/board/__init__.c | 11 +++++++++++ shared-module/displayio/__init__.c | 5 +++++ 6 files changed, 32 insertions(+) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 72d4f1c88e..bf738e9618 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -38,6 +38,7 @@ #define BOARD_OSC_DIV 12 #define BOARD_NO_VBUS_SENSE //#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader +#define SHOW_FLASH_SPI // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index afc6cfcbd5..e00b5e9f0c 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -428,31 +428,43 @@ STATIC void spi_clock_disable(uint8_t mask) { #ifdef SPI1 if (mask & (1 << 0)) { __HAL_RCC_SPI1_CLK_DISABLE(); + __HAL_RCC_SPI1_FORCE_RESET(); + __HAL_RCC_SPI1_RELEASE_RESET(); } #endif #ifdef SPI2 if (mask & (1 << 1)) { __HAL_RCC_SPI2_CLK_DISABLE(); + __HAL_RCC_SPI2_FORCE_RESET(); + __HAL_RCC_SPI2_RELEASE_RESET(); } #endif #ifdef SPI3 if (mask & (1 << 2)) { __HAL_RCC_SPI3_CLK_DISABLE(); + __HAL_RCC_SPI3_FORCE_RESET(); + __HAL_RCC_SPI3_RELEASE_RESET(); } #endif #ifdef SPI4 if (mask & (1 << 3)) { __HAL_RCC_SPI4_CLK_DISABLE(); + __HAL_RCC_SPI4_FORCE_RESET(); + __HAL_RCC_SPI4_RELEASE_RESET(); } #endif #ifdef SPI5 if (mask & (1 << 4)) { __HAL_RCC_SPI5_CLK_DISABLE(); + __HAL_RCC_SPI5_FORCE_RESET(); + __HAL_RCC_SPI5_RELEASE_RESET(); } #endif #ifdef SPI6 if (mask & (1 << 5)) { __HAL_RCC_SPI6_CLK_DISABLE(); + __HAL_RCC_SPI6_FORCE_RESET(); + __HAL_RCC_SPI6_RELEASE_RESET(); } #endif } diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 5b705a0883..b5d9bb9a80 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -296,6 +296,7 @@ extern const struct _mp_obj_module_t board_module; #define BOARD_I2C (defined(DEFAULT_I2C_BUS_SDA) && defined(DEFAULT_I2C_BUS_SCL)) #define BOARD_SPI (defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MISO) && defined(DEFAULT_SPI_BUS_MOSI)) #define BOARD_UART (defined(DEFAULT_UART_BUS_RX) && defined(DEFAULT_UART_BUS_TX)) +#define BOARD_INTERNAL_SPI (defined(SHOW_FLASH_SPI)) // I2C and SPI are always allocated off the heap. diff --git a/shared-bindings/board/__init__.h b/shared-bindings/board/__init__.h index a9b652ba8d..2842057ad6 100644 --- a/shared-bindings/board/__init__.h +++ b/shared-bindings/board/__init__.h @@ -37,6 +37,8 @@ mp_obj_t common_hal_board_get_i2c(void); mp_obj_t common_hal_board_create_i2c(void); MP_DECLARE_CONST_FUN_OBJ_0(board_i2c_obj); +mp_obj_t common_hal_board_get_internal_spi(void); + mp_obj_t common_hal_board_get_spi(void); mp_obj_t common_hal_board_create_spi(void); MP_DECLARE_CONST_FUN_OBJ_0(board_spi_obj); diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 914bc43137..8d87a98ebd 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -29,6 +29,8 @@ #include "mpconfigboard.h" #include "py/runtime.h" +#include "supervisor/spi_flash_api.h" + #if CIRCUITPY_BUSIO #include "shared-bindings/busio/I2C.h" #include "shared-bindings/busio/SPI.h" @@ -89,6 +91,15 @@ mp_obj_t common_hal_board_create_spi(void) { } #endif +#if BOARD_INTERNAL_SPI +//Provide a reference to the internal SPI, if required. +mp_obj_t common_hal_board_get_internal_spi(void) { + //TODO: can we change the name of this without having to change every instance of spi in every + //flash file? + return (mp_obj_t)(&spi); +} +#endif + #if BOARD_UART mp_obj_t common_hal_board_get_uart(void) { return MP_STATE_VM(shared_uart_bus); diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index af22cb0df8..795de7b87b 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -100,6 +100,11 @@ void reset_displays(void) { continue; } #endif + #if BOARD_INTERNAL_SPI + if (original_spi == common_hal_board_get_internal_spi()) { + continue; + } + #endif memcpy(&fourwire->inline_bus, original_spi, sizeof(busio_spi_obj_t)); fourwire->bus = &fourwire->inline_bus; // Check for other displays that use the same spi bus and swap them too. From 70932cab4223463816974e57945f6f803bbe7371 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 24 Jan 2020 14:33:28 -0500 Subject: [PATCH 373/531] Simplify the flash-display conflict fix --- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 2 +- py/circuitpy_mpconfig.h | 1 - shared-bindings/board/__init__.h | 2 -- shared-module/board/__init__.c | 11 ----------- shared-module/displayio/__init__.c | 7 +++++-- 5 files changed, 6 insertions(+), 17 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index bf738e9618..2d8ff87618 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -38,7 +38,7 @@ #define BOARD_OSC_DIV 12 #define BOARD_NO_VBUS_SENSE //#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader -#define SHOW_FLASH_SPI +#define BOARD_USE_INTERNAL_SPI // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index b5d9bb9a80..5b705a0883 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -296,7 +296,6 @@ extern const struct _mp_obj_module_t board_module; #define BOARD_I2C (defined(DEFAULT_I2C_BUS_SDA) && defined(DEFAULT_I2C_BUS_SCL)) #define BOARD_SPI (defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MISO) && defined(DEFAULT_SPI_BUS_MOSI)) #define BOARD_UART (defined(DEFAULT_UART_BUS_RX) && defined(DEFAULT_UART_BUS_TX)) -#define BOARD_INTERNAL_SPI (defined(SHOW_FLASH_SPI)) // I2C and SPI are always allocated off the heap. diff --git a/shared-bindings/board/__init__.h b/shared-bindings/board/__init__.h index 2842057ad6..a9b652ba8d 100644 --- a/shared-bindings/board/__init__.h +++ b/shared-bindings/board/__init__.h @@ -37,8 +37,6 @@ mp_obj_t common_hal_board_get_i2c(void); mp_obj_t common_hal_board_create_i2c(void); MP_DECLARE_CONST_FUN_OBJ_0(board_i2c_obj); -mp_obj_t common_hal_board_get_internal_spi(void); - mp_obj_t common_hal_board_get_spi(void); mp_obj_t common_hal_board_create_spi(void); MP_DECLARE_CONST_FUN_OBJ_0(board_spi_obj); diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 8d87a98ebd..914bc43137 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -29,8 +29,6 @@ #include "mpconfigboard.h" #include "py/runtime.h" -#include "supervisor/spi_flash_api.h" - #if CIRCUITPY_BUSIO #include "shared-bindings/busio/I2C.h" #include "shared-bindings/busio/SPI.h" @@ -91,15 +89,6 @@ mp_obj_t common_hal_board_create_spi(void) { } #endif -#if BOARD_INTERNAL_SPI -//Provide a reference to the internal SPI, if required. -mp_obj_t common_hal_board_get_internal_spi(void) { - //TODO: can we change the name of this without having to change every instance of spi in every - //flash file? - return (mp_obj_t)(&spi); -} -#endif - #if BOARD_UART mp_obj_t common_hal_board_get_uart(void) { return MP_STATE_VM(shared_uart_bus); diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 795de7b87b..8d9f148834 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -16,6 +16,9 @@ #include "supervisor/shared/display.h" #include "supervisor/memory.h" +#include "supervisor/spi_flash_api.h" +#include "py/mpconfig.h" + primary_display_t displays[CIRCUITPY_DISPLAY_LIMIT]; // Check for recursive calls to displayio_background. @@ -100,8 +103,8 @@ void reset_displays(void) { continue; } #endif - #if BOARD_INTERNAL_SPI - if (original_spi == common_hal_board_get_internal_spi()) { + #ifdef BOARD_USE_INTERNAL_SPI + if (original_spi == (mp_obj_t)(&spi)) { continue; } #endif From b5b94b72c1cef10de16d4c30761791238ce204da Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 24 Jan 2020 14:47:13 -0500 Subject: [PATCH 374/531] Return to bootloader options --- ports/stm32f4/Makefile | 2 +- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 2 +- ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 1b5b2eee24..ccadeac8a4 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -22,7 +22,7 @@ # 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. -DEBUG = 1 +# DEBUG = 1 # Select the board to build for. ifeq ($(BOARD),) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 2d8ff87618..c849e03b6c 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -37,7 +37,7 @@ #define BOARD_OSC_DIV 12 #define BOARD_NO_VBUS_SENSE -//#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader +#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader #define BOARD_USE_INTERNAL_SPI // On-board flash diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index e45d2803f7..340fd9d3b7 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -9,7 +9,7 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ LONGINT_IMPL = MPZ -# BOOTLOADER_OFFSET = 0x8010000 +BOOTLOADER_OFFSET = 0x8010000 # INTERNAL_FLASH_FILESYSTEM = 1 # LONGINT_IMPL = NONE @@ -19,5 +19,5 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -#LD_FILE = boards/STM32F401_boot.ld -LD_FILE = boards/STM32F401_fs.ld \ No newline at end of file +LD_FILE = boards/STM32F401_boot.ld +# LD_FILE = boards/STM32F401_fs.ld #use for internal flash \ No newline at end of file From 81c3bc411fadd41890d4e432a204a12d0750955b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 24 Jan 2020 18:22:28 -0800 Subject: [PATCH 375/531] Don't assume native methods want the native object as self. --- py/objtype.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/py/objtype.c b/py/objtype.c index a5e733208c..ad68b85d2a 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -187,14 +187,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_ return; } else { mp_obj_instance_t *obj = lookup->obj; - mp_obj_t obj_obj; - if (obj != NULL && mp_obj_is_native_type(type) && type != &mp_type_object /* object is not a real type */) { - // If we're dealing with native base class, then it applies to native sub-object - obj_obj = obj->subobj[0]; - } else { - obj_obj = MP_OBJ_FROM_PTR(obj); - } - mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest); + mp_convert_member_lookup(MP_OBJ_FROM_PTR(obj), type, elem->value, lookup->dest); } #if DEBUG_PRINT printf("mp_obj_class_lookup: Returning: "); From 39971794dd48b9dba0be389b22d4eae8ecd30f7d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 24 Jan 2020 18:23:07 -0800 Subject: [PATCH 376/531] Encapsulate buffers inside PixelBuf and refactor it. --- shared-bindings/_pixelbuf/PixelBuf.c | 327 +++++++++++---------------- shared-bindings/_pixelbuf/PixelBuf.h | 35 ++- shared-bindings/_pixelbuf/__init__.c | 35 +-- shared-bindings/_pixelbuf/__init__.h | 1 - shared-bindings/_pixelbuf/types.h | 47 ---- shared-module/_pixelbuf/PixelBuf.c | 297 ++++++++++++++++++------ shared-module/_pixelbuf/PixelBuf.h | 37 ++- 7 files changed, 406 insertions(+), 373 deletions(-) delete mode 100644 shared-bindings/_pixelbuf/types.h diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 3e93190470..61b4c9ae09 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -36,13 +36,14 @@ #include -#include "PixelBuf.h" -#include "shared-bindings/_pixelbuf/types.h" -#include "../../shared-module/_pixelbuf/PixelBuf.h" +#include "shared-bindings/_pixelbuf/PixelBuf.h" +#include "shared-module/_pixelbuf/PixelBuf.h" #include "shared-bindings/digitalio/DigitalInOut.h" extern const int32_t colorwheel(float pos); +static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed); + //| .. currentmodule:: pixelbuf //| //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices @@ -50,140 +51,109 @@ extern const int32_t colorwheel(float pos); //| //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction. //| -//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False) +//| .. class:: PixelBuf(size, *, byteorder="BGR", brightness=0, auto_write=False, header=b"", trailer=b"") //| //| Create a PixelBuf object of the specified size, byteorder, and bits per pixel. //| -//| When given a second bytearray (``rawbuf``), changing brightness adjusts the -//| brightness of all members of ``buf``. +//| When brightness is less than 1.0, a second buffer will be used to store the color values +//| before they are adjusted for brightness. //| -//| When only given ``buf``, ``brightness`` applies to the next pixel assignment. -//| -//| When ``P`` (pwm duration) is present as the 4th character of the byteorder -//| string, the 4th value in the tuple/list for a pixel is the individual pixel +//| When ``P`` (pwm duration) is present as the 4th character of the byteorder +//| string, the 4th value in the tuple/list for a pixel is the individual pixel //| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the //| output buffer (``buf``). //| //| :param ~int size: Number of pixelsx -//| :param ~bytearray buf: Bytearray in which to store pixel data //| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) -//| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) -//| :param ~int offset: Offset from start of buffer (default 0) //| :param ~bool auto_write: Whether to automatically write pixels (Default False) +//| :param bytes header: Sequence of bytes to always send before pixel values. +//| :param bytes trailer: Sequence of bytes to always send after pixel values. //| STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 2, MP_OBJ_FUN_ARGS_MAX, true); - enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, - ARG_auto_write }; + mp_arg_check_num(n_args, kw_args, 1, MP_OBJ_FUN_ARGS_MAX, true); + enum { ARG_size, ARG_byteorder, ARG_brightness, ARG_auto_write, ARG_header, ARG_trailer }; static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, - { MP_QSTR_buf, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_byteorder, MP_ARG_OBJ, { .u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_BGR) } }, - { MP_QSTR_brightness, MP_ARG_OBJ, { .u_obj = mp_const_none } }, - { MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } }, - { MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } }, - { MP_QSTR_auto_write, MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_byteorder, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_BGR) } }, + { MP_QSTR_brightness, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, + { MP_QSTR_auto_write, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_header, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, + { MP_QSTR_trailer, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const char *byteorder = NULL; pixelbuf_byteorder_details_t byteorder_details; - size_t bo_len; - if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj)) + parse_byteorder(args[ARG_byteorder].u_obj, &byteorder_details); + + mp_buffer_info_t header_bufinfo; + mp_buffer_info_t trailer_bufinfo; + + if (!mp_get_buffer(args[ARG_header].u_obj, &header_bufinfo, MP_BUFFER_READ)) { + header_bufinfo.buf = NULL; + header_bufinfo.len = 0; + } + if (!mp_get_buffer(args[ARG_trailer].u_obj, &trailer_bufinfo, MP_BUFFER_READ)) { + trailer_bufinfo.buf = NULL; + trailer_bufinfo.len = 0; + } + + float brightness = 1.0; + if (args[ARG_brightness].u_obj != mp_const_none) { + brightness = mp_obj_get_float(args[ARG_brightness].u_obj); + if (brightness < 0) { + brightness = 0; + } else if (brightness > 1) { + brightness = 1; + } + } + + // Validation complete, allocate and populate object. + pixelbuf_pixelbuf_obj_t *self = m_new_obj(pixelbuf_pixelbuf_obj_t); + self->base.type = &pixelbuf_pixelbuf_type; + common_hal__pixelbuf_pixelbuf_construct(self, args[ARG_size].u_int, + &byteorder_details, brightness, args[ARG_auto_write].u_bool, header_bufinfo.buf, + header_bufinfo.len, trailer_bufinfo.buf, trailer_bufinfo.len); + + return MP_OBJ_FROM_PTR(self); +} + +static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed) { + if (!MP_OBJ_IS_STR(byteorder_obj)) { mp_raise_TypeError(translate("byteorder is not a string")); + } - byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); - if (bo_len < 3 || bo_len > 4) + size_t bo_len; + const char *byteorder = mp_obj_str_get_data(byteorder_obj, &bo_len); + if (bo_len < 3 || bo_len > 4) { mp_raise_ValueError(translate("Invalid byteorder string")); - byteorder_details.order = args[ARG_byteorder].u_obj; + } + parsed->order_string = byteorder_obj; - byteorder_details.bpp = bo_len; + parsed->bpp = bo_len; char *dotstar = strchr(byteorder, 'P'); char *r = strchr(byteorder, 'R'); char *g = strchr(byteorder, 'G'); char *b = strchr(byteorder, 'B'); char *w = strchr(byteorder, 'W'); int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); - if ((num_chars < byteorder_details.bpp) || !(r && b && g)) + if ((num_chars < parsed->bpp) || !(r && b && g)) { mp_raise_ValueError(translate("Invalid byteorder string")); - byteorder_details.is_dotstar = dotstar ? true : false; - byteorder_details.has_white = w ? true : false; - byteorder_details.byteorder.r = r - byteorder; - byteorder_details.byteorder.g = g - byteorder; - byteorder_details.byteorder.b = b - byteorder; - byteorder_details.byteorder.w = w ? w - byteorder : 0; + } + parsed->is_dotstar = dotstar ? true : false; + parsed->has_white = w ? true : false; + parsed->byteorder.r = r - byteorder; + parsed->byteorder.g = g - byteorder; + parsed->byteorder.b = b - byteorder; + parsed->byteorder.w = w ? w - byteorder : 0; // The dotstar brightness byte is always first (as it goes with the pixel start bits) if (dotstar && byteorder[0] != 'P') { mp_raise_ValueError(translate("Invalid byteorder string")); } - if (byteorder_details.has_white && byteorder_details.is_dotstar) + if (parsed->has_white && parsed->is_dotstar) { mp_raise_ValueError(translate("Invalid byteorder string")); - - size_t effective_bpp = byteorder_details.is_dotstar ? 4 : byteorder_details.bpp; // Always 4 for DotStar - size_t bytes = args[ARG_size].u_int * effective_bpp; - size_t offset = args[ARG_offset].u_int; - mp_buffer_info_t bufinfo, rawbufinfo; - - mp_get_buffer_raise(args[ARG_buf].u_obj, &bufinfo, MP_BUFFER_READ | MP_BUFFER_WRITE); - bool two_buffers = args[ARG_rawbuf].u_obj != mp_const_none; - if (two_buffers) { - mp_get_buffer_raise(args[ARG_rawbuf].u_obj, &rawbufinfo, MP_BUFFER_READ | MP_BUFFER_WRITE); - if (rawbufinfo.len != bufinfo.len) { - mp_raise_ValueError(translate("rawbuf is not the same size as buf")); - } } - - if (bytes + offset > bufinfo.len) - mp_raise_ValueError_varg(translate("buf is too small. need %d bytes"), bytes + offset); - - // Validation complete, allocate and populate object. - pixelbuf_pixelbuf_obj_t *self = m_new_obj(pixelbuf_pixelbuf_obj_t); - - self->base.type = &pixelbuf_pixelbuf_type; - self->pixels = args[ARG_size].u_int; - self->bytes = bytes; - self->byteorder = byteorder_details; // Copied because we modify for dotstar - self->bytearray = args[ARG_buf].u_obj; - self->two_buffers = two_buffers; - self->rawbytearray = two_buffers ? args[ARG_rawbuf].u_obj : NULL; - self->offset = offset; - self->buf = (uint8_t *)bufinfo.buf + offset; - self->rawbuf = two_buffers ? (uint8_t *)rawbufinfo.buf + offset : NULL; - self->pixel_step = effective_bpp; - self->auto_write = args[ARG_auto_write].u_bool; - - if (args[ARG_brightness].u_obj == mp_const_none) { - self->brightness = 1.0; - } else { - self->brightness = mp_obj_get_float(args[ARG_brightness].u_obj); - if (self->brightness < 0) - self->brightness = 0; - else if (self->brightness > 1) - self->brightness = 1; - } - - if (self->byteorder.is_dotstar) { - // Initialize the buffer with the dotstar start bytes. - // Note: Header and end must be setup by caller - for (uint i = 0; i < self->pixels * 4; i += 4) { - self->buf[i] = DOTSTAR_LED_START_FULL_BRIGHT; - if (two_buffers) { - self->rawbuf[i] = DOTSTAR_LED_START_FULL_BRIGHT; - } - } - } - - return MP_OBJ_FROM_PTR(self); -} - - -// Helper to ensure we have the native super class instead of a subclass. -static pixelbuf_pixelbuf_obj_t* native_pixelbuf(mp_obj_t pixelbuf_obj) { - mp_obj_t native_pixelbuf = mp_instance_cast_to_native_base(pixelbuf_obj, &pixelbuf_pixelbuf_type); - mp_obj_assert_native_inited(native_pixelbuf); - return MP_OBJ_TO_PTR(native_pixelbuf); } //| .. attribute:: bpp @@ -191,8 +161,7 @@ static pixelbuf_pixelbuf_obj_t* native_pixelbuf(mp_obj_t pixelbuf_obj) { //| The number of bytes per pixel in the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return mp_obj_new_int_from_uint(self->byteorder.bpp); + return MP_OBJ_NEW_SMALL_INT(common_hal__pixelbuf_pixelbuf_get_bpp(self_in)); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_bpp_obj, pixelbuf_pixelbuf_obj_get_bpp); @@ -207,30 +176,24 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = { //| .. attribute:: brightness //| //| Float value between 0 and 1. Output brightness. -//| If the PixelBuf was allocated with two both a buf and a rawbuf, -//| setting this value causes a recomputation of the values in buf. -//| If only a buf was provided, then the brightness only applies to -//| future pixel changes. -//| In DotStar mode +//| +//| When brightness is less than 1.0, a second buffer will be used to store the color values +//| before they are adjusted for brightness. //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness(mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return mp_obj_new_float(self->brightness); + return mp_obj_new_float(common_hal__pixelbuf_pixelbuf_get_brightness(self_in)); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_brightness_obj, pixelbuf_pixelbuf_obj_get_brightness); STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t value) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - self->brightness = mp_obj_float_get(value); - if (self->brightness > 1) - self->brightness = 1; - else if (self->brightness < 0) - self->brightness = 0; - if (self->two_buffers) - pixelbuf_recalculate_brightness(self); - if (self->auto_write) - pixelbuf_call_show(self_in); + mp_float_t brightness = mp_obj_float_get(value); + if (brightness > 1) { + brightness = 1; + } else if (brightness < 0) { + brightness = 0; + } + common_hal__pixelbuf_pixelbuf_set_brightness(self_in, brightness); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -242,37 +205,18 @@ const mp_obj_property_t pixelbuf_pixelbuf_brightness_obj = { (mp_obj_t)&mp_const_none_obj}, }; -void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { - uint8_t *buf = (uint8_t *)self->buf; - uint8_t *rawbuf = (uint8_t *)self->rawbuf; - // Compensate for shifted buffer (bpp=3 dotstar) - for (uint i = 0; i < self->bytes; i++) { - // Don't adjust per-pixel luminance bytes in dotstar mode - if (!self->byteorder.is_dotstar || (i % 4 != 0)) - buf[i] = rawbuf[i] * self->brightness; - } -} - -mp_obj_t pixelbuf_call_show(mp_obj_t self_in) { - mp_obj_t dest[2]; - mp_load_method(self_in, MP_QSTR_show, dest); - return mp_call_method_n_kw(0, 0, dest); -} - //| .. attribute:: auto_write //| //| Whether to automatically write the pixels after each update. //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write(mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return mp_obj_new_bool(self->auto_write); + return mp_obj_new_bool(common_hal__pixelbuf_pixelbuf_get_auto_write(self_in)); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_auto_write_obj, pixelbuf_pixelbuf_obj_get_auto_write); STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_auto_write(mp_obj_t self_in, mp_obj_t value) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - self->auto_write = mp_obj_is_true(value); + common_hal__pixelbuf_pixelbuf_set_auto_write(self_in, mp_obj_is_true(value)); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_auto_write_obj, pixelbuf_pixelbuf_obj_set_auto_write); @@ -284,33 +228,12 @@ const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = { (mp_obj_t)&mp_const_none_obj}, }; - -//| .. attribute:: buf -//| -//| (read-only) bytearray of pixel data after brightness adjustment. If an offset was provided -//| then this bytearray is the subset of the bytearray passed in that represents the -//| actual pixels. -//| -STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_buf(mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return mp_obj_new_bytearray_by_ref(self->bytes, self->buf); -} -MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_buf_obj, pixelbuf_pixelbuf_obj_get_buf); - -const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_buf_obj, - (mp_obj_t)&mp_const_none_obj, - (mp_obj_t)&mp_const_none_obj}, -}; - //| .. attribute:: byteorder //| //| byteorder string for the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return self->byteorder.order; + return common_hal__pixelbuf_pixelbuf_get_byteorder_string(self_in); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); @@ -322,32 +245,49 @@ const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { }; STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); switch (op) { case MP_UNARY_OP_BOOL: return mp_const_true; - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->pixels); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(common_hal__pixelbuf_pixelbuf_get_len(self_in)); default: return MP_OBJ_NULL; // op not supported } } //| .. method:: show() //| -//| Must be implemented in subclasses. +//| Transmits the color data to the pixels so that they are shown. This is done automatically +//| when `auto_write` is True. //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { - mp_raise_NotImplementedError(NULL); + common_hal__pixelbuf_pixelbuf_show(self_in); + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); +//| .. function:: fill(color) +//| +//| Fills the given pixelbuf with the given color. +//| + +STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { + common_hal__pixelbuf_pixelbuf_fill(self_in, value); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); + //| .. method:: __getitem__(index) //| -//| Returns the pixel value at the given index. +//| Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values +//| between 0 and 255. //| //| .. method:: __setitem__(index, value) //| -//| Sets the pixel value at the given index. +//| Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue +//| [, White]) values between 0 and 255 or an integer where the red, green and blue values are +//| packed into the lower three bytes (0xRRGGBB). //| STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { @@ -356,32 +296,34 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp return MP_OBJ_NULL; // op not supported } - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - if (0) { #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; - mp_seq_get_fast_slice_indexes(self->pixels, index_in, &slice); + size_t length = common_hal__pixelbuf_pixelbuf_get_len(self_in); + mp_seq_get_fast_slice_indexes(length, index_in, &slice); - if ((slice.stop * self->pixel_step) > self->bytes) - mp_raise_IndexError(translate("Range out of bounds")); - if (slice.step < 0) + if (slice.step < 0) { mp_raise_IndexError(translate("Negative step not supported")); + } if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; if (slice.step > 1) { len = (len / slice.step) + (len % slice.step ? 1 : 0); } - uint8_t *readbuf = self->two_buffers ? self->rawbuf : self->buf; - return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, slice.step, self->byteorder.is_dotstar); + mp_obj_tuple_t* t = MP_OBJ_TO_PTR(mp_obj_new_tuple(len, NULL)); + for (uint i = 0; i < len; i++) { + t->items[i] = common_hal__pixelbuf_pixelbuf_get_pixel(self_in, i * slice.step); + } + return MP_OBJ_FROM_PTR(t); } else { // Set #if MICROPY_PY_ARRAY_SLICE_ASSIGN - if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) + if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) { mp_raise_ValueError(translate("tuple/list required on RHS")); + } size_t dst_len = (slice.stop - slice.start); if (slice.step > 1) { @@ -398,21 +340,12 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp num_items = l->len; src_objs = l->items; } - if (num_items != dst_len) + if (num_items != dst_len) { mp_raise_ValueError_varg(translate("Unmatched number of items on RHS (expected %d, got %d)."), dst_len, num_items); - - size_t target_i = slice.start; - for (size_t i = slice.start; target_i < slice.stop; i++, target_i += slice.step) { - mp_obj_t *item = src_objs[i-slice.start]; - if (MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple) || MP_OBJ_IS_INT(value)) { - pixelbuf_set_pixel(self->buf + (target_i * self->pixel_step), - self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL, - self->brightness, item, &self->byteorder, self->byteorder.is_dotstar); - } } - if (self->auto_write) - pixelbuf_call_show(self_in); + + common_hal__pixelbuf_pixelbuf_set_pixels(self_in, slice.start, slice.stop, slice.step, src_objs); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -420,19 +353,13 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } #endif } else { // Single index rather than slice. - size_t index = mp_get_index(self->base.type, self->pixels, index_in, false); - size_t offset = (index * self->pixel_step); - if (offset > self->bytes) - mp_raise_IndexError(translate("Pixel beyond bounds of buffer")); + size_t length = common_hal__pixelbuf_pixelbuf_get_len(self_in); + size_t index = mp_get_index(mp_obj_get_type(self_in), length, index_in, false); if (value == MP_OBJ_SENTINEL) { // Get - uint8_t *pixelstart = (uint8_t *)(self->two_buffers ? self->rawbuf : self->buf) + offset; - return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->byteorder.is_dotstar); + return common_hal__pixelbuf_pixelbuf_get_pixel(self_in, index); } else { // Store - pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, - self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); - if (self->auto_write) - pixelbuf_call_show(self_in); + common_hal__pixelbuf_pixelbuf_set_pixel(self_in, index, value); return mp_const_none; } } @@ -442,9 +369,9 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_auto_write), MP_ROM_PTR(&pixelbuf_pixelbuf_auto_write_obj)}, { MP_ROM_QSTR(MP_QSTR_bpp), MP_ROM_PTR(&pixelbuf_pixelbuf_bpp_obj)}, { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&pixelbuf_pixelbuf_brightness_obj)}, - { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, + { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_pixelbuf_fill_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_locals_dict_table); diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 691da3cd33..68d6d4eefc 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -27,27 +27,26 @@ #ifndef CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H #define CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H -#include "shared-bindings/_pixelbuf/types.h" +#include "shared-module/_pixelbuf/PixelBuf.h" const mp_obj_type_t pixelbuf_pixelbuf_type; -typedef struct { - mp_obj_base_t base; - size_t pixels; - size_t bytes; - size_t pixel_step; - pixelbuf_byteorder_details_t byteorder; - mp_obj_t bytearray; - mp_obj_t rawbytearray; - mp_float_t brightness; - bool two_buffers; - size_t offset; - uint8_t *rawbuf; - uint8_t *buf; - bool auto_write; -} pixelbuf_pixelbuf_obj_t; +void common_hal__pixelbuf_pixelbuf_construct(pixelbuf_pixelbuf_obj_t *self, size_t n, + pixelbuf_byteorder_details_t* byteorder, mp_float_t brightness, bool auto_write, uint8_t* header, + size_t header_len, uint8_t* trailer, size_t trailer_len); -void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -mp_obj_t pixelbuf_call_show(mp_obj_t self_in); +// These take mp_obj_t because they are called on subclasses of PixelBuf. +uint8_t common_hal__pixelbuf_pixelbuf_get_bpp(mp_obj_t self); +mp_float_t common_hal__pixelbuf_pixelbuf_get_brightness(mp_obj_t self); +void common_hal__pixelbuf_pixelbuf_set_brightness(mp_obj_t self, mp_float_t brightness); +bool common_hal__pixelbuf_pixelbuf_get_auto_write(mp_obj_t self); +void common_hal__pixelbuf_pixelbuf_set_auto_write(mp_obj_t self, bool auto_write); +size_t common_hal__pixelbuf_pixelbuf_get_len(mp_obj_t self_in); +mp_obj_t common_hal__pixelbuf_pixelbuf_get_byteorder_string(mp_obj_t self); +void common_hal__pixelbuf_pixelbuf_fill(mp_obj_t self, mp_obj_t item); +void common_hal__pixelbuf_pixelbuf_show(mp_obj_t self); +mp_obj_t common_hal__pixelbuf_pixelbuf_get_pixel(mp_obj_t self, size_t index); +void common_hal__pixelbuf_pixelbuf_set_pixel(mp_obj_t self, size_t index, mp_obj_t item); +void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, size_t stop, size_t step, mp_obj_t* values); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index ed264f3bb4..424ed23e4c 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -29,11 +29,8 @@ #include "py/runtime.h" #include "py/objproperty.h" -#include "types.h" -#include "__init__.h" - -#include "PixelBuf.h" -#include "../../shared-module/_pixelbuf/PixelBuf.h" +#include "shared-bindings/_pixelbuf/__init__.h" +#include "shared-bindings/_pixelbuf/PixelBuf.h" //| :mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers @@ -82,39 +79,15 @@ const int32_t colorwheel(float pos) { } } - -//| .. function:: fill(pixelbuf, color) -//| -//| Fills the given pixelbuf with the given color. -//| - -STATIC mp_obj_t pixelbuf_fill(mp_obj_t pixelbuf_in, mp_obj_t value) { - mp_obj_t obj = mp_instance_cast_to_native_base(pixelbuf_in, &pixelbuf_pixelbuf_type); - if (obj == MP_OBJ_NULL) - mp_raise_TypeError(translate("Expected a PixelBuf instance")); - pixelbuf_pixelbuf_obj_t *pixelbuf = MP_OBJ_TO_PTR(obj); - - for (size_t offset = 0; offset < pixelbuf->bytes; offset+= pixelbuf->pixel_step) { - pixelbuf_set_pixel(pixelbuf->buf + offset, pixelbuf->two_buffers ? (pixelbuf->rawbuf + offset) : NULL, - pixelbuf->brightness, value, &pixelbuf->byteorder, pixelbuf->byteorder.is_dotstar); - } - if (pixelbuf->auto_write) - pixelbuf_call_show(pixelbuf_in); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_fill_obj, pixelbuf_fill); - - STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, - { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_fill_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table); const mp_obj_module_t pixelbuf_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&pixelbuf_module_globals, + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&pixelbuf_module_globals, }; diff --git a/shared-bindings/_pixelbuf/__init__.h b/shared-bindings/_pixelbuf/__init__.h index f70ffe5083..0e8c4a37f9 100644 --- a/shared-bindings/_pixelbuf/__init__.h +++ b/shared-bindings/_pixelbuf/__init__.h @@ -30,6 +30,5 @@ #include "common-hal/digitalio/DigitalInOut.h" const int32_t colorwheel(float pos); -extern void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* gpio, uint8_t *pixels, uint32_t numBytes); #endif //CP_SHARED_BINDINGS_PIXELBUF_INIT_H diff --git a/shared-bindings/_pixelbuf/types.h b/shared-bindings/_pixelbuf/types.h deleted file mode 100644 index f7dc1a1092..0000000000 --- a/shared-bindings/_pixelbuf/types.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the Circuit Python project, https://github.com/adafruit/circuitpython - * - * The MIT License (MIT) - * - * Copyright (c) 2018 Roy Hooper - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef CIRCUITPYTHON_PIXELBUF_TYPES_H -#define CIRCUITPYTHON_PIXELBUF_TYPES_H - -//| :orphan: - -typedef struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t w; -} pixelbuf_rgbw_t; - -typedef struct { - uint8_t bpp; - pixelbuf_rgbw_t byteorder; - bool has_white; - bool is_dotstar; - mp_obj_t *order; -} pixelbuf_byteorder_details_t; - -#endif // CIRCUITPYTHON_PIXELBUF_TYPES_H diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index 020151bc31..ab5bcb4417 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -26,95 +26,256 @@ #include "py/obj.h" -#include "py/objarray.h" +#include "py/objstr.h" +#include "py/objtype.h" #include "py/runtime.h" -#include "PixelBuf.h" +#include "shared-bindings/_pixelbuf/PixelBuf.h" #include -void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder) { - buf[byteorder->byteorder.r] = value >> 16 & 0xff; - buf[byteorder->byteorder.g] = (value >> 8) & 0xff; - buf[byteorder->byteorder.b] = value & 0xff; - if (byteorder->bpp == 4 && byteorder->has_white && - (buf[byteorder->byteorder.r] == buf[byteorder->byteorder.g] && - buf[byteorder->byteorder.r] == buf[byteorder->byteorder.b])) { - buf[byteorder->byteorder.w] = buf[byteorder->byteorder.r]; - buf[byteorder->byteorder.r] = buf[byteorder->byteorder.g] = buf[byteorder->byteorder.b] = 0; +// Helper to ensure we have the native super class instead of a subclass. +static pixelbuf_pixelbuf_obj_t* native_pixelbuf(mp_obj_t pixelbuf_obj) { + mp_obj_t native_pixelbuf = mp_instance_cast_to_native_base(pixelbuf_obj, &pixelbuf_pixelbuf_type); + mp_obj_assert_native_inited(native_pixelbuf); + return MP_OBJ_TO_PTR(native_pixelbuf); +} + +void common_hal__pixelbuf_pixelbuf_construct(pixelbuf_pixelbuf_obj_t *self, size_t n, + pixelbuf_byteorder_details_t* byteorder, mp_float_t brightness, bool auto_write, + uint8_t* header, size_t header_len, uint8_t* trailer, size_t trailer_len) { + + self->pixel_count = n; + self->byteorder = *byteorder; // Copied because we modify for dotstar + self->bytes_per_pixel = byteorder->is_dotstar ? 4 : byteorder->bpp; + self->auto_write = false; + + size_t pixel_len = self->pixel_count * self->bytes_per_pixel; + self->transmit_buffer_obj = mp_obj_new_bytes_of_zeros(header_len + pixel_len + trailer_len); + mp_obj_str_t *o = MP_OBJ_TO_PTR(self->transmit_buffer_obj); + + // Abuse the bytes object a bit by mutating it's data by dropping the const. If the user's + // Python code holds onto it, they'll find out that it changes. At least this way it isn't + // mutable by the code itself. + uint8_t* transmit_buffer = (uint8_t*) o->data; + memcpy(transmit_buffer, header, header_len); + memcpy(transmit_buffer + header_len + pixel_len, trailer, trailer_len); + self->post_brightness_buffer = transmit_buffer + header_len; + + if (self->byteorder.is_dotstar) { + // Initialize the buffer with the dotstar start bytes. + // Note: Header and end must be setup by caller + for (uint i = 0; i < self->pixel_count * 4; i += 4) { + self->post_brightness_buffer[i] = DOTSTAR_LED_START_FULL_BRIGHT; + } + } + // Call set_brightness so that it can allocate a second buffer if needed. + common_hal__pixelbuf_pixelbuf_set_brightness(MP_OBJ_FROM_PTR(self), brightness); + + // Turn on auto_write. We don't want to do it with the above brightness call. + self->auto_write = auto_write; +} + +size_t common_hal__pixelbuf_pixelbuf_get_len(mp_obj_t self_in) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + return self->pixel_count; +} + +uint8_t common_hal__pixelbuf_pixelbuf_get_bpp(mp_obj_t self_in) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + return self->byteorder.bpp; +} + +mp_obj_t common_hal__pixelbuf_pixelbuf_get_byteorder_string(mp_obj_t self_in) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + return self->byteorder.order_string; +} + +bool common_hal__pixelbuf_pixelbuf_get_auto_write(mp_obj_t self_in) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + return self->auto_write; +} + +void common_hal__pixelbuf_pixelbuf_set_auto_write(mp_obj_t self_in, bool auto_write) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + self->auto_write = auto_write; +} + +mp_float_t common_hal__pixelbuf_pixelbuf_get_brightness(mp_obj_t self_in) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + return self->brightness; +} + +void common_hal__pixelbuf_pixelbuf_set_brightness(mp_obj_t self_in, mp_float_t brightness) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + self->brightness = brightness; + size_t pixel_len = self->pixel_count * self->bytes_per_pixel; + if (self->pre_brightness_buffer == NULL) { + self->pre_brightness_buffer = m_malloc(pixel_len, false); + memcpy(self->pre_brightness_buffer, self->post_brightness_buffer, pixel_len); + } + for (size_t i = 0; i < pixel_len; i++) { + // Don't adjust per-pixel luminance bytes in dotstar mode + if (self->byteorder.is_dotstar && i % 4 == 0) { + continue; + } + self->post_brightness_buffer[i] = self->pre_brightness_buffer[i] * self->brightness; + } + + if (self->auto_write) { + common_hal__pixelbuf_pixelbuf_show(self_in); } } -void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar) { - if (MP_OBJ_IS_INT(item)) { - uint8_t *target = rawbuf ? rawbuf : buf; - pixelbuf_set_pixel_int(target, mp_obj_get_int_truncated(item), byteorder); - if (dotstar) { - buf[0] = DOTSTAR_LED_START_FULL_BRIGHT; - if (rawbuf) - rawbuf[0] = DOTSTAR_LED_START_FULL_BRIGHT; - } - if (rawbuf) { - buf[byteorder->byteorder.r] = rawbuf[byteorder->byteorder.r] * brightness; - buf[byteorder->byteorder.g] = rawbuf[byteorder->byteorder.g] * brightness; - buf[byteorder->byteorder.b] = rawbuf[byteorder->byteorder.b] * brightness; - } else { - buf[byteorder->byteorder.r] *= brightness; - buf[byteorder->byteorder.g] *= brightness; - buf[byteorder->byteorder.b] *= brightness; +void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t* self, mp_obj_t color, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* w) { + pixelbuf_byteorder_details_t *byteorder = &self->byteorder; + // w is shared between white in NeoPixels and brightness in dotstars (so that DotStars can have + // per-pixel brightness). Set the defaults here in case it isn't set below. + if (byteorder->is_dotstar) { + *w = 255; + } else { + *w = 0; + } + + if (MP_OBJ_IS_INT(color)) { + mp_int_t value = mp_obj_get_int_truncated(color); + *r = value >> 16 & 0xff; + *g = (value >> 8) & 0xff; + *b = value & 0xff; + // Int colors can't set white directly so convert to white when all components are equal. + if (!byteorder->is_dotstar && byteorder->bpp == 4 && byteorder->has_white && *r == *g && *r == *b) { + *w = *r; + *r = 0; + *g = 0; + *b = 0; } } else { mp_obj_t *items; size_t len; - mp_obj_get_array(item, &len, &items); - if (len != byteorder->bpp && !dotstar) + mp_obj_get_array(color, &len, &items); + if (len != byteorder->bpp && !byteorder->is_dotstar) { mp_raise_ValueError_varg(translate("Expected tuple of length %d, got %d"), byteorder->bpp, len); - - buf[byteorder->byteorder.r] = mp_obj_get_int_truncated(items[PIXEL_R]) * brightness; - buf[byteorder->byteorder.g] = mp_obj_get_int_truncated(items[PIXEL_G]) * brightness; - buf[byteorder->byteorder.b] = mp_obj_get_int_truncated(items[PIXEL_B]) * brightness; - if (rawbuf) { - rawbuf[byteorder->byteorder.r] = mp_obj_get_int_truncated(items[PIXEL_R]); - rawbuf[byteorder->byteorder.g] = mp_obj_get_int_truncated(items[PIXEL_G]); - rawbuf[byteorder->byteorder.b] = mp_obj_get_int_truncated(items[PIXEL_B]); } + + *r = mp_obj_get_int_truncated(items[PIXEL_R]); + *g = mp_obj_get_int_truncated(items[PIXEL_G]); + *b = mp_obj_get_int_truncated(items[PIXEL_B]); if (len > 3) { - if (dotstar) { - buf[byteorder->byteorder.w] = DOTSTAR_LED_START | DOTSTAR_BRIGHTNESS(mp_obj_get_float(items[PIXEL_W])); - if (rawbuf) - rawbuf[byteorder->byteorder.w] = buf[byteorder->byteorder.w]; + if (mp_obj_is_float(items[PIXEL_W])) { + *w = 255 * mp_obj_get_float(items[PIXEL_W]); } else { - buf[byteorder->byteorder.w] = mp_obj_get_int_truncated(items[PIXEL_W]) * brightness; - if (rawbuf) - rawbuf[byteorder->byteorder.w] = mp_obj_get_int_truncated(items[PIXEL_W]); + *w = mp_obj_get_int_truncated(items[PIXEL_W]); } - } else if (dotstar) { - buf[byteorder->byteorder.w] = DOTSTAR_LED_START_FULL_BRIGHT; - if (rawbuf) - rawbuf[byteorder->byteorder.w] = DOTSTAR_LED_START_FULL_BRIGHT; } } } -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar) { - mp_obj_t elems[len]; - for (uint i = 0; i < len; i++) { - elems[i] = pixelbuf_get_pixel(buf + ((i * slice_step) * step), byteorder, dotstar); +void _pixelbuf_set_pixel_color(pixelbuf_pixelbuf_obj_t* self, size_t index, uint8_t r, uint8_t g, uint8_t b, uint8_t w) { + // DotStars don't have white, instead they have 5 bit brightness so pack it into w. Shift right + // by three to leave the top five bits. + if (self->bytes_per_pixel == 4 && self->byteorder.is_dotstar) { + w = DOTSTAR_LED_START | w >> 3; } - return mp_obj_new_tuple(len, elems); -} + pixelbuf_rgbw_t *rgbw_order = &self->byteorder.byteorder; + size_t offset = index * self->bytes_per_pixel; + if (self->pre_brightness_buffer != NULL) { + uint8_t* pre_brightness_buffer = self->pre_brightness_buffer + offset; + if (self->bytes_per_pixel == 4) { + pre_brightness_buffer[rgbw_order->w] = w; + } -mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar) { - mp_obj_t elems[byteorder->bpp]; - - elems[0] = mp_obj_new_int(buf[byteorder->byteorder.r]); - elems[1] = mp_obj_new_int(buf[byteorder->byteorder.g]); - elems[2] = mp_obj_new_int(buf[byteorder->byteorder.b]); - if (byteorder->bpp > 3) - { - if (dotstar) - elems[3] = mp_obj_new_float(DOTSTAR_GET_BRIGHTNESS(buf[byteorder->byteorder.w])); - else - elems[3] = mp_obj_new_int(buf[byteorder->byteorder.w]); + pre_brightness_buffer[rgbw_order->r] = r; + pre_brightness_buffer[rgbw_order->g] = g; + pre_brightness_buffer[rgbw_order->b] = b; } - return mp_obj_new_tuple(byteorder->bpp, elems); + uint8_t* post_brightness_buffer = self->post_brightness_buffer + offset; + if (self->bytes_per_pixel == 4) { + // Only apply brightness if w is actually white (aka not DotStar.) + if (!self->byteorder.is_dotstar) { + w *= self->brightness; + } + post_brightness_buffer[rgbw_order->w] = w; + } + post_brightness_buffer[rgbw_order->r] = r * self->brightness; + post_brightness_buffer[rgbw_order->g] = g * self->brightness; + post_brightness_buffer[rgbw_order->b] = b * self->brightness; +} + +void _pixelbuf_set_pixel(pixelbuf_pixelbuf_obj_t* self, size_t index, mp_obj_t value) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t w; + _pixelbuf_parse_color(self, value, &r, &g, &b, &w); + _pixelbuf_set_pixel_color(self, index, r, g, b, w); +} + +void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, size_t stop, size_t step, mp_obj_t* values) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + size_t source_i = 0; + for (size_t target_i = start; target_i < stop; target_i += step) { + _pixelbuf_set_pixel(self, target_i, values[source_i]); + source_i++; + } + if (self->auto_write) { + common_hal__pixelbuf_pixelbuf_show(self_in); + } +} + +void common_hal__pixelbuf_pixelbuf_set_pixel(mp_obj_t self_in, size_t index, mp_obj_t value) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + _pixelbuf_set_pixel(self, index, value); + if (self->auto_write) { + common_hal__pixelbuf_pixelbuf_show(self_in); + } +} + +mp_obj_t common_hal__pixelbuf_pixelbuf_get_pixel(mp_obj_t self_in, size_t index) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + mp_obj_t elems[self->byteorder.bpp]; + uint8_t* pixel_buffer = self->post_brightness_buffer; + if (self->pre_brightness_buffer != NULL) { + pixel_buffer = self->pre_brightness_buffer; + } + + pixelbuf_rgbw_t *rgbw_order = &self->byteorder.byteorder; + elems[0] = MP_OBJ_NEW_SMALL_INT(pixel_buffer[rgbw_order->r]); + elems[1] = MP_OBJ_NEW_SMALL_INT(pixel_buffer[rgbw_order->g]); + elems[2] = MP_OBJ_NEW_SMALL_INT(pixel_buffer[rgbw_order->b]); + if (self->byteorder.bpp > 3) { + uint8_t w = pixel_buffer[rgbw_order->w]; + if (self->byteorder.is_dotstar) { + elems[3] = mp_obj_new_float((w & 0b00011111) / 31.0); + } else { + elems[3] = MP_OBJ_NEW_SMALL_INT(w); + } + } + + return mp_obj_new_tuple(self->byteorder.bpp, elems); +} + +void common_hal__pixelbuf_pixelbuf_show(mp_obj_t self_in) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + mp_obj_t dest[2 + 1]; + mp_load_method(self_in, MP_QSTR__transmit, dest); + + dest[2] = self->transmit_buffer_obj; + + mp_call_method_n_kw(1, 0, dest); +} + +void common_hal__pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t fill_color) { + pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t w; + _pixelbuf_parse_color(self, fill_color, &r, &g, &b, &w); + + for (size_t i = 0; i < self->pixel_count; i++) { + _pixelbuf_set_pixel_color(self, i, r, g, b, w); + } + if (self->auto_write) { + common_hal__pixelbuf_pixelbuf_show(self_in); + } } diff --git a/shared-module/_pixelbuf/PixelBuf.h b/shared-module/_pixelbuf/PixelBuf.h index 173ce61a83..a9fbed366f 100644 --- a/shared-module/_pixelbuf/PixelBuf.h +++ b/shared-module/_pixelbuf/PixelBuf.h @@ -27,24 +27,45 @@ #include "py/obj.h" #include "py/objarray.h" -#include "../../shared-bindings/_pixelbuf/types.h" #ifndef PIXELBUF_SHARED_MODULE_H #define PIXELBUF_SHARED_MODULE_H +typedef struct { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t w; +} pixelbuf_rgbw_t; + +typedef struct { + uint8_t bpp; + pixelbuf_rgbw_t byteorder; + bool has_white; + bool is_dotstar; + mp_obj_t order_string; +} pixelbuf_byteorder_details_t; + +typedef struct { + mp_obj_base_t base; + size_t pixel_count; + size_t bytes_per_pixel; + pixelbuf_byteorder_details_t byteorder; + mp_float_t brightness; + mp_obj_t transmit_buffer_obj; + // The post_brightness_buffer is offset into the buffer allocated in transmit_buffer_obj to + // account for any header. + uint8_t *post_brightness_buffer; + uint8_t *pre_brightness_buffer; + bool auto_write; +} pixelbuf_pixelbuf_obj_t; + #define PIXEL_R 0 #define PIXEL_G 1 #define PIXEL_B 2 #define PIXEL_W 3 #define DOTSTAR_LED_START 0b11100000 -#define DOTSTAR_BRIGHTNESS(brightness) ((32 - (uint8_t)(32 - brightness * 31)) & 0b00011111) -#define DOTSTAR_GET_BRIGHTNESS(value) ((value & 0b00011111) / 31.0) #define DOTSTAR_LED_START_FULL_BRIGHT 0xFF -void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar); -void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder); - #endif From ebf0fe0a8cfc93546699879b13a87071ea942ce3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 14:04:11 -0600 Subject: [PATCH 377/531] mpy-cross: Make it easier to build mpy-cross static targets --- mpy-cross/.gitignore | 4 +- mpy-cross/Makefile | 82 +-------------------------------- mpy-cross/Makefile.static | 5 ++ mpy-cross/Makefile.static-mingw | 6 +++ mpy-cross/fmode.c | 49 ++++++++++++++++++++ mpy-cross/fmode.h | 37 +++++++++++++++ mpy-cross/main.c | 2 +- mpy-cross/mpy-cross.mk | 81 ++++++++++++++++++++++++++++++++ 8 files changed, 183 insertions(+), 83 deletions(-) create mode 100644 mpy-cross/Makefile.static create mode 100644 mpy-cross/Makefile.static-mingw create mode 100644 mpy-cross/fmode.c create mode 100644 mpy-cross/fmode.h create mode 100644 mpy-cross/mpy-cross.mk diff --git a/mpy-cross/.gitignore b/mpy-cross/.gitignore index 82a0a7efaa..f0024841d2 100644 --- a/mpy-cross/.gitignore +++ b/mpy-cross/.gitignore @@ -1 +1,3 @@ -mpy-cross +mpy-cross{,.exe} +mpy-cross.static{,.exe} +build-* diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile index 42dbace984..072304faa0 100644 --- a/mpy-cross/Makefile +++ b/mpy-cross/Makefile @@ -11,84 +11,4 @@ override undefine BUILD override undefine PROG endif -include ../py/mkenv.mk - -# define main target - -ifeq ($(OS),Windows_NT) -# Detect a MINGW32 build, and change the name of the final executable. -PROG = mpy-cross.exe -else -PROG = mpy-cross -endif - -# qstr definitions (must come before including py.mk) -QSTR_DEFS = qstrdefsport.h - -# OS name, for simple autoconfig -UNAME_S := $(shell uname -s) - -# include py core make definitions -include $(TOP)/py/py.mk - -INC += -I. -INC += -I$(TOP) -INC += -I$(BUILD) - -# compiler settings -CWARN = -Wall -Werror -CWARN += -Wpointer-arith -Wuninitialized -CFLAGS = $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables - -# Build a static executable. -# Useful for Windows builds, etc., that must run on multiple operating system versions. -ifdef STATIC_BUILD -CFLAGS += -static -static-libgcc -static-libstdc++ -endif - - -# Debugging/Optimization -ifdef DEBUG -CFLAGS += -g -COPT = -O0 -else -COPT = -Os #-DNDEBUG -endif - -# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed. -# The unix port of MicroPython on OSX must be compiled with clang, -# while cross-compile ports require gcc, so we test here for OSX and -# if necessary override the value of 'CC' set in py/mkenv.mk -ifeq ($(UNAME_S),Darwin) -CC = clang -# Use clang syntax for map file -LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip -else -# Use gcc syntax for map file -LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections -endif -LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) - -ifdef STATIC_BUILD -LDFLAGS += -static -static-libgcc -static-libstdc++ -endif - -# source files -SRC_C = \ - main.c \ - gccollect.c \ - supervisor/stub/safe_mode.c \ - supervisor/stub/stack.c \ - supervisor/shared/translate.c - -# Add fmode when compiling with mingw gcc -COMPILER_TARGET := $(shell $(CC) -dumpmachine) -ifneq (,$(findstring mingw,$(COMPILER_TARGET))) - SRC_C += ports/windows/fmode.c -endif - -OBJ = $(PY_O) -OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) - -include $(TOP)/py/mkrules.mk +include mpy-cross.mk diff --git a/mpy-cross/Makefile.static b/mpy-cross/Makefile.static new file mode 100644 index 0000000000..ca0925f758 --- /dev/null +++ b/mpy-cross/Makefile.static @@ -0,0 +1,5 @@ +PROG=mpy-cross.static +BUILD=build-static +STATIC_BUILD=1 + +include mpy-cross.mk diff --git a/mpy-cross/Makefile.static-mingw b/mpy-cross/Makefile.static-mingw new file mode 100644 index 0000000000..a176e80e6e --- /dev/null +++ b/mpy-cross/Makefile.static-mingw @@ -0,0 +1,6 @@ +PROG=mpy-cross.static.exe +CROSS_COMPILE = x86_64-w64-mingw32- +BUILD=build-static-mingw +STATIC_BUILD=1 + +include mpy-cross.mk diff --git a/mpy-cross/fmode.c b/mpy-cross/fmode.c new file mode 100644 index 0000000000..33ba24ed1f --- /dev/null +++ b/mpy-cross/fmode.c @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 Damien P. George + * + * 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 "fmode.h" +#include "py/mpconfig.h" +#include +#include + +// Workaround for setting file translation mode: we must distinguish toolsets +// since mingw has no _set_fmode, and altering msvc's _fmode directly has no effect +STATIC int set_fmode_impl(int mode) { +#ifndef _MSC_VER + _fmode = mode; + return 0; +#else + return _set_fmode(mode); +#endif +} + +void set_fmode_binary(void) { + set_fmode_impl(O_BINARY); +} + +void set_fmode_text(void) { + set_fmode_impl(O_TEXT); +} diff --git a/mpy-cross/fmode.h b/mpy-cross/fmode.h new file mode 100644 index 0000000000..c661c84d0c --- /dev/null +++ b/mpy-cross/fmode.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2016 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef MICROPY_INCLUDED_WINDOWS_FMODE_H +#define MICROPY_INCLUDED_WINDOWS_FMODE_H + +// Treat files opened by open() as binary. No line ending translation is done. +void set_fmode_binary(void); + +// Treat files opened by open() as text. +// When reading from the file \r\n will be converted to \n. +// When writing to the file \n will be converted into \r\n. +void set_fmode_text(void); + +#endif // MICROPY_INCLUDED_WINDOWS_FMODE_H diff --git a/mpy-cross/main.c b/mpy-cross/main.c index d819f74f12..280f59522f 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -35,7 +35,7 @@ #include "py/gc.h" #include "py/stackctrl.h" #ifdef _WIN32 -#include "ports/windows/fmode.h" +#include "fmode.h" #endif // Command line options, with their defaults diff --git a/mpy-cross/mpy-cross.mk b/mpy-cross/mpy-cross.mk new file mode 100644 index 0000000000..de96305cbf --- /dev/null +++ b/mpy-cross/mpy-cross.mk @@ -0,0 +1,81 @@ +include ../py/mkenv.mk + +# define main target + +ifeq ($(OS),Windows_NT) +# Detect a MINGW32 build, and change the name of the final executable. +PROG ?= mpy-cross.exe +else +PROG ?= mpy-cross +endif + +# qstr definitions (must come before including py.mk) +QSTR_DEFS = qstrdefsport.h + +# OS name, for simple autoconfig +UNAME_S := $(shell uname -s) + +# include py core make definitions +include $(TOP)/py/py.mk + +INC += -I. +INC += -I$(TOP) +INC += -I$(BUILD) + +# compiler settings +CWARN = -Wall -Werror +CWARN += -Wpointer-arith -Wuninitialized +CFLAGS = $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) +CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables + +# Build a static executable. +# Useful for Windows builds, etc., that must run on multiple operating system versions. +ifdef STATIC_BUILD +CFLAGS += -static -static-libgcc -static-libstdc++ +endif + + +# Debugging/Optimization +ifdef DEBUG +CFLAGS += -g +COPT = -O0 +else +COPT = -Os #-DNDEBUG +endif + +# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed. +# The unix port of MicroPython on OSX must be compiled with clang, +# while cross-compile ports require gcc, so we test here for OSX and +# if necessary override the value of 'CC' set in py/mkenv.mk +ifeq ($(UNAME_S),Darwin) +CC = clang +# Use clang syntax for map file +LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip +else +# Use gcc syntax for map file +LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections +endif +LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) + +ifdef STATIC_BUILD +LDFLAGS += -static -static-libgcc -static-libstdc++ +endif + +# source files +SRC_C = \ + main.c \ + gccollect.c \ + supervisor/stub/safe_mode.c \ + supervisor/stub/stack.c \ + supervisor/shared/translate.c + +# Add fmode when compiling with mingw gcc +COMPILER_TARGET := $(shell $(CC) -dumpmachine) +ifneq (,$(findstring mingw,$(COMPILER_TARGET))) + SRC_C += fmode.c +endif + +OBJ = $(PY_O) +OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) + +include $(TOP)/py/mkrules.mk From a43a19728c464a56f240c78fe620a690c8950333 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 14:40:38 -0600 Subject: [PATCH 378/531] Define serial_write, it was undefined in the Windows mpy-cross build --- mpy-cross/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mpy-cross/main.c b/mpy-cross/main.c index 280f59522f..7c232385b8 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -284,3 +284,7 @@ void nlr_jump_fail(void *val) { printf("FATAL: uncaught NLR %p\n", val); exit(1); } + +void serial_write(const char* text) { + printf("%s", text); +} From d9e0742a072adf00d29da5dff4edda028e351597 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 14:58:14 -0600 Subject: [PATCH 379/531] accomodate excessively old gcc versions for raspbian mpy-cross cross-build --- py/sequence.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/py/sequence.c b/py/sequence.c index a750e5bac4..0e668ea2a1 100644 --- a/py/sequence.c +++ b/py/sequence.c @@ -34,6 +34,11 @@ #define SWAP(type, var1, var2) { type t = var2; var2 = var1; var1 = t; } +#if __GNUC__ < 5 +// n.b. does not actually detect overflow! +#define __builtin_mul_overflow(a, b, x) (*(x) = (a) * (b), false) +#endif + // Detect when a multiply causes an overflow. size_t mp_seq_multiply_len(size_t item_sz, size_t len) { size_t new_len; From 9673ea4a50ddfd1451a15d2b87ea2390e8b556ce Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 15:02:02 -0600 Subject: [PATCH 380/531] Add a makefile to cross-compile for raspbian --- mpy-cross/.gitignore | 1 + mpy-cross/Makefile.static-raspbian | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 mpy-cross/Makefile.static-raspbian diff --git a/mpy-cross/.gitignore b/mpy-cross/.gitignore index f0024841d2..ede9937ced 100644 --- a/mpy-cross/.gitignore +++ b/mpy-cross/.gitignore @@ -1,3 +1,4 @@ mpy-cross{,.exe} mpy-cross.static{,.exe} build-* +pitools diff --git a/mpy-cross/Makefile.static-raspbian b/mpy-cross/Makefile.static-raspbian new file mode 100644 index 0000000000..9129f555e7 --- /dev/null +++ b/mpy-cross/Makefile.static-raspbian @@ -0,0 +1,8 @@ +PROG=mpy-cross.static-raspbian +BUILD=build-static-raspbian +STATIC_BUILD=1 + +CROSS_COMPILE = pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- +include mpy-cross.mk + +$(shell [ -d pitools ] || git clone --progress --verbose https://github.com/raspberrypi/tools.git --depth=1 pitools) From f13f9c7f308f0a33c6d3ac26057fc21e787dd473 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 15:02:16 -0600 Subject: [PATCH 381/531] rework gitignore file --- mpy-cross/.gitignore | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mpy-cross/.gitignore b/mpy-cross/.gitignore index ede9937ced..37cd3b0876 100644 --- a/mpy-cross/.gitignore +++ b/mpy-cross/.gitignore @@ -1,4 +1,6 @@ -mpy-cross{,.exe} -mpy-cross.static{,.exe} -build-* -pitools +/mpy-cross +/mpy-cross.static +/mpy-cross.static.exe +/mpy-cross.static-raspbian +/build-* +/pitools From b5b7b6fd0fa877301b564be60bce3607ed5a3ee4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 14:06:54 -0600 Subject: [PATCH 382/531] Build static mpy-cross bins .. for windows, desktop (x86_64) linux, and raspbian --- .github/workflows/build.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd049a53d8..cc43d5b7e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,8 @@ jobs: python-version: 3.5 - name: Install deps run: | - sudo apt-get install -y gettext librsvg2-bin + sudo apt-get install -y eatmydata + sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64 pip install requests sh click setuptools cpp-coveralls Sphinx sphinx-rtd-theme recommonmark sphinxcontrib-svg2pdfconverter polib pyyaml - name: Versions run: | @@ -66,6 +67,27 @@ jobs: run: python3 -u ci_new_boards_check.py working-directory: tools + - name: Build mpy-cross.static-raspbian + run: make -C mpy-cross -j2 -f Makefile.static-raspbian + - uses: actions/upload-artifact@v1.0.0 + with: + name: mpy-cross.static-raspbian + path: mpy-cross/mpy-cross.static-raspbian + + - name: Build mpy-cross.static + run: make -C mpy-cross -j2 -f Makefile.static + - uses: actions/upload-artifact@v1.0.0 + with: + name: mpy-cross.static-amd64-linux + path: mpy-cross/mpy-cross.static + + - name: Build mpy-cross.static-mingw + run: make -C mpy-cross -j2 -f Makefile.static-mingw + - uses: actions/upload-artifact@v1.0.0 + with: + name: mpy-cross.static-x64-windows + path: mpy-cross/mpy-cross.static.exe + build-arm: runs-on: ubuntu-16.04 needs: test From eee9159a91a2b7ad367850cab2b11ab5c427e4df Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 17:13:29 -0600 Subject: [PATCH 383/531] alphabetize --- mpy-cross/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpy-cross/.gitignore b/mpy-cross/.gitignore index 37cd3b0876..0681b685fa 100644 --- a/mpy-cross/.gitignore +++ b/mpy-cross/.gitignore @@ -1,6 +1,6 @@ +/build-* /mpy-cross /mpy-cross.static /mpy-cross.static.exe /mpy-cross.static-raspbian -/build-* /pitools From 0b7551f4c7af0fd6344386312f64d894cf4bd09b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 25 Jan 2020 18:49:14 -0600 Subject: [PATCH 384/531] add mpy-cross-mac to build artifacts --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc43d5b7e6..7ba9caa546 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,6 +88,33 @@ jobs: name: mpy-cross.static-x64-windows path: mpy-cross/mpy-cross.static.exe + mpy-cross-mac: + runs-on: macos-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Install deps + run: | + brew link --force gettext + - name: Versions + run: | + gcc --version + python3 --version + msgfmt --version + - uses: actions/checkout@v1 + with: + submodules: true + - name: CircuitPython version + run: git describe --dirty --always --tags + - name: Build mpy-cross + run: make -C mpy-cross -j2 + - uses: actions/upload-artifact@v1.0.0 + with: + name: mpy-cross-macos-catalina + path: mpy-cross/mpy-cross + build-arm: runs-on: ubuntu-16.04 needs: test From cb6193bbc76ee702128c44a95bc8184abcb04177 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 26 Jan 2020 15:36:12 -0600 Subject: [PATCH 385/531] samd: When possible, use one DMA channel for stereo AudioOut .. the documentation doesn't make this clear, but in practice it works to write both of the DATABUF registers at the same time. This should also reduce the amount of wear and tear DMA puts on the system, as the number of transfers is cut in half. (the number of bytes transferred remains the same, though) In principle, this could cover all stereo cases if audio_dma_convert_signed also learned to 16-bit extend and swap values. However, this is the case that matters for stereo mp3 playback on PyGamer. Testing performed: Listened to some tracks with good stereo separation. --- .../atmel-samd/common-hal/audioio/AudioOut.c | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index 36ab520067..b75c2b3350 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -397,15 +397,22 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t* self, if (self->right_channel == &pin_PA02) { right_channel_reg = (uint32_t) &DAC->DATABUF[0].reg; } - result = audio_dma_setup_playback(&self->left_dma, sample, loop, true, 0, - false /* output unsigned */, - left_channel_reg, - left_channel_trigger); - if (right_channel_reg != 0 && result == AUDIO_DMA_OK) { - result = audio_dma_setup_playback(&self->right_dma, sample, loop, true, 1, + if(right_channel_reg == left_channel_reg + 2 && audiosample_bits_per_sample(sample) == 16) { + result = audio_dma_setup_playback(&self->left_dma, sample, loop, false, 0, false /* output unsigned */, - right_channel_reg, - right_channel_trigger); + left_channel_reg, + left_channel_trigger); + } else { + result = audio_dma_setup_playback(&self->left_dma, sample, loop, true, 0, + false /* output unsigned */, + left_channel_reg, + left_channel_trigger); + if (right_channel_reg != 0 && result == AUDIO_DMA_OK) { + result = audio_dma_setup_playback(&self->right_dma, sample, loop, true, 1, + false /* output unsigned */, + right_channel_reg, + right_channel_trigger); + } } #endif if (result != AUDIO_DMA_OK) { From f2dfcee04241faad5edb7ef678c95cecf7408c60 Mon Sep 17 00:00:00 2001 From: Lady Ada Date: Sun, 26 Jan 2020 20:10:20 -0500 Subject: [PATCH 386/531] add missing displayref --- ports/nrf/boards/clue_nrf52840_express/pins.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/nrf/boards/clue_nrf52840_express/pins.c b/ports/nrf/boards/clue_nrf52840_express/pins.c index b13d1977fb..2926f46e0b 100644 --- a/ports/nrf/boards/clue_nrf52840_express/pins.c +++ b/ports/nrf/boards/clue_nrf52840_express/pins.c @@ -1,5 +1,8 @@ #include "shared-bindings/board/__init__.h" +#include "boards/board.h" +#include "shared-module/displayio/__init__.h" + STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_P0_04) }, { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_04) }, @@ -96,6 +99,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From c8f969feb5f8dcdbe7716403e0a48d63ebb19352 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 27 Jan 2020 08:49:41 -0600 Subject: [PATCH 387/531] samd: audio-dma: avoid memory allocations With the previous change, stereo mp3 playback changed from needing 4 2304-byte allocations to needing 2 4604-byte allocations. This was enough to cause MemoryErrors with regularity. By using m_realloc() here, the existing memory region can be used. m_realloc() also works on the first invocation, because m_realloc(NULL, sz) just calls m_malloc of sz. --- ports/atmel-samd/audio_dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c index 0478cc9bf4..352af89802 100644 --- a/ports/atmel-samd/audio_dma.c +++ b/ports/atmel-samd/audio_dma.c @@ -203,13 +203,13 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t* dma, if (output_signed != samples_signed) { output_spacing = 1; max_buffer_length /= dma->spacing; - dma->first_buffer = (uint8_t*) m_malloc(max_buffer_length, false); + dma->first_buffer = (uint8_t*) m_realloc(dma->first_buffer, max_buffer_length); if (dma->first_buffer == NULL) { return AUDIO_DMA_MEMORY_ERROR; } dma->first_buffer_free = true; if (!single_buffer) { - dma->second_buffer = (uint8_t*) m_malloc(max_buffer_length, false); + dma->second_buffer = (uint8_t*) m_realloc(dma->second_buffer, max_buffer_length); if (dma->second_buffer == NULL) { return AUDIO_DMA_MEMORY_ERROR; } From e21580b67fb476ac89955407af01cf6406b3b388 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 27 Jan 2020 17:10:56 -0500 Subject: [PATCH 388/531] PacketBuffer.packet_size was returning bool instead of int --- shared-bindings/_bleio/Characteristic.c | 2 +- shared-bindings/_bleio/PacketBuffer.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 2b1dc1f789..e55191f7ce 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -49,7 +49,7 @@ //| as part of remote Services. //| -//| .. method:: add_to_service(service, uuid, *, properties=0, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`, max_length=20, fixed_length=False, initial_value=None) +//| .. method:: add_to_service(service, uuid, *, properties=0, read_perm=Attribute.OPEN, write_perm=Attribute.OPEN, max_length=20, fixed_length=False, initial_value=None) //| //| Create a new Characteristic object, and add it to this Service. //| diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index f9f171870b..3ed295f017 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -163,13 +163,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_bu //| .. attribute:: packet_size //| -//| Maximum size of each packet in bytes. This is the minimum of the Characterstic length and +//| Maximum size of each packet in bytes. This is the minimum of the Characteristic length and //| the negotiated Maximum Transfer Unit (MTU). //| STATIC mp_obj_t bleio_packet_buffer_get_packet_size(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(common_hal_bleio_packet_buffer_get_packet_size(self)); + return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_packet_buffer_get_packet_size(self)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_get_packet_size_obj, bleio_packet_buffer_get_packet_size); From f6a635b102259c6bc7d0f163881eac5b5e50a117 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 27 Jan 2020 14:52:42 -0800 Subject: [PATCH 389/531] Fix subclassing of objects that are tested. Others may still be broken. --- extmod/modframebuf.c | 34 ++++++++++++++++++++++------------ py/objlist.c | 31 ++++++++++++++++--------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index a51d1c3804..c59d1592ba 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -28,6 +28,7 @@ #include #include "py/runtime.h" +#include "py/objtype.h" #include "py/proto.h" #if MICROPY_PY_FRAMEBUF @@ -304,9 +305,18 @@ STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, cons return MP_OBJ_FROM_PTR(o); } +STATIC const mp_obj_type_t mp_type_framebuf; + +// Helper to ensure we have the native super class instead of a subclass. +static mp_obj_framebuf_t* native_framebuf(mp_obj_t framebuf_obj) { + mp_obj_t native_framebuf = mp_instance_cast_to_native_base(framebuf_obj, &mp_type_framebuf); + mp_obj_assert_native_inited(native_framebuf); + return MP_OBJ_TO_PTR(native_framebuf); +} + STATIC mp_int_t framebuf_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { (void)flags; - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_framebuf_t *self = native_framebuf(self_in); bufinfo->buf = self->buf; bufinfo->len = self->stride * self->height * (self->format == FRAMEBUF_RGB565 ? 2 : 1); bufinfo->typecode = 'B'; // view framebuf as bytes @@ -314,7 +324,7 @@ STATIC mp_int_t framebuf_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, } STATIC mp_obj_t framebuf_fill(mp_obj_t self_in, mp_obj_t col_in) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_framebuf_t *self = native_framebuf(self_in); mp_int_t col = mp_obj_get_int(col_in); formats[self->format].fill_rect(self, 0, 0, self->width, self->height, col); return mp_const_none; @@ -324,7 +334,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(framebuf_fill_obj, framebuf_fill); STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) { (void)n_args; - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); mp_int_t x = mp_obj_get_int(args[1]); mp_int_t y = mp_obj_get_int(args[2]); mp_int_t width = mp_obj_get_int(args[3]); @@ -338,7 +348,7 @@ STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_fill_rect_obj, 6, 6, framebuf_fill_rect); STATIC mp_obj_t framebuf_pixel(size_t n_args, const mp_obj_t *args) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); mp_int_t x = mp_obj_get_int(args[1]); mp_int_t y = mp_obj_get_int(args[2]); if (0 <= x && x < self->width && 0 <= y && y < self->height) { @@ -357,7 +367,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_pixel_obj, 3, 4, framebuf_pi STATIC mp_obj_t framebuf_hline(size_t n_args, const mp_obj_t *args) { (void)n_args; - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); mp_int_t x = mp_obj_get_int(args[1]); mp_int_t y = mp_obj_get_int(args[2]); mp_int_t w = mp_obj_get_int(args[3]); @@ -372,7 +382,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_hline_obj, 5, 5, framebuf_hl STATIC mp_obj_t framebuf_vline(size_t n_args, const mp_obj_t *args) { (void)n_args; - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); mp_int_t x = mp_obj_get_int(args[1]); mp_int_t y = mp_obj_get_int(args[2]); mp_int_t h = mp_obj_get_int(args[3]); @@ -387,7 +397,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_vline_obj, 5, 5, framebuf_vl STATIC mp_obj_t framebuf_rect(size_t n_args, const mp_obj_t *args) { (void)n_args; - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); mp_int_t x = mp_obj_get_int(args[1]); mp_int_t y = mp_obj_get_int(args[2]); mp_int_t w = mp_obj_get_int(args[3]); @@ -406,7 +416,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_rect_obj, 6, 6, framebuf_rec STATIC mp_obj_t framebuf_line(size_t n_args, const mp_obj_t *args) { (void)n_args; - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); mp_int_t x1 = mp_obj_get_int(args[1]); mp_int_t y1 = mp_obj_get_int(args[2]); mp_int_t x2 = mp_obj_get_int(args[3]); @@ -470,8 +480,8 @@ STATIC mp_obj_t framebuf_line(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_line_obj, 6, 6, framebuf_line); STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_obj_framebuf_t *source = MP_OBJ_TO_PTR(args[1]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); + mp_obj_framebuf_t *source = native_framebuf(args[1]); mp_int_t x = mp_obj_get_int(args[2]); mp_int_t y = mp_obj_get_int(args[3]); mp_int_t key = -1; @@ -513,7 +523,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 5, framebuf_blit); STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) { - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_framebuf_t *self = native_framebuf(self_in); mp_int_t xstep = mp_obj_get_int(xstep_in); mp_int_t ystep = mp_obj_get_int(ystep_in); int sx, y, xend, yend, dx, dy; @@ -546,7 +556,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(framebuf_scroll_obj, framebuf_scroll); STATIC mp_obj_t framebuf_text(size_t n_args, const mp_obj_t *args) { // extract arguments - mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_framebuf_t *self = native_framebuf(args[0]); const char *str = mp_obj_str_get_str(args[1]); mp_int_t x0 = mp_obj_get_int(args[2]); mp_int_t y0 = mp_obj_get_int(args[3]); diff --git a/py/objlist.c b/py/objlist.c index b32f82085e..9ae9c0ed68 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -46,6 +46,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in); + //mp_obj_list_t *o = mp_instance_cast_to_native_base(o_in, &mp_type_list); if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { kind = PRINT_REPR; } @@ -93,7 +94,7 @@ STATIC mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, const } STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); switch (op) { case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0); case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); @@ -108,7 +109,7 @@ STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { - mp_obj_list_t *o = MP_OBJ_TO_PTR(lhs); + mp_obj_list_t *o = mp_instance_cast_to_native_base(lhs, &mp_type_list); switch (op) { case MP_BINARY_OP_ADD: { if (!MP_OBJ_IS_TYPE(rhs, &mp_type_list)) { @@ -239,7 +240,7 @@ STATIC mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (self->len >= self->alloc) { self->items = m_renew(mp_obj_t, self->items, self->alloc, self->alloc * 2); self->alloc *= 2; @@ -252,8 +253,8 @@ mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) { STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); if (MP_OBJ_IS_TYPE(arg_in, &mp_type_list)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_list_t *arg = MP_OBJ_TO_PTR(arg_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); + mp_obj_list_t *arg = mp_instance_cast_to_native_base(arg_in, &mp_type_list); if (self->len + arg->len > self->alloc) { // TODO: use alloc policy for "4" @@ -272,7 +273,7 @@ STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) { mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_list_t *self = mp_instance_cast_to_native_base(args[0], &mp_type_list); if (self->len == 0) { mp_raise_IndexError(translate("pop from empty list")); } @@ -332,7 +333,7 @@ mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args); mp_check_self(MP_OBJ_IS_TYPE(pos_args[0], &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(pos_args[0]); + mp_obj_list_t *self = mp_instance_cast_to_native_base(pos_args[0], &mp_type_list); if (self->len > 1) { mp_quicksort(self->items, self->items + self->len - 1, @@ -345,7 +346,7 @@ mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ mp_obj_t mp_obj_list_clear(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); self->len = 0; self->items = m_renew(mp_obj_t, self->items, self->alloc, LIST_MIN_ALLOC); self->alloc = LIST_MIN_ALLOC; @@ -355,25 +356,25 @@ mp_obj_t mp_obj_list_clear(mp_obj_t self_in) { STATIC mp_obj_t list_copy(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); return mp_obj_new_list(self->len, self->items); } STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); return mp_seq_count_obj(self->items, self->len, value); } STATIC mp_obj_t list_index(size_t n_args, const mp_obj_t *args) { mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]); + mp_obj_list_t *self = mp_instance_cast_to_native_base(args[0], &mp_type_list); return mp_seq_index_obj(self->items, self->len, n_args, args); } STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); // insert has its own strange index logic mp_int_t index = MP_OBJ_SMALL_INT_VALUE(idx); if (index < 0) { @@ -407,7 +408,7 @@ mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) { STATIC mp_obj_t list_reverse(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); mp_int_t len = self->len; for (mp_int_t i = 0; i < len/2; i++) { @@ -484,7 +485,7 @@ mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items) { } void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); *len = self->len; *items = self->items; } @@ -497,7 +498,7 @@ void mp_obj_list_set_len(mp_obj_t self_in, size_t len) { } void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); size_t i = mp_get_index(self->base.type, self->len, index, false); self->items[i] = value; } From 5e789b38504846982a8cd7fa447297a51efc8352 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 27 Jan 2020 15:10:32 -0800 Subject: [PATCH 390/531] Don't allocate the pre brightness buffer if brightness is 1.0 still --- shared-module/_pixelbuf/PixelBuf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index ab5bcb4417..bad8539ea8 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -68,6 +68,7 @@ void common_hal__pixelbuf_pixelbuf_construct(pixelbuf_pixelbuf_obj_t *self, size } } // Call set_brightness so that it can allocate a second buffer if needed. + self->brightness = 1.0; common_hal__pixelbuf_pixelbuf_set_brightness(MP_OBJ_FROM_PTR(self), brightness); // Turn on auto_write. We don't want to do it with the above brightness call. @@ -106,6 +107,12 @@ mp_float_t common_hal__pixelbuf_pixelbuf_get_brightness(mp_obj_t self_in) { void common_hal__pixelbuf_pixelbuf_set_brightness(mp_obj_t self_in, mp_float_t brightness) { pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in); + // Skip out if the brightness is already set. The default of self->brightness is 1.0. So, this + // also prevents the pre_brightness_buffer allocation when brightness is set to 1.0 again. + mp_float_t change = brightness - self->brightness; + if (-0.001 < change && change < 0.001) { + return; + } self->brightness = brightness; size_t pixel_len = self->pixel_count * self->bytes_per_pixel; if (self->pre_brightness_buffer == NULL) { From df5e58fc6ed0c09668498da768f0d4ad2bbbefb3 Mon Sep 17 00:00:00 2001 From: Wojtek Siudzinski Date: Tue, 28 Jan 2020 10:53:50 +0100 Subject: [PATCH 391/531] Add support for the Particle Ethernet FeatherWing --- ports/nrf/Makefile | 26 +++++++++++++++++++ .../boards/particle_argon/mpconfigboard.mk | 4 +++ .../boards/particle_boron/mpconfigboard.mk | 4 +++ .../boards/particle_xenon/mpconfigboard.mk | 4 +++ 4 files changed, 38 insertions(+) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 75bf23fc84..47a5b86534 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -183,6 +183,32 @@ SRC_C += \ lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c endif +ifeq ($(CIRCUITPY_NETWORK),1) +CFLAGS += -DMICROPY_PY_NETWORK=1 + +SRC_MOD += lib/netutils/netutils.c + +ifneq ($(MICROPY_PY_WIZNET5K),0) +WIZNET5K_DIR=drivers/wiznet5k +INC += -I$(TOP)/$(WIZNET5K_DIR) +CFLAGS_MOD += -DMICROPY_PY_WIZNET5K=$(MICROPY_PY_WIZNET5K) -D_WIZCHIP_=$(MICROPY_PY_WIZNET5K) +SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\ + ethernet/w$(MICROPY_PY_WIZNET5K)/w$(MICROPY_PY_WIZNET5K).c \ + ethernet/wizchip_conf.c \ + ethernet/socket.c \ + internet/dns/dns.c \ + internet/dhcp/dhcp.c \ + ) + +endif # MICROPY_PY_WIZNET5K +endif # CIRCUITPY_NETWORK + +ifeq ($(CIRCUITPY_NETWORK),1) +ifneq ($(MICROPY_PY_WIZNET5K),0) +SRC_SHARED_MODULE += wiznet/__init__.c wiznet/wiznet5k.c +endif +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/nrf/boards/particle_argon/mpconfigboard.mk b/ports/nrf/boards/particle_argon/mpconfigboard.mk index f8d3d2aca2..a0edfda958 100644 --- a/ports/nrf/boards/particle_argon/mpconfigboard.mk +++ b/ports/nrf/boards/particle_argon/mpconfigboard.mk @@ -8,3 +8,7 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "MX25L3233F" + +# Support for the Ethernet FeatherWing +CIRCUITPY_NETWORK = 1 +MICROPY_PY_WIZNET5K = 5500 \ No newline at end of file diff --git a/ports/nrf/boards/particle_boron/mpconfigboard.mk b/ports/nrf/boards/particle_boron/mpconfigboard.mk index eada97a730..ccb2d63a17 100644 --- a/ports/nrf/boards/particle_boron/mpconfigboard.mk +++ b/ports/nrf/boards/particle_boron/mpconfigboard.mk @@ -8,3 +8,7 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "MX25L3233F" + +# Support for the Ethernet FeatherWing +CIRCUITPY_NETWORK = 1 +MICROPY_PY_WIZNET5K = 5500 \ No newline at end of file diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.mk b/ports/nrf/boards/particle_xenon/mpconfigboard.mk index 6062da378f..3970b1d056 100644 --- a/ports/nrf/boards/particle_xenon/mpconfigboard.mk +++ b/ports/nrf/boards/particle_xenon/mpconfigboard.mk @@ -8,3 +8,7 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "MX25L3233F" + +# Support for the Ethernet FeatherWing +CIRCUITPY_NETWORK = 1 +MICROPY_PY_WIZNET5K = 5500 \ No newline at end of file From 03cdc5ef765d28261c039f236ba36ebd5016f055 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 28 Jan 2020 13:48:17 -0600 Subject: [PATCH 392/531] tools/uf2: take new upstream commits --- tools/uf2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/uf2 b/tools/uf2 index 84da66ce62..adbb8c7260 160000 --- a/tools/uf2 +++ b/tools/uf2 @@ -1 +1 @@ -Subproject commit 84da66ce62215c1daa62204f2c3fa83c05143a42 +Subproject commit adbb8c7260f938e810eb37f2287f8e1a055ff402 From ab9483b7fb50db46d9cb6abe54641787f5acd7c9 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 28 Jan 2020 16:00:34 -0500 Subject: [PATCH 393/531] Add internal display definitions, fails at startup --- ports/stm32f4/boards/meowbit_v121/board.c | 82 +++++++++++++++++++ .../boards/meowbit_v121/mpconfigboard.h | 2 +- .../boards/meowbit_v121/mpconfigboard.mk | 6 +- ports/stm32f4/boards/meowbit_v121/pins.c | 4 + 4 files changed, 90 insertions(+), 4 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/board.c b/ports/stm32f4/boards/meowbit_v121/board.c index 82b0c506ed..2fa3729803 100644 --- a/ports/stm32f4/boards/meowbit_v121/board.c +++ b/ports/stm32f4/boards/meowbit_v121/board.c @@ -27,7 +27,89 @@ #include "boards/board.h" #include "mpconfigboard.h" +#include "shared-bindings/board/__init__.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/busio/SPI.h" + +#include "supervisor/spi_flash_api.h" + +#include "tick.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + 0x11, 0 | DELAY, 255, // SLPOUT + 0xb1, 3, 0x01, 0x2C, 0x2D, // _FRMCTR1 + 0xb2, 3, 0x01, 0x2C, 0x2D, // + 0xb3, 6, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D, + 0xb4, 1, 0x07, // _INVCTR line inversion + 0xc0, 3, 0xa2, 0x02, 0x84, // _PWCTR1 GVDD = 4.7V, 1.0uA + 0xc1, 1, 0xc5, // _PWCTR2 VGH=14.7V, VGL=-7.35V + 0xc2, 2, 0x0a, 0x00, // _PWCTR3 Opamp current small, Boost frequency + 0xc3, 2, 0x8a, 0x2a, + 0xc4, 2, 0x8a, 0xee, + 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V + 0x20, 0, // _INVOFF //MISMATCh 0x2a vs 0x20 + 0x36, 1, 0x18, // _MADCTL bottom to top refresh + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // fix on VTL + 0x3a, 1, 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, 10, // _NORON + 0x29, 0 | DELAY, 100, // _DISPON +}; + void board_init(void) { + displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + busio_spi_obj_t *internal_spi = &spi; + common_hal_displayio_fourwire_construct(bus, + internal_spi, + &pin_PA08, // Command or data + &pin_PB12, // Chip select + &pin_PB10, // Reset + 24000000); + + displayio_display_obj_t* display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct(display, + bus, + 160, // Width + 128, // Height + 0, // column start + 0, // row start + 90, // rotation + 16, // Color depth + false, // Grayscale + false, // Pixels in a byte share a row. Only used for depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + 0x37, // set vertical scroll command + display_init_sequence, + sizeof(display_init_sequence), + &pin_PB03, + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60); // native_frames_per_second } bool board_requests_safe_mode(void) { diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index c849e03b6c..b807153831 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -37,7 +37,7 @@ #define BOARD_OSC_DIV 12 #define BOARD_NO_VBUS_SENSE -#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader +// #define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader #define BOARD_USE_INTERNAL_SPI // On-board flash diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 340fd9d3b7..c813b4120a 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -9,7 +9,7 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ LONGINT_IMPL = MPZ -BOOTLOADER_OFFSET = 0x8010000 +# BOOTLOADER_OFFSET = 0x8010000 # INTERNAL_FLASH_FILESYSTEM = 1 # LONGINT_IMPL = NONE @@ -19,5 +19,5 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401_boot.ld -# LD_FILE = boards/STM32F401_fs.ld #use for internal flash \ No newline at end of file +# LD_FILE = boards/STM32F401_boot.ld +LD_FILE = boards/STM32F401_fs.ld #use for internal flash \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 0cdbefd59b..def551c3bb 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -1,6 +1,8 @@ #include "shared-bindings/board/__init__.h" #include "supervisor/spi_flash_api.h" +#include "shared-module/displayio/__init__.h" + STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) }, { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) }, @@ -61,5 +63,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) }, { MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 3c8600554654926fe88d65fc0b5d668c0bea476a Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 28 Jan 2020 17:11:25 -0500 Subject: [PATCH 394/531] Implement requested changes --- ports/stm32f4/boards/meowbit_v121/pins.c | 2 +- ports/stm32f4/common-hal/pulseio/PWMOut.c | 6 ++-- shared-module/displayio/__init__.c | 2 +- supervisor/shared/external_flash/spi_flash.c | 32 ++++++++++---------- supervisor/spi_flash_api.h | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 0cdbefd59b..1489c23f1c 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -60,6 +60,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P0), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) }, - { MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) }, + { MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&supervisor_flash_spi_bus) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 000325be30..29376691bb 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -68,9 +68,9 @@ STATIC uint32_t timer_get_source_freq(uint32_t tim_id) { } STATIC uint32_t timer_get_internal_duty(uint16_t duty, uint32_t period) { - //duty cycle is (0xFFFF - duty)/0xFFFF fraction x (number of pulses per period) + //duty cycle is duty/0xFFFF fraction x (number of pulses per period) //Note that pulses are inverted, so duty cycle is inverted - return ((0xFFFF - duty)*period) / ((1 << 16) - 1); + return (duty*period) / ((1 << 16) - 1); } STATIC void timer_get_optimal_divisors(uint32_t*period, uint32_t*prescaler, @@ -203,7 +203,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, //Channel/PWM init self->chan_handle.OCMode = TIM_OCMODE_PWM1; self->chan_handle.Pulse = timer_get_internal_duty(duty, period); - self->chan_handle.OCPolarity = TIM_OCPOLARITY_LOW; + self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH; self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE; self->chan_handle.OCNPolarity = TIM_OCNPOLARITY_LOW; // needed for TIM1 and TIM8 self->chan_handle.OCIdleState = TIM_OCIDLESTATE_SET; // needed for TIM1 and TIM8 diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 8d9f148834..efa61265e6 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -104,7 +104,7 @@ void reset_displays(void) { } #endif #ifdef BOARD_USE_INTERNAL_SPI - if (original_spi == (mp_obj_t)(&spi)) { + if (original_spi == (mp_obj_t)(&supervisor_flash_spi_bus)) { continue; } #endif diff --git a/supervisor/shared/external_flash/spi_flash.c b/supervisor/shared/external_flash/spi_flash.c index 12888f2d33..67e64c970e 100644 --- a/supervisor/shared/external_flash/spi_flash.c +++ b/supervisor/shared/external_flash/spi_flash.c @@ -36,33 +36,33 @@ #include "py/mpconfig.h" digitalio_digitalinout_obj_t cs_pin; -busio_spi_obj_t spi; +busio_spi_obj_t supervisor_flash_spi_bus; const external_flash_device* flash_device; uint32_t spi_flash_baudrate; // Enable the flash over SPI. static void flash_enable(void) { - while (!common_hal_busio_spi_try_lock(&spi)) {} + while (!common_hal_busio_spi_try_lock(&supervisor_flash_spi_bus)) {} common_hal_digitalio_digitalinout_set_value(&cs_pin, false); } // Disable the flash over SPI. static void flash_disable(void) { common_hal_digitalio_digitalinout_set_value(&cs_pin, true); - common_hal_busio_spi_unlock(&spi); + common_hal_busio_spi_unlock(&supervisor_flash_spi_bus); } static bool transfer(uint8_t* command, uint32_t command_length, uint8_t* data_in, uint8_t* data_out, uint32_t data_length) { flash_enable(); - bool status = common_hal_busio_spi_write(&spi, command, command_length); + bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, command, command_length); if (status) { if (data_in != NULL && data_out != NULL) { - status = common_hal_busio_spi_transfer(&spi, data_out, data_in, data_length); + status = common_hal_busio_spi_transfer(&supervisor_flash_spi_bus, data_out, data_in, data_length); } else if (data_out != NULL) { - status = common_hal_busio_spi_read(&spi, data_out, data_length, 0xff); + status = common_hal_busio_spi_read(&supervisor_flash_spi_bus, data_out, data_length, 0xff); } else if (data_in != NULL) { - status = common_hal_busio_spi_write(&spi, data_in, data_length); + status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, data_in, data_length); } } flash_disable(); @@ -103,10 +103,10 @@ bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t data_length) // Write the SPI flash write address into the bytes following the command byte. address_to_bytes(address, request + 1); flash_enable(); - common_hal_busio_spi_configure(&spi, spi_flash_baudrate, 0, 0, 8); - bool status = common_hal_busio_spi_write(&spi, request, 4); + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); + bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, 4); if (status) { - status = common_hal_busio_spi_write(&spi, data, data_length); + status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, data, data_length); } flash_disable(); return status; @@ -122,10 +122,10 @@ bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t data_length) // Write the SPI flash write address into the bytes following the command byte. address_to_bytes(address, request + 1); flash_enable(); - common_hal_busio_spi_configure(&spi, spi_flash_baudrate, 0, 0, 8); - bool status = common_hal_busio_spi_write(&spi, request, command_length); + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); + bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, command_length); if (status) { - status = common_hal_busio_spi_read(&spi, data, data_length, 0xff); + status = common_hal_busio_spi_read(&supervisor_flash_spi_bus, data, data_length, 0xff); } flash_disable(); return status; @@ -140,9 +140,9 @@ void spi_flash_init(void) { common_hal_digitalio_digitalinout_switch_to_output(&cs_pin, true, DRIVE_MODE_PUSH_PULL); common_hal_digitalio_digitalinout_never_reset(&cs_pin); - spi.base.type = &busio_spi_type; - common_hal_busio_spi_construct(&spi, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN); - common_hal_busio_spi_never_reset(&spi); + supervisor_flash_spi_bus.base.type = &busio_spi_type; + common_hal_busio_spi_construct(&supervisor_flash_spi_bus, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN); + common_hal_busio_spi_never_reset(&supervisor_flash_spi_bus); } void spi_flash_init_device(const external_flash_device* device) { diff --git a/supervisor/spi_flash_api.h b/supervisor/spi_flash_api.h index b477308bab..f59346e25a 100644 --- a/supervisor/spi_flash_api.h +++ b/supervisor/spi_flash_api.h @@ -33,7 +33,7 @@ #include "shared-bindings/busio/SPI.h" -extern busio_spi_obj_t spi; //Used to share SPI bus on some boards +extern busio_spi_obj_t supervisor_flash_spi_bus; //Used to share SPI bus on some boards // This API is implemented for both normal SPI peripherals and QSPI peripherals. From 947c2243bdc88fed001723939ed6f91851236e8d Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 29 Jan 2020 15:30:35 -0500 Subject: [PATCH 395/531] add feather bootloader settings, cleanup --- ports/stm32f4/boards/STM32F401_boot.ld | 6 +-- .../{STM32F401.ld => STM32F405_boot.ld} | 54 ++++++------------- .../boards/{STM32F405.ld => STM32F405_fs.ld} | 0 .../feather_stm32f405_express/mpconfigboard.h | 3 ++ .../mpconfigboard.mk | 7 +-- .../boards/meowbit_v121/mpconfigboard.mk | 2 +- 6 files changed, 26 insertions(+), 46 deletions(-) rename ports/stm32f4/boards/{STM32F401.ld => STM32F405_boot.ld} (60%) rename ports/stm32f4/boards/{STM32F405.ld => STM32F405_fs.ld} (100%) diff --git a/ports/stm32f4/boards/STM32F401_boot.ld b/ports/stm32f4/boards/STM32F401_boot.ld index ffdd7097cb..125d785fc2 100644 --- a/ports/stm32f4/boards/STM32F401_boot.ld +++ b/ports/stm32f4/boards/STM32F401_boot.ld @@ -5,9 +5,9 @@ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */ - FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K - FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash, sans bootloader region */ + FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4 */ + FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5,6,7 are 128K */ RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 } diff --git a/ports/stm32f4/boards/STM32F401.ld b/ports/stm32f4/boards/STM32F405_boot.ld similarity index 60% rename from ports/stm32f4/boards/STM32F401.ld rename to ports/stm32f4/boards/STM32F405_boot.ld index bf1f21cf61..cff2af388e 100644 --- a/ports/stm32f4/boards/STM32F401.ld +++ b/ports/stm32f4/boards/STM32F405_boot.ld @@ -1,39 +1,30 @@ /* - GNU linker script for STM32F401 with bootloader (from Meowbit Micropython) - Doesn't work: - - Traceback (most recent call last): - File "../../tools/build_memory_info.py", line 64, in - regions[region] = int(eval(space)) - File "", line 1, in -NameError: name 'FLASH_ISR' is not defined + GNU linker script for STM32F405 with bootloader + Based on Micropython */ /* Specify the memory areas */ -/* FLASH_FS (rx) : ORIGIN = 0x08020000, LENGTH = 128K */ -/* sectors 5 128K */ MEMORY { - FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */ - FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4, sec 0~3 reserved for booloader */ - FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5, 6,7 are 128K */ - RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194 + FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 1024K - 64K /* entire flash, sans bootloader region */ + FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 0 */ + FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 1024K - 64K - 64K /* sectors 5+ */ + CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K } /* produce a link error if there is not this amount of RAM for these sections */ _minimum_stack_size = 2K; _minimum_heap_size = 16K; -/* Define the stack. The stack is full descending so begins just above last byte - of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */ -_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve; -_sstack = _estack - 16K; /* tunable */ +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* RAM extents for the garbage collector */ _ram_start = ORIGIN(RAM); _ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_start = _ebss; /* heap starts just after statically allocated memory */ -_heap_end = _sstack; ENTRY(Reset_Handler) @@ -47,25 +38,8 @@ SECTIONS KEEP(*(.isr_vector)) /* Startup code */ /* This first flash block is 16K annd the isr vectors only take up - about 400 bytes. So we pull in a couple of object files to pad it - out. */ - - . = ALIGN(4); - - /* NOTE: If you update the list of files contained in .isr_vector, - then be sure to also update smhal/Makefile where it forcibly - builds each of these files with -Os */ - - */ff.o(.text*) - */vfs_fat_*.o(.text*) - */py/formatfloat.o(.text*) - */py/parsenum.o(.text*) - */py/mpprint.o(.text*) - - */py/compile.o(.text*) - */py/objset.o(.text*) - */py/mpz.o(.text*) - */py/vm.o(.text*) + about 400 bytes. Micropython pads this with files, but this didn't + work with the size of Circuitpython's ff object. */ . = ALIGN(4); } >FLASH_ISR @@ -130,3 +104,5 @@ SECTIONS .ARM.attributes 0 : { *(.ARM.attributes) } } + + diff --git a/ports/stm32f4/boards/STM32F405.ld b/ports/stm32f4/boards/STM32F405_fs.ld similarity index 100% rename from ports/stm32f4/boards/STM32F405.ld rename to ports/stm32f4/boards/STM32F405_fs.ld diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h index a1d83a25af..fb98397a98 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h @@ -40,6 +40,9 @@ #define SPI_FLASH_SCK_PIN (&pin_PB03) #define SPI_FLASH_CS_PIN (&pin_PA15) +// Bootloader only +#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader + #define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SDA (&pin_PB07) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk index 5bad4e81f3..4fa59d70fb 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk @@ -9,11 +9,12 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ +BOOTLOADER_OFFSET = 0x8010000 + MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f405xx MCU_PACKAGE = 64 CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 \ No newline at end of file +LD_FILE = boards/STM32F405_boot.ld # use for bootloader (external fs only) +# LD_FILE = boards/STM32F405_fs.ld # use for internal filesystem \ No newline at end of file diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 340fd9d3b7..8c24222f36 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -20,4 +20,4 @@ MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE LD_FILE = boards/STM32F401_boot.ld -# LD_FILE = boards/STM32F401_fs.ld #use for internal flash \ No newline at end of file +# LD_FILE = boards/STM32F401_fs.ld # use for internal flash \ No newline at end of file From 8a9c3097e3f622d965dfd55b121c4cce6a66344c Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 29 Jan 2020 16:00:38 -0500 Subject: [PATCH 396/531] Add port-specific requested changes --- ports/stm32f4/boards/meowbit_v121/pins.c | 2 +- ports/stm32f4/common-hal/pulseio/PWMOut.c | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c index 1489c23f1c..5d077a04c3 100644 --- a/ports/stm32f4/boards/meowbit_v121/pins.c +++ b/ports/stm32f4/boards/meowbit_v121/pins.c @@ -11,7 +11,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_PA08) }, { MP_ROM_QSTR(MP_QSTR_DISP_RST), MP_ROM_PTR(&pin_PB10) }, - { MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) }, //what is this, backlight? + { MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_BUZZ), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_BTNA), MP_ROM_PTR(&pin_PB09) }, diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c index 29376691bb..50bacbb514 100644 --- a/ports/stm32f4/common-hal/pulseio/PWMOut.c +++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c @@ -69,7 +69,6 @@ STATIC uint32_t timer_get_source_freq(uint32_t tim_id) { STATIC uint32_t timer_get_internal_duty(uint16_t duty, uint32_t period) { //duty cycle is duty/0xFFFF fraction x (number of pulses per period) - //Note that pulses are inverted, so duty cycle is inverted return (duty*period) / ((1 << 16) - 1); } @@ -114,11 +113,12 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, bool first_time_setup = true; for (uint i = 0; i < tim_num; i++) { - uint8_t l_tim_index = mcu_tim_pin_list[i].tim_index - 1; - uint8_t l_tim_channel = mcu_tim_pin_list[i].channel_index - 1; + const mcu_tim_pin_obj_t * l_tim = &mcu_tim_pin_list[i]; + uint8_t l_tim_index = l_tim->tim_index - 1; + uint8_t l_tim_channel = l_tim->channel_index - 1; //if pin is same - if (mcu_tim_pin_list[i].pin == pin) { + if (l_tim->pin == pin) { //check if the timer has a channel active if (reserved_tim[l_tim_index] != 0) { //is it the same channel? (or all channels reserved by a var-freq) @@ -139,7 +139,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, first_time_setup = false; //skip setting up the timer } //No problems taken, so set it up - self->tim = &mcu_tim_pin_list[i]; + self->tim = l_tim; break; } } @@ -205,9 +205,6 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, self->chan_handle.Pulse = timer_get_internal_duty(duty, period); self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH; self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE; - self->chan_handle.OCNPolarity = TIM_OCNPOLARITY_LOW; // needed for TIM1 and TIM8 - self->chan_handle.OCIdleState = TIM_OCIDLESTATE_SET; // needed for TIM1 and TIM8 - self->chan_handle.OCNIdleState = TIM_OCNIDLESTATE_SET; // needed for TIM1 and TIM8 if (HAL_TIM_PWM_ConfigChannel(&self->handle, &self->chan_handle, self->channel) != HAL_OK) { mp_raise_ValueError(translate("Could not initialize channel")); } From 100409961aa32e84810d6c86309e66277b4ea902 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 29 Jan 2020 16:29:43 -0500 Subject: [PATCH 397/531] Move board_init to main.c --- main.c | 5 +++++ ports/atmel-samd/supervisor/port.c | 3 --- ports/mimxrt10xx/supervisor/port.c | 3 --- ports/nrf/supervisor/port.c | 3 --- ports/stm32f4/supervisor/port.c | 1 - 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index 805888dddf..52870cc8e2 100755 --- a/main.c +++ b/main.c @@ -57,6 +57,8 @@ #include "supervisor/shared/stack.h" #include "supervisor/serial.h" +#include "boards/board.h" + #if CIRCUITPY_DISPLAYIO #include "shared-module/displayio/__init__.h" #endif @@ -425,6 +427,9 @@ int __attribute__((used)) main(void) { // no SPI flash filesystem, and we might erase the existing one. filesystem_init(safe_mode == NO_SAFE_MODE, false); + // displays init after filesystem, since they could share the flash SPI + board_init(); + // Reset everything and prep MicroPython to run boot.py. reset_port(); reset_board(); diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 5662b159bc..dd812dfeb2 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -232,9 +232,6 @@ safe_mode_t port_init(void) { // Reset everything into a known state before board_init. reset_port(); - // Init the board last so everything else is ready - board_init(); - #ifdef SAMD21 if (PM->RCAUSE.bit.BOD33 == 1 || PM->RCAUSE.bit.BOD12 == 1) { return BROWNOUT; diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 3573074279..0399ee61d7 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -76,9 +76,6 @@ safe_mode_t port_init(void) { // Reset everything into a known state before board_init. reset_port(); - // Init the board last so everything else is ready - board_init(); - if (board_requests_safe_mode()) { return USER_SAFE_MODE; } diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index af858aa4a1..637ab8c36f 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -92,9 +92,6 @@ safe_mode_t port_init(void) { rtc_init(); #endif - // Will do usb_init() if chip supports USB. - board_init(); - return NO_SAFE_MODE; } diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c index df5a70cd12..19520255e4 100644 --- a/ports/stm32f4/supervisor/port.c +++ b/ports/stm32f4/supervisor/port.c @@ -50,7 +50,6 @@ safe_mode_t port_init(void) { stm32f4_peripherals_gpio_init(); tick_init(); - board_init(); return NO_SAFE_MODE; } From 1a25d3ca83e1c50c44d8d6179e4fe092fe96a401 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 29 Jan 2020 18:46:14 -0500 Subject: [PATCH 398/531] fix merge issue --- ports/stm32f4/supervisor/port.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c index 397923f234..e9e4720d77 100644 --- a/ports/stm32f4/supervisor/port.c +++ b/ports/stm32f4/supervisor/port.c @@ -51,8 +51,6 @@ safe_mode_t port_init(void) { tick_init(); - board_init(); - return NO_SAFE_MODE; } From 5d24ade5c9f7b1771b5b914835bd7ededc6fcdc0 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 29 Jan 2020 17:32:07 -0800 Subject: [PATCH 399/531] Tweak error messages to reduce code size. --- locale/ID.po | 42 ++------------- locale/circuitpython.pot | 42 ++------------- locale/de_DE.po | 58 +++++++-------------- locale/en_US.po | 42 ++------------- locale/en_x_pirate.po | 42 ++------------- locale/es.po | 65 ++++++++++------------- locale/fil.po | 56 ++++++-------------- locale/fr.po | 65 ++++++++++------------- locale/it_IT.po | 56 ++++++-------------- locale/ko.po | 42 ++------------- locale/pl.po | 63 +++++++++------------- locale/pt_BR.po | 42 ++------------- locale/zh_Latn_pinyin.po | 66 ++++++++++-------------- ports/atmel-samd/common-hal/busio/UART.c | 2 +- py/objstr.c | 4 +- shared-bindings/displayio/I2CDisplay.c | 2 +- 16 files changed, 187 insertions(+), 502 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 6bdb0d4c04..36bfc4df64 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -512,11 +512,8 @@ msgstr "Clock unit sedang digunakan" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -661,10 +658,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -692,11 +685,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Gagal untuk mengalokasikan buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1148,10 +1141,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Tambahkan module apapun pada filesystem\n" @@ -1203,10 +1192,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1632,11 +1617,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2528,10 +2508,6 @@ msgstr "" msgid "queue overflow" msgstr "antrian meluap (overflow)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" @@ -2765,16 +2741,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "tipe tidak diketahui" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 35cd63edd8..f85bcba83f 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -502,11 +502,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -650,10 +647,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -681,11 +674,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1136,10 +1129,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1189,10 +1178,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1609,11 +1594,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2503,10 +2483,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2739,16 +2715,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 8fa78d64e6..ba1915e430 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -506,11 +506,8 @@ msgstr "Clock unit wird benutzt" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Spalteneintrag muss digitalio.DigitalInOut sein" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "Der Befehl muss zwischen 0 und 255 liegen" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Der Befehl muss ein int zwischen 0 und 255 sein" @@ -654,10 +651,6 @@ msgstr "Erwartet ein(e) %q" msgid "Expected a Characteristic" msgstr "Characteristic wird erwartet" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Ein Service wird erwartet" @@ -685,11 +678,11 @@ msgstr "Kommando nicht gesendet." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Konnte keinen RX Buffer allozieren" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1151,10 +1144,6 @@ msgstr "Zugang verweigert" msgid "Pin does not have ADC capabilities" msgstr "Pin hat keine ADC Funktionalität" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Pixel außerhalb der Puffergrenzen" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "und alle Module im Dateisystem \n" @@ -1206,10 +1195,6 @@ msgstr "Eine RTC wird auf diesem Board nicht unterstützt" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "Bereich außerhalb der Grenzen" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Nur lesen möglich, da Schreibgeschützt" @@ -1637,11 +1622,6 @@ msgstr "Es müssen 8 oder 16 bits_per_sample sein" msgid "branch not in range" msgstr "Zweig ist außerhalb der Reichweite" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "buf ist zu klein. brauche %d Bytes" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "Puffer muss ein bytes-artiges Objekt sein" @@ -2541,10 +2521,6 @@ msgstr "" msgid "queue overflow" msgstr "Warteschlangenüberlauf" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "rawbuf hat nicht die gleiche Größe wie buf" - #: py/builtinimport.c msgid "relative import" msgstr "relativer Import" @@ -2784,16 +2760,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "unbekannter Typ" @@ -2921,6 +2887,9 @@ msgstr "" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Characteristic wird bereits von einem anderen Dienst verwendet." +#~ msgid "Command must be 0-255" +#~ msgstr "Der Befehl muss zwischen 0 und 255 liegen" + #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Konnte ble_uuid nicht decodieren. Status: 0x%04x" @@ -3122,6 +3091,12 @@ msgstr "" #~ msgid "Pins not valid for SPI" #~ msgstr "Pins nicht gültig für SPI" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Pixel außerhalb der Puffergrenzen" + +#~ msgid "Range out of bounds" +#~ msgstr "Bereich außerhalb der Grenzen" + #~ msgid "STA must be active" #~ msgstr "STA muss aktiv sein" @@ -3192,6 +3167,10 @@ msgstr "" #~ "Sie laufen im abgesicherten Modus, was bedeutet, dass etwas Unerwartetes " #~ "passiert ist.\n" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "buf ist zu klein. brauche %d Bytes" + #~ msgid "buffer too long" #~ msgstr "Buffer zu lang" @@ -3251,6 +3230,9 @@ msgstr "" #~ msgid "pin does not have IRQ capabilities" #~ msgstr "Pin hat keine IRQ Fähigkeiten" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "rawbuf hat nicht die gleiche Größe wie buf" + #~ msgid "readonly attribute" #~ msgstr "Readonly-Attribut" diff --git a/locale/en_US.po b/locale/en_US.po index df73627e69..c6a78b505b 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -502,11 +502,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -650,10 +647,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -681,11 +674,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1136,10 +1129,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1189,10 +1178,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1609,11 +1594,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2503,10 +2483,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2739,16 +2715,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 58fdf9f704..12ca1d6082 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -506,11 +506,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -654,10 +651,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -685,11 +678,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1140,10 +1133,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "Belay that! Th' Pin be not ADC capable" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1193,10 +1182,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1613,11 +1598,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2507,10 +2487,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2743,16 +2719,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/es.po b/locale/es.po index 6521921a97..b4e0981650 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -508,11 +508,8 @@ msgstr "Clock unit está siendo utilizado" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Entrada de columna debe ser digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Command debe estar entre 0 y 255." @@ -656,10 +653,6 @@ msgstr "Se espera un %q" msgid "Expected a Characteristic" msgstr "Se esperaba una Característica." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -687,11 +680,11 @@ msgstr "Fallo enviando comando" msgid "Failed to acquire mutex, err 0x%04x" msgstr "No se puede adquirir el mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Ha fallado la asignación del buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1150,10 +1143,6 @@ msgstr "Permiso denegado" msgid "Pin does not have ADC capabilities" msgstr "Pin no tiene capacidad ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Pixel beyond bounds of buffer" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1205,11 +1194,6 @@ msgstr "RTC no soportado en esta placa" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "address fuera de límites" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Solo-lectura" @@ -1634,11 +1618,6 @@ msgstr "bits_per_sample debe ser 8 ó 16" msgid "branch not in range" msgstr "El argumento de chr() no esta en el rango(256)" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "buf es demasiado pequeño. necesita %d bytes" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "buffer debe de ser un objeto bytes-like" @@ -2542,10 +2521,6 @@ msgstr "pow() con 3 argumentos requiere enteros" msgid "queue overflow" msgstr "desbordamiento de cola(queue)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "rawbuf no es el mismo tamaño que buf" - #: py/builtinimport.c msgid "relative import" msgstr "import relativo" @@ -2781,16 +2756,6 @@ msgstr "especificador de conversión %c desconocido" msgid "unknown format code '%c' for object of type '%s'" msgstr "codigo format desconocido '%c' para el typo de objeto '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "codigo format desconocido '%c' para el typo de objeto 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "codigo format desconocido '%c' para objeto de tipo 'str'" - #: py/compile.c msgid "unknown type" msgstr "tipo desconocido" @@ -3143,6 +3108,13 @@ msgstr "paso cero" #~ msgid "Pins not valid for SPI" #~ msgstr "Pines no válidos para SPI" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Pixel beyond bounds of buffer" + +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "address fuera de límites" + #~ msgid "STA must be active" #~ msgstr "STA debe estar activo" @@ -3222,6 +3194,10 @@ msgstr "paso cero" #~ msgid "bad GATT role" #~ msgstr "mal GATT role" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "buf es demasiado pequeño. necesita %d bytes" + #~ msgid "buffer too long" #~ msgstr "buffer demasiado largo" @@ -3305,6 +3281,9 @@ msgstr "paso cero" #~ msgid "position must be 2-tuple" #~ msgstr "posición debe ser 2-tuple" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "rawbuf no es el mismo tamaño que buf" + #, fuzzy #~ msgid "readonly attribute" #~ msgstr "atributo no legible" @@ -3333,6 +3312,14 @@ msgstr "paso cero" #~ msgid "unknown config param" #~ msgstr "parámetro config desconocido" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "codigo format desconocido '%c' para el typo de objeto 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "codigo format desconocido '%c' para objeto de tipo 'str'" + #~ msgid "unknown status param" #~ msgstr "status param desconocido" diff --git a/locale/fil.po b/locale/fil.po index 69d7e169a4..86378ba107 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -510,11 +510,8 @@ msgstr "Clock unit ginagamit" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "Sa gitna ng 0 o 255 dapat ang bytes." @@ -663,10 +660,6 @@ msgstr "Umasa ng %q" msgid "Expected a Characteristic" msgstr "Hindi mabasa and Characteristic." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -695,11 +688,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Nabigong ilaan ang RX buffer" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1156,10 +1149,6 @@ msgstr "Walang pahintulot" msgid "Pin does not have ADC capabilities" msgstr "Ang pin ay walang kakayahan sa ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Kasama ang kung ano pang modules na sa filesystem\n" @@ -1211,11 +1200,6 @@ msgstr "Hindi supportado ang RTC sa board na ito" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "wala sa sakop ang address" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Basahin-lamang" @@ -1643,11 +1627,6 @@ msgstr "bits_per_sample ay dapat 8 o 16" msgid "branch not in range" msgstr "branch wala sa range" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "buffer ay dapat bytes-like object" @@ -2556,10 +2535,6 @@ msgstr "pow() na may 3 argumento kailangan ng integers" msgid "queue overflow" msgstr "puno na ang pila (overflow)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" @@ -2796,16 +2771,6 @@ msgstr "hindi alam ang conversion specifier na %c" msgid "unknown format code '%c' for object of type '%s'" msgstr "hindi alam ang format code '%c' para sa object na ang type ay '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "hindi alam ang format code '%c' sa object na ang type ay 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "hindi alam ang format ng code na '%c' para sa object ng type ay 'str'" - #: py/compile.c msgid "unknown type" msgstr "hindi malaman ang type (unknown type)" @@ -3123,6 +3088,10 @@ msgstr "zero step" #~ msgid "Pins not valid for SPI" #~ msgstr "Mali ang pins para sa SPI" +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "wala sa sakop ang address" + #~ msgid "STA must be active" #~ msgstr "Dapat aktibo ang STA" @@ -3285,6 +3254,15 @@ msgstr "zero step" #~ msgid "unknown config param" #~ msgstr "hindi alam na config param" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "hindi alam ang format code '%c' sa object na ang type ay 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "" +#~ "hindi alam ang format ng code na '%c' para sa object ng type ay 'str'" + #~ msgid "unknown status param" #~ msgstr "hindi alam na status param" diff --git a/locale/fr.po b/locale/fr.po index a9124679f3..b522b253da 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -515,11 +515,8 @@ msgstr "Horloge en cours d'utilisation" msgid "Column entry must be digitalio.DigitalInOut" msgstr "L'entrée 'Column' doit être un digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "La commande doit être un entier entre 0 et 255" @@ -666,10 +663,6 @@ msgstr "Attendu un %q" msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -698,11 +691,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Echec de l'obtention de mutex, err 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Echec de l'allocation du tampon RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1170,10 +1163,6 @@ msgstr "Permission refusée" msgid "Pin does not have ADC capabilities" msgstr "La broche ne peut être utilisée pour l'ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Pixel au-delà des limites du tampon" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1224,11 +1213,6 @@ msgstr "RTC non supportée sur cette carte" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "adresse hors limites" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Lecture seule" @@ -1662,11 +1646,6 @@ msgstr "'bits_per_sample' doivent être 8 ou 16" msgid "branch not in range" msgstr "branche hors-bornes" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "'buf' est trop petit. Besoin de %d octets" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "le tampon doit être un objet bytes-like" @@ -2589,10 +2568,6 @@ msgstr "pow() avec 3 arguments nécessite des entiers" msgid "queue overflow" msgstr "dépassement de file" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "'rawbuf' n'est pas de la même taille que 'buf'" - #: py/builtinimport.c msgid "relative import" msgstr "import relatif" @@ -2830,16 +2805,6 @@ msgstr "spécification %c de conversion inconnue" msgid "unknown format code '%c' for object of type '%s'" msgstr "code de format '%c' inconnu pour un objet de type '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "code de format '%c' inconnu pour un objet de type 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "code de format '%c' inconnu pour un objet de type 'str'" - #: py/compile.c msgid "unknown type" msgstr "type inconnu" @@ -3201,6 +3166,13 @@ msgstr "'step' nul" #~ msgid "Pins not valid for SPI" #~ msgstr "Broche invalide pour le SPI" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Pixel au-delà des limites du tampon" + +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "adresse hors limites" + #~ msgid "STA must be active" #~ msgstr "'STA' doit être actif" @@ -3281,6 +3253,10 @@ msgstr "'step' nul" #~ msgid "bad GATT role" #~ msgstr "mauvais rôle GATT" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "'buf' est trop petit. Besoin de %d octets" + #~ msgid "buffer too long" #~ msgstr "tampon trop long" @@ -3364,6 +3340,9 @@ msgstr "'step' nul" #~ msgid "position must be 2-tuple" #~ msgstr "position doit être un 2-tuple" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "'rawbuf' n'est pas de la même taille que 'buf'" + #, fuzzy #~ msgid "readonly attribute" #~ msgstr "attribut en lecture seule" @@ -3389,6 +3368,14 @@ msgstr "'step' nul" #~ msgid "unknown config param" #~ msgstr "paramètre de config. inconnu" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "code de format '%c' inconnu pour un objet de type 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "code de format '%c' inconnu pour un objet de type 'str'" + #~ msgid "unknown status param" #~ msgstr "paramètre de statut inconnu" diff --git a/locale/it_IT.po b/locale/it_IT.po index 6164f6cf83..e4a06b7691 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -511,11 +511,8 @@ msgstr "Unità di clock in uso" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "I byte devono essere compresi tra 0 e 255" @@ -663,10 +660,6 @@ msgstr "Atteso un %q" msgid "Expected a Characteristic" msgstr "Non è possibile aggiungere Characteristic." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -695,11 +688,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Impossibile allocare buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1165,10 +1158,6 @@ msgstr "Permesso negato" msgid "Pin does not have ADC capabilities" msgstr "Il pin non ha capacità di ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1220,11 +1209,6 @@ msgstr "RTC non supportato su questa scheda" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "indirizzo fuori limite" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Sola lettura" @@ -1648,11 +1632,6 @@ msgstr "i bit devono essere 7, 8 o 9" msgid "branch not in range" msgstr "argomento di chr() non è in range(256)" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2563,10 +2542,6 @@ msgstr "pow() con 3 argomenti richiede interi" msgid "queue overflow" msgstr "overflow della coda" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "importazione relativa" @@ -2803,16 +2778,6 @@ msgstr "specificatore di conversione %s sconosciuto" msgid "unknown format code '%c' for object of type '%s'" msgstr "codice di formattaione '%c' sconosciuto per oggetto di tipo '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "codice di formattazione '%c' sconosciuto per oggetto di tipo 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "codice di formattazione '%c' sconosciuto per oggetto di tipo 'str'" - #: py/compile.c msgid "unknown type" msgstr "tipo sconosciuto" @@ -3134,6 +3099,10 @@ msgstr "zero step" #~ msgid "Pins not valid for SPI" #~ msgstr "Pin non validi per SPI" +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "indirizzo fuori limite" + #~ msgid "STA must be active" #~ msgstr "STA deve essere attiva" @@ -3272,6 +3241,15 @@ msgstr "zero step" #~ msgid "unknown config param" #~ msgstr "parametro di configurazione sconosciuto" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "" +#~ "codice di formattazione '%c' sconosciuto per oggetto di tipo 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "codice di formattazione '%c' sconosciuto per oggetto di tipo 'str'" + #~ msgid "unknown status param" #~ msgstr "prametro di stato sconosciuto" diff --git a/locale/ko.po b/locale/ko.po index ee48006266..fa49366825 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -506,11 +506,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "명령은 0에서 255 사이의 정수(int) 여야합니다" @@ -654,10 +651,6 @@ msgstr "%q 이 예상되었습니다." msgid "Expected a Characteristic" msgstr "특성(Characteristic)이 예상되었습니다." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -685,11 +678,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1140,10 +1133,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1193,10 +1182,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1614,11 +1599,6 @@ msgstr "bits_per_sample은 8 또는 16이어야합니다." msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2508,10 +2488,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2744,16 +2720,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 6a009357d5..70106112ed 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -505,11 +505,8 @@ msgstr "Jednostka zegara w użyciu" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Kolumny muszą być typu digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Komenda musi być int pomiędzy 0 a 255" @@ -653,10 +650,6 @@ msgstr "Oczekiwano %q" msgid "Expected a Characteristic" msgstr "Oczekiwano charakterystyki" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -684,11 +677,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nie udało się uzyskać blokady, błąd 0x$04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Nie udała się alokacja bufora RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1141,10 +1134,6 @@ msgstr "Odmowa dostępu" msgid "Pin does not have ADC capabilities" msgstr "Nóżka nie obsługuje ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Piksel poza granicami bufora" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Oraz moduły w systemie plików\n" @@ -1194,10 +1183,6 @@ msgstr "Brak obsługi RTC" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "Zakres poza granicami" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Tylko do odczytu" @@ -1617,11 +1602,6 @@ msgstr "bits_per_sample musi być 8 lub 16" msgid "branch not in range" msgstr "skok poza zakres" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "buf zbyt mały. Wymagane %d bajtów" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "bufor mysi być typu bytes" @@ -2513,10 +2493,6 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" msgid "queue overflow" msgstr "przepełnienie kolejki" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "rawbuf nie jest tej samej wielkości co buf" - #: py/builtinimport.c msgid "relative import" msgstr "relatywny import" @@ -2750,16 +2726,6 @@ msgstr "zła specyfikacja konwersji %c" msgid "unknown format code '%c' for object of type '%s'" msgstr "zły kod formatowania '%c' dla obiektu typu '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "zły kod foratowania '%c' dla obiektu typu 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "zły kod formatowania '%c' dla obiektu typu 'str'" - #: py/compile.c msgid "unknown type" msgstr "zły typ" @@ -3009,6 +2975,12 @@ msgstr "zerowy krok" #~ msgid "Only slices with step=1 (aka None) are supported" #~ msgstr "Wspierane są tylko fragmenty z step=1 (albo None)" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Piksel poza granicami bufora" + +#~ msgid "Range out of bounds" +#~ msgstr "Zakres poza granicami" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Soft device assert, id: 0x%08lX, pc: 0x%08lX" @@ -3063,6 +3035,10 @@ msgstr "zerowy krok" #~ msgid "bad GATT role" #~ msgstr "zła rola GATT" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "buf zbyt mały. Wymagane %d bajtów" + #, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "byteorder musi być typu ByteOrder (jest %s)" @@ -3077,6 +3053,9 @@ msgstr "zerowy krok" #~ msgid "name must be a string" #~ msgstr "nazwa musi być łańcuchem" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "rawbuf nie jest tej samej wielkości co buf" + #~ msgid "services includes an object that is not a Service" #~ msgstr "obiekt typu innego niż Service w services" @@ -3089,5 +3068,13 @@ msgstr "zerowy krok" #~ msgid "timeout >100 (units are now seconds, not msecs)" #~ msgstr "timeout > 100 (jednostkami są sekundy)" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "zły kod foratowania '%c' dla obiektu typu 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "zły kod formatowania '%c' dla obiektu typu 'str'" + #~ msgid "write_args must be a list, tuple, or None" #~ msgstr "write_args musi być listą, krotką lub None" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 0d6592201e..755dc6d972 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -507,11 +507,8 @@ msgstr "Unidade de Clock em uso" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "Os bytes devem estar entre 0 e 255." @@ -658,10 +655,6 @@ msgstr "Esperado um" msgid "Expected a Characteristic" msgstr "Não é possível adicionar Característica." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -690,11 +683,11 @@ msgstr "Falha ao enviar comando." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Falha ao alocar buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1151,10 +1144,6 @@ msgstr "Permissão negada" msgid "Pin does not have ADC capabilities" msgstr "O pino não tem recursos de ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1205,10 +1194,6 @@ msgstr "O RTC não é suportado nesta placa" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Somente leitura" @@ -1629,11 +1614,6 @@ msgstr "bits devem ser 8" msgid "branch not in range" msgstr "Calibração está fora do intervalo" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2525,10 +2505,6 @@ msgstr "" msgid "queue overflow" msgstr "estouro de fila" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2763,16 +2739,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index d3ecc630c4..369ce4426c 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -506,11 +506,8 @@ msgstr "Shǐyòng shízhōng dānwèi" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Liè tiáomù bìxū shì digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "Mìnglìng bìxū wèi 0-255" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Mìnglìng bìxū shì 0 dào 255 zhī jiān de int" @@ -654,10 +651,6 @@ msgstr "Yùqí %q" msgid "Expected a Characteristic" msgstr "Yùqí de tèdiǎn" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Yùqí fúwù" @@ -685,11 +678,11 @@ msgstr "Fāsòng mìnglìng shībài." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Wúfǎ huòdé mutex, err 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Fēnpèi RX huǎnchōng shībài" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1146,10 +1139,6 @@ msgstr "Quánxiàn bèi jùjué" msgid "Pin does not have ADC capabilities" msgstr "Pin méiyǒu ADC nénglì" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Xiàngsù chāochū huǎnchōng qū biānjiè" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Zài wénjiàn xìtǒng shàng tiānjiā rènhé mókuài\n" @@ -1199,10 +1188,6 @@ msgstr "Cǐ bǎn bù zhīchí RTC" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "Fànwéi chāochū biānjiè" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Zhǐ dú" @@ -1626,11 +1611,6 @@ msgstr "měi jiàn yàngběn bìxū wèi 8 huò 16" msgid "branch not in range" msgstr "fēnzhī bùzài fànwéi nèi" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "huǎnchōng tài xiǎo. Xūyào%d zì jié" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "huǎnchōng qū bìxū shì zì jié lèi duìxiàng" @@ -2525,10 +2505,6 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" msgid "queue overflow" msgstr "duìliè yìchū" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "yuánshǐ huǎnchōng qū hé huǎnchōng qū de dàxiǎo bùtóng" - #: py/builtinimport.c msgid "relative import" msgstr "xiāngduì dǎorù" @@ -2763,16 +2739,6 @@ msgstr "wèizhī de zhuǎnhuàn biāozhù %c" msgid "unknown format code '%c' for object of type '%s'" msgstr "lèixíng '%s' duìxiàng wèizhī de géshì dàimǎ '%c'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "lèixíng 'float' duìxiàng wèizhī de géshì dàimǎ '%c'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "lèixíng 'str' duìxiàng wèizhī de géshì dàimǎ '%c'" - #: py/compile.c msgid "unknown type" msgstr "wèizhī lèixíng" @@ -2888,6 +2854,9 @@ msgstr "líng bù" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Qítā fúwù bùmén yǐ shǐyòng de gōngnéng." +#~ msgid "Command must be 0-255" +#~ msgstr "Mìnglìng bìxū wèi 0-255" + #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Wúfǎ jiěmǎ kě dú_uuid, err 0x%04x" @@ -3060,6 +3029,12 @@ msgstr "líng bù" #~ msgid "Only slices with step=1 (aka None) are supported" #~ msgstr "Jǐn zhīchí 1 bù qiēpiàn" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Xiàngsù chāochū huǎnchōng qū biānjiè" + +#~ msgid "Range out of bounds" +#~ msgstr "Fànwéi chāochū biānjiè" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Ruǎn shèbèi wéihù, id: 0X%08lX, pc: 0X%08lX" @@ -3116,6 +3091,10 @@ msgstr "líng bù" #~ msgid "bad GATT role" #~ msgstr "zǒng xiédìng de bùliáng juésè" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "huǎnchōng tài xiǎo. Xūyào%d zì jié" + #, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "zì jié bùshì zì jié xù shílì (yǒu %s)" @@ -3132,6 +3111,9 @@ msgstr "líng bù" #~ msgid "name must be a string" #~ msgstr "míngchēng bìxū shì yīgè zìfú chuàn" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "yuánshǐ huǎnchōng qū hé huǎnchōng qū de dàxiǎo bùtóng" + #~ msgid "row must be packed and word aligned" #~ msgstr "xíng bìxū dǎbāo bìngqiě zì duìqí" @@ -3150,6 +3132,14 @@ msgstr "líng bù" #~ msgid "too many arguments" #~ msgstr "tài duō cānshù" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "lèixíng 'float' duìxiàng wèizhī de géshì dàimǎ '%c'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "lèixíng 'str' duìxiàng wèizhī de géshì dàimǎ '%c'" + #~ msgid "unsupported bitmap type" #~ msgstr "bù zhīchí de bitmap lèixíng" diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 4ad47a58da..70857de6de 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -150,7 +150,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->buffer = (uint8_t *) gc_alloc(self->buffer_length * sizeof(uint8_t), false, true); if (self->buffer == NULL) { common_hal_busio_uart_deinit(self); - mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); + mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), self->buffer_length * sizeof(uint8_t)); } } else { self->buffer_length = 0; diff --git a/py/objstr.c b/py/objstr.c index fde2646815..a60f507e99 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -1352,7 +1352,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar terse_str_format_value_error(); } else { mp_raise_ValueError_varg( - translate("unknown format code '%c' for object of type 'float'"), + translate("unknown format code '%c' for object of type '%s'"), type, mp_obj_get_type_str(arg)); } } @@ -1388,7 +1388,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar terse_str_format_value_error(); } else { mp_raise_ValueError_varg( - translate("unknown format code '%c' for object of type 'str'"), + translate("unknown format code '%c' for object of type '%s'"), type, mp_obj_get_type_str(arg)); } } diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index 4339d182f4..9b863f6567 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -118,7 +118,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_i2cdisplay_reset_obj, displayio_i2cdisplay_o STATIC mp_obj_t displayio_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = MP_OBJ_SMALL_INT_VALUE(command_obj); if (!MP_OBJ_IS_SMALL_INT(command_obj) || command_int > 255 || command_int < 0) { - mp_raise_ValueError(translate("Command must be 0-255")); + mp_raise_ValueError(translate("Command must be an int between 0 and 255")); } uint8_t command = command_int; mp_buffer_info_t bufinfo; From 27c36eea2bbadd1e5df1ef4fd9bf54824068f2c2 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Thu, 30 Jan 2020 15:24:04 +0100 Subject: [PATCH 400/531] circuitpython-stage: allow choosing background color --- frozen/circuitpython-stage | 2 +- shared-bindings/_stage/__init__.c | 11 ++++++++--- shared-module/_stage/__init__.c | 6 +++++- shared-module/_stage/__init__.h | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index 8d5cc38405..19a66d79f0 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit 8d5cc384058b1cb296aaeab86fb8405042d547ed +Subproject commit 19a66d79f0650a15e502464b42e16692365eab36 diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 1154bbbf12..4bac280bf2 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -51,7 +51,7 @@ //| Layer //| Text //| -//| .. function:: render(x0, y0, x1, y1, layers, buffer, display[, scale]) +//| .. function:: render(x0, y0, x1, y1, layers, buffer, display[, scale[, background]]) //| //| Render and send to the display a fragment of the screen. //| @@ -63,6 +63,7 @@ //| :param bytearray buffer: A buffer to use for rendering. //| :param ~displayio.Display display: The display to use. //| :param int scale: How many times should the image be scaled up. +//| :param int background: What color to display when nothing is there. //| //| There are also no sanity checks, outside of the basic overflow //| checking. The caller is responsible for making the passed parameters @@ -92,12 +93,16 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { } displayio_display_obj_t *display = MP_OBJ_TO_PTR(native_display); uint8_t scale = 1; - if (n_args >= 8) { + if (n_args > 7) { scale = mp_obj_get_int(args[7]); } + uint16_t background = 0; + if (n_args > 8) { + background = mp_obj_get_int(args[8]); + } render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, - display, scale); + display, scale, background); return mp_const_none; } diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c index d5da74272f..0323c32cb9 100644 --- a/shared-module/_stage/__init__.c +++ b/shared-module/_stage/__init__.c @@ -34,7 +34,8 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, - displayio_display_obj_t *display, uint8_t scale) { + displayio_display_obj_t *display, + uint8_t scale, uint16_t background) { displayio_area_t area; @@ -68,6 +69,9 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, break; } } + if (c == TRANSPARENT) { + c = background; + } for (uint8_t xscale = 0; xscale < scale; ++xscale) { buffer[index] = c; index += 1; diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h index 5af2124aeb..7a1826200e 100644 --- a/shared-module/_stage/__init__.h +++ b/shared-module/_stage/__init__.h @@ -37,6 +37,7 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, - displayio_display_obj_t *display, uint8_t scale); + displayio_display_obj_t *display, + uint8_t scale, uint16_t background); #endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE From 87f73e2729be3158ea3bb030644cbc42a4913c4c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 30 Jan 2020 09:52:06 -0500 Subject: [PATCH 401/531] track vm_used_ble better --- ports/nrf/bluetooth/ble_drv.c | 3 ++ ports/nrf/common-hal/_bleio/Adapter.c | 8 +++++ ports/nrf/common-hal/_bleio/__init__.c | 10 +++++-- ports/nrf/common-hal/_bleio/bonding.c | 11 +++---- .../nrf/common-hal/microcontroller/__init__.c | 30 +++++++++++++++++++ 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index 28a265b7fe..e410ac3b42 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.c @@ -145,6 +145,9 @@ void SD_EVT_IRQHandler(void) { ble_drv_evt_handler_entry_t *it = MP_STATE_VM(ble_drv_evt_handler_entries); bool done = false; while (it != NULL) { + #if CIRCUITPY_VERBOSE_BLE + // mp_printf(&mp_plat_print, " calling handler: 0x%08lx, param: 0x%08lx\n", it->func-1, it->param); + #endif done = it->func(event, it->param) || done; it = it->next; } diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 361fbbf3b5..c92ce12a52 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -437,6 +437,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t* .active = active }; uint32_t err_code; + vm_used_ble = true; err_code = sd_ble_gap_scan_start(&scan_params, sd_data); if (err_code != NRF_SUCCESS) { @@ -511,6 +512,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre ble_drv_add_event_handler(connect_on_ble_evt, &event_info); event_info.done = false; + vm_used_ble = true; uint32_t err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_CUSTOM); if (err_code != NRF_SUCCESS) { @@ -615,6 +617,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, return err_code; } + vm_used_ble = true; err_code = sd_ble_gap_adv_start(adv_handle, BLE_CONN_CFG_TAG_CUSTOM); if (err_code != NRF_SUCCESS) { return err_code; @@ -709,6 +712,11 @@ void bleio_adapter_reset(bleio_adapter_obj_t* adapter) { adapter->connection_objs = NULL; for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { bleio_connection_internal_t *connection = &bleio_connections[i]; + // Disconnect all connections with Python state cleanly. Keep any supervisor-only connections. + if (connection->connection_obj != mp_const_none && + connection->conn_handle != BLE_CONN_HANDLE_INVALID) { + common_hal_bleio_connection_disconnect(connection); + } connection->connection_obj = mp_const_none; } } diff --git a/ports/nrf/common-hal/_bleio/__init__.c b/ports/nrf/common-hal/_bleio/__init__.c index a000c3e7e5..58e28c8c10 100644 --- a/ports/nrf/common-hal/_bleio/__init__.c +++ b/ports/nrf/common-hal/_bleio/__init__.c @@ -91,13 +91,14 @@ void check_sec_status(uint8_t sec_status) { void bleio_reset() { bleio_adapter_reset(&common_hal_bleio_adapter_obj); if (!vm_used_ble) { + // No user-code BLE operations were done, so we can maintain the supervisor state. return; } if (common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) { common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false); } - supervisor_start_bluetooth(); bonding_reset(); + supervisor_start_bluetooth(); } // The singleton _bleio.Adapter object, bound to _bleio.adapter @@ -195,14 +196,17 @@ size_t common_hal_bleio_gattc_read(uint16_t handle, uint16_t conn_handle, uint8_ while (nrf_error == NRF_ERROR_BUSY) { nrf_error = sd_ble_gattc_read(conn_handle, handle, 0); } - check_nrf_error(nrf_error); + if (nrf_error != NRF_SUCCESS) { + ble_drv_remove_event_handler(_on_gattc_read_rsp_evt, &read_info); + check_nrf_error(nrf_error); + } while (!read_info.done) { RUN_BACKGROUND_TASKS; } - check_gatt_status(read_info.status); ble_drv_remove_event_handler(_on_gattc_read_rsp_evt, &read_info); + check_gatt_status(read_info.status); return read_info.final_len; } diff --git a/ports/nrf/common-hal/_bleio/bonding.c b/ports/nrf/common-hal/_bleio/bonding.c index 9716b3988b..081ba992f3 100644 --- a/ports/nrf/common-hal/_bleio/bonding.c +++ b/ports/nrf/common-hal/_bleio/bonding.c @@ -267,14 +267,15 @@ void bonding_background(void) { for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { bleio_connection_internal_t *connection = &bleio_connections[i]; - uint64_t current_ticks_ms = supervisor_ticks_ms64(); // Wait at least one second before saving CCCD, to consolidate // writes that involve multiple CCCDs. For instance, for HID, // three CCCD's are set in short succession by the HID client. - if (connection->do_bond_cccds && - current_ticks_ms - connection->do_bond_cccds_request_time >= 1000) { - write_sys_attr_block(connection); - connection->do_bond_cccds = false; + if (connection->do_bond_cccds) { + uint64_t current_ticks_ms = supervisor_ticks_ms64(); + if (current_ticks_ms - connection->do_bond_cccds_request_time >= 1000) { + write_sys_attr_block(connection); + connection->do_bond_cccds = false; + } } if (connection->do_bond_keys) { diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index de924566c8..7eb1c06149 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -37,8 +37,10 @@ #include "shared-bindings/microcontroller/Processor.h" #include "supervisor/filesystem.h" +#include "supervisor/port.h" #include "supervisor/shared/safe_mode.h" #include "nrfx_glue.h" +#include "nrf_nvic.h" // This routine should work even when interrupts are disabled. Used by OneWire // for precise timing. @@ -46,10 +48,38 @@ void common_hal_mcu_delay_us(uint32_t delay) { NRFX_DELAY_US(delay); } +static volatile uint32_t nesting_count = 0; +static uint8_t is_nested_critical_region; +static uint8_t sd_is_enabled = false; void common_hal_mcu_disable_interrupts() { + sd_softdevice_is_enabled(&sd_is_enabled); + if (sd_is_enabled) { + sd_nvic_critical_region_enter(&is_nested_critical_region); + } else { + __disable_irq(); + __DMB(); + nesting_count++; + } } void common_hal_mcu_enable_interrupts() { + // Don't check here if SD is enabled, because we'll crash if interrupts + // were turned off and sd_softdevice_is_enabled is called. + if (sd_is_enabled) { + sd_nvic_critical_region_exit(is_nested_critical_region); + } else { + if (nesting_count == 0) { + // This is very very bad because it means there was mismatched disable/enables so we + // crash. + reset_into_safe_mode(HARD_CRASH); + } + nesting_count--; + if (nesting_count > 0) { + return; + } + __DMB(); + __enable_irq(); + } } void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { From 2cc20e8816c6c1571b7488e83e3b13af79d50d65 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 30 Jan 2020 10:59:16 -0800 Subject: [PATCH 402/531] Remove unneeded native cast. --- py/objlist.c | 1 - 1 file changed, 1 deletion(-) diff --git a/py/objlist.c b/py/objlist.c index 9ae9c0ed68..608ea9f6ca 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -46,7 +46,6 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in); - //mp_obj_list_t *o = mp_instance_cast_to_native_base(o_in, &mp_type_list); if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { kind = PRINT_REPR; } From b6358182d3972cd514fa6dad9165e612c6d02f5d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 30 Jan 2020 15:14:05 -0500 Subject: [PATCH 403/531] Update CLUE to Rev C --- .../circuitplayground_bluefruit/mpconfigboard.h | 2 +- .../nrf/boards/clue_nrf52840_express/mpconfigboard.h | 3 ++- ports/nrf/boards/clue_nrf52840_express/pins.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index e401cecc16..17b044b145 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -32,7 +32,7 @@ #define MICROPY_HW_LED_STATUS (&pin_P1_14) -// Unusually, board does not have a 32 kHz xtal. Nearly all boards do. +// Board does not have a 32kHz crystal. It does have a 32MHz crystal. #define BOARD_HAS_32KHZ_XTAL (0) #if QSPI_FLASH_FILESYSTEM diff --git a/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h index a239ca7ce3..9cb05de092 100644 --- a/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/clue_nrf52840_express/mpconfigboard.h @@ -50,7 +50,8 @@ #define SPI_FLASH_CS_PIN &pin_P0_20 #endif -#define BOARD_HAS_CRYSTAL 1 +// No 32kHz crystal. THere's a 32MHz crystal in the nRF module. +#define BOARD_HAS_32KHZ_XTAL (0) #define DEFAULT_I2C_BUS_SCL (&pin_P0_25) #define DEFAULT_I2C_BUS_SDA (&pin_P0_24) diff --git a/ports/nrf/boards/clue_nrf52840_express/pins.c b/ports/nrf/boards/clue_nrf52840_express/pins.c index 2926f46e0b..ab0738893c 100644 --- a/ports/nrf/boards/clue_nrf52840_express/pins.c +++ b/ports/nrf/boards/clue_nrf52840_express/pins.c @@ -86,8 +86,15 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_P0_24) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_24) }, - { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_11) }, - { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P1_08) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_01) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_00) }, + + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_P1_00) }, + + { MP_ROM_QSTR(MP_QSTR_PROXIMITY_LIGHT_INTERRUPT), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_GYRO_INTERRUPT), MP_ROM_PTR(&pin_P1_06) }, + + { MP_ROM_QSTR(MP_QSTR_WHITE_LEDS), MP_ROM_PTR(&pin_P0_10) }, { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_P1_03) }, { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_P1_05) }, From 3b95d7c16a44bc0543d8436e19e792472c654774 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 30 Jan 2020 21:00:47 -0500 Subject: [PATCH 404/531] add gamepad to specialty cpx builds; update frozen libs --- frozen/Adafruit_CircuitPython_BusDevice | 2 +- frozen/Adafruit_CircuitPython_CircuitPlayground | 2 +- frozen/Adafruit_CircuitPython_Crickit | 2 +- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- frozen/Adafruit_CircuitPython_IRRemote | 2 +- frozen/Adafruit_CircuitPython_LIS3DH | 2 +- frozen/Adafruit_CircuitPython_Motor | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- frozen/Adafruit_CircuitPython_SD | 2 +- frozen/Adafruit_CircuitPython_Thermistor | 2 +- frozen/Adafruit_CircuitPython_seesaw | 2 +- .../boards/circuitplayground_express_crickit/mpconfigboard.mk | 2 +- .../boards/circuitplayground_express_displayio/mpconfigboard.mk | 1 - 14 files changed, 13 insertions(+), 14 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 805d41a021..0b0d1e999a 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 805d41a021c70df7609da772a6f6131810e5d6ba +Subproject commit 0b0d1e999a6c7944e55bed59a30ccc21b3c96666 diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index 82ba9e40df..2cf0f40ab8 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit 82ba9e40dfff41fdc0541636afde4936c930d86c +Subproject commit 2cf0f40ab818fddbc2cecf3ec495ed16067c5f7e diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index 5534662902..09bd10e948 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit 5534662902a223ac8562e6f999d6359e4c17dab1 +Subproject commit 09bd10e94894a4eec7e3a02b51ffb5d8581b3024 diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 01e89a8437..84eadeafa9 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 01e89a8437c78b62d4d655c745ded57e26dc747a +Subproject commit 84eadeafa9144829b8c6faf903b4282d58a77353 diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index 2d1dce6ad6..f044548d6d 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit 2d1dce6ad6ca7e091fd8b5c3f102693c24af8b88 +Subproject commit f044548d6d3aa21650b50232bb16e0b29f540b8f diff --git a/frozen/Adafruit_CircuitPython_IRRemote b/frozen/Adafruit_CircuitPython_IRRemote index 8b7611a2cc..9dac9628e4 160000 --- a/frozen/Adafruit_CircuitPython_IRRemote +++ b/frozen/Adafruit_CircuitPython_IRRemote @@ -1 +1 @@ -Subproject commit 8b7611a2cc076a2ac1b368c70227519f69f1e3e9 +Subproject commit 9dac9628e48675308d447b70b2005f7d1f0ddf6b diff --git a/frozen/Adafruit_CircuitPython_LIS3DH b/frozen/Adafruit_CircuitPython_LIS3DH index 53146ab2e8..42a55eafcb 160000 --- a/frozen/Adafruit_CircuitPython_LIS3DH +++ b/frozen/Adafruit_CircuitPython_LIS3DH @@ -1 +1 @@ -Subproject commit 53146ab2e82c318c3c37bd76bac34035a597b311 +Subproject commit 42a55eafcb29f563b31e23af902c31dac8289900 diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index f69fc9b47f..ddcd1e7154 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit f69fc9b47fa25ba1414eb3d5c82f05013280c0d2 +Subproject commit ddcd1e7154f1b27f9a87daffb6e691e1e7051b64 diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index ff99d55115..10db851c81 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit ff99d55115f81899902c2c4a84fdfbea9ae83823 +Subproject commit 10db851c81873fd8db207ff0c4d9342426ee25a4 diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD index dd0fe8530a..efd548b1e3 160000 --- a/frozen/Adafruit_CircuitPython_SD +++ b/frozen/Adafruit_CircuitPython_SD @@ -1 +1 @@ -Subproject commit dd0fe8530a2dcc64ac95bb3e116af2158dcd7cd2 +Subproject commit efd548b1e36c534bbce494f4cb0d9a625dd170cd diff --git a/frozen/Adafruit_CircuitPython_Thermistor b/frozen/Adafruit_CircuitPython_Thermistor index 2e5aedf18e..ac83a3dc70 160000 --- a/frozen/Adafruit_CircuitPython_Thermistor +++ b/frozen/Adafruit_CircuitPython_Thermistor @@ -1 +1 @@ -Subproject commit 2e5aedf18eb417a4120d4998ac1f387a4f600730 +Subproject commit ac83a3dc703ec50b2236c773d22c47a0c0aaba43 diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index ea5e445edd..dc01285aa4 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit ea5e445edd4441cacd207aa2d2bfd724b813a253 +Subproject commit dc01285aa45dd8260bb3ae35a657e4cdcbf325b8 diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index 04b4b7792e..1516c149b9 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -14,9 +14,9 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" LONGINT_IMPL = NONE CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 55 diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index b5a7c2424d..d65dc993f7 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -16,7 +16,6 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CSLAVE = 0 CIRCUITPY_PIXELBUF = 0 -CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 From b4dcecb266bd1aba0a94d11ac6d8a044f6822b69 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 31 Jan 2020 13:12:58 -0500 Subject: [PATCH 405/531] Add build option for UF2 flash offset --- ports/stm32f4/Makefile | 49 ++++++++++++------- .../feather_stm32f405_express/mpconfigboard.h | 4 +- .../mpconfigboard.mk | 8 +-- .../boards/pyboard_v11/mpconfigboard.mk | 3 +- .../stm32f411ce_blackpill/mpconfigboard.mk | 3 +- .../stm32f411ve_discovery/mpconfigboard.mk | 2 - .../stm32f412zg_discovery/mpconfigboard.mk | 3 +- 7 files changed, 41 insertions(+), 31 deletions(-) diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index ccadeac8a4..082d050390 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -26,11 +26,11 @@ # Select the board to build for. ifeq ($(BOARD),) - $(error You must provide a BOARD parameter) + $(error You must provide a BOARD parameter) else - ifeq ($(wildcard boards/$(BOARD)/.),) - $(error Invalid BOARD specified) - endif + ifeq ($(wildcard boards/$(BOARD)/.),) + $(error Invalid BOARD specified) + endif endif # If the build directory is not given, make it reflect the board name. @@ -80,19 +80,16 @@ INC += -I../../supervisor/shared/usb #Debugging/Optimization ifeq ($(DEBUG), 1) - CFLAGS += -ggdb - # You may want to enable these flags to make setting breakpoints easier. - CFLAGS += -fno-inline -fno-ipa-sra + CFLAGS += -ggdb + # You may want to enable these flags to make setting breakpoints easier. + CFLAGS += -fno-inline -fno-ipa-sra else - CFLAGS += -Os -DNDEBUG - CFLAGS += -ggdb - # TODO: Test with -flto - ### CFLAGS += -flto + CFLAGS += -Os -DNDEBUG + CFLAGS += -ggdb + # TODO: Test with -flto + ### CFLAGS += -flto endif -ifndef BOOTLOADER_OFFSET - BOOTLOADER_OFFSET := 0x8000000 -endif C_DEFS = -DMCU_PACKAGE=$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(CMSIS_MCU) @@ -115,6 +112,22 @@ CFLAGS += \ # TODO: check this CFLAGS += -D__START=main +#need both command and valid file to use uf2 bootloader +ifndef LD_FILE + ifneq ($(and $(UF2_BOOTLOADER),$(LD_BOOT)),) + LD_FILE = $(LD_BOOT) + BOOTLOADER_OFFSET = $(UF2_OFFSET) + CFLAGS += -DUF2_BOOTLOADER_ENABLED + else + LD_FILE = $(LD_FS) + endif +endif + +# Add bootloader specific items +ifndef BOOTLOADER_OFFSET + BOOTLOADER_OFFSET := 0x8000000 +endif + LDFLAGS = $(CFLAGS) -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LIBS := -lgcc -lc @@ -210,12 +223,12 @@ SRC_S = \ boards/startup_$(MCU_SUB_VARIANT).s SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \ - $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \ - $(addprefix common-hal/, $(SRC_COMMON_HAL)) + $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \ + $(addprefix common-hal/, $(SRC_COMMON_HAL)) SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \ - $(addprefix shared-module/, $(SRC_SHARED_MODULE)) \ - $(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL)) + $(addprefix shared-module/, $(SRC_SHARED_MODULE)) \ + $(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL)) ifneq ($(FROZEN_MPY_DIR),) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h index fb98397a98..ad9bba7b0a 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h @@ -41,7 +41,9 @@ #define SPI_FLASH_CS_PIN (&pin_PA15) // Bootloader only -#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader +#ifdef UF2_BOOTLOADER_ENABLED + #define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader +#endif #define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SDA (&pin_PB07) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk index 4fa59d70fb..95bc6c75e6 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk @@ -9,12 +9,12 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -BOOTLOADER_OFFSET = 0x8010000 - MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f405xx MCU_PACKAGE = 64 CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405_boot.ld # use for bootloader (external fs only) -# LD_FILE = boards/STM32F405_fs.ld # use for internal filesystem \ No newline at end of file + +LD_FS = boards/STM32F405_fs.ld # Default to internal FS +LD_BOOT = boards/STM32F405_boot.ld # UF2 boot option +UF2_OFFSET = 0x8010000 diff --git a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk index a01ff7923c..b83852c4cf 100644 --- a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk +++ b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk @@ -13,5 +13,4 @@ MCU_SUB_VARIANT = stm32f405xx MCU_PACKAGE = 64 CMSIS_MCU = STM32F405xx LD_FILE = boards/STM32F405.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08010000 + diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk index d4f0f9577f..68c6a1eeaa 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.mk @@ -18,5 +18,4 @@ MCU_SUB_VARIANT = stm32f411xe MCU_PACKAGE = 48 CMSIS_MCU = STM32F411xE LD_FILE = boards/STM32F411VETx_FLASH.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 + diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk index d6f369b6ea..1f91bd8bc5 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk @@ -13,5 +13,3 @@ MCU_SUB_VARIANT = stm32f411xe MCU_PACKAGE = 100 CMSIS_MCU = STM32F411xE LD_FILE = boards/STM32F411VETx_FLASH.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk index d642f243ef..b0205fc733 100644 --- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk @@ -18,6 +18,5 @@ MCU_SUB_VARIANT = stm32f412zx MCU_PACKAGE = 144 CMSIS_MCU = STM32F412Zx LD_FILE = boards/STM32F412ZGTx_FLASH.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 + From 7085d912786ffa5cd3919dcfcff2f37d247c3f30 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 31 Jan 2020 13:13:51 -0500 Subject: [PATCH 406/531] dangling edit --- ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk index d46ee0b08a..d761d9dbe9 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk @@ -15,5 +15,3 @@ MCU_SUB_VARIANT = stm32f411xe MCU_PACKAGE = 48 CMSIS_MCU = STM32F411xE LD_FILE = boards/STM32F411VETx_FLASH.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 \ No newline at end of file From a10e5d1da2f0fa29c3588bda5c791ca47fbe53bd Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 31 Jan 2020 13:17:43 -0500 Subject: [PATCH 407/531] text fixes --- .../stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk | 1 + ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 3 ++- ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk | 1 + ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk index 95bc6c75e6..e7c5353b4b 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk @@ -18,3 +18,4 @@ CMSIS_MCU = STM32F405xx LD_FS = boards/STM32F405_fs.ld # Default to internal FS LD_BOOT = boards/STM32F405_boot.ld # UF2 boot option UF2_OFFSET = 0x8010000 + diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index 8c24222f36..dce69276d2 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -20,4 +20,5 @@ MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE LD_FILE = boards/STM32F401_boot.ld -# LD_FILE = boards/STM32F401_fs.ld # use for internal flash \ No newline at end of file +# LD_FILE = boards/STM32F401_fs.ld # use for internal flash + diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk index d761d9dbe9..a8472608b7 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.mk @@ -15,3 +15,4 @@ MCU_SUB_VARIANT = stm32f411xe MCU_PACKAGE = 48 CMSIS_MCU = STM32F411xE LD_FILE = boards/STM32F411VETx_FLASH.ld + diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk index 1f91bd8bc5..64e2b4dc53 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk @@ -13,3 +13,4 @@ MCU_SUB_VARIANT = stm32f411xe MCU_PACKAGE = 100 CMSIS_MCU = STM32F411xE LD_FILE = boards/STM32F411VETx_FLASH.ld + From f38e12f0abaf9a1a0ae84a0240958a27d99425ff Mon Sep 17 00:00:00 2001 From: hierophect Date: Fri, 31 Jan 2020 13:56:08 -0500 Subject: [PATCH 408/531] Update ports/stm32f4/boards/STM32F405_boot.ld Co-Authored-By: Scott Shawcroft --- ports/stm32f4/boards/STM32F405_boot.ld | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/stm32f4/boards/STM32F405_boot.ld b/ports/stm32f4/boards/STM32F405_boot.ld index cff2af388e..64da3b6520 100644 --- a/ports/stm32f4/boards/STM32F405_boot.ld +++ b/ports/stm32f4/boards/STM32F405_boot.ld @@ -17,7 +17,7 @@ MEMORY _minimum_stack_size = 2K; _minimum_heap_size = 16K; -/* Define tho top end of the stack. The stack is full descending so begins just +/* Define the top end of the stack. The stack is full descending so begins just above last byte of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */ _estack = ORIGIN(RAM) + LENGTH(RAM); @@ -105,4 +105,3 @@ SECTIONS .ARM.attributes 0 : { *(.ARM.attributes) } } - From ab031bc25fe9f57f8f08db0d6d2400e1cef72b09 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 31 Jan 2020 14:04:54 -0500 Subject: [PATCH 409/531] Create basic board profile --- .../stm32f4/boards/stm32f4_discovery/board.c | 38 ++ .../boards/stm32f4_discovery/mpconfigboard.h | 35 ++ .../boards/stm32f4_discovery/mpconfigboard.mk | 18 + ports/stm32f4/boards/stm32f4_discovery/pins.c | 107 +++++ .../stm32f4_discovery/stm32f4xx_hal_conf.h | 439 ++++++++++++++++++ 5 files changed, 637 insertions(+) create mode 100644 ports/stm32f4/boards/stm32f4_discovery/board.c create mode 100644 ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h create mode 100644 ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/stm32f4_discovery/pins.c create mode 100644 ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h diff --git a/ports/stm32f4/boards/stm32f4_discovery/board.c b/ports/stm32f4/boards/stm32f4_discovery/board.c new file mode 100644 index 0000000000..4421970eef --- /dev/null +++ b/ports/stm32f4/boards/stm32f4_discovery/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h new file mode 100644 index 0000000000..8a22a874e5 --- /dev/null +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Lucian Copeland 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 "STM32F4_DISCO" +#define MICROPY_HW_MCU_NAME "STM32F407VG" + +#define FLASH_SIZE (0x80000) //512K +#define FLASH_PAGE_SIZE (0x4000) //16K + +#define BOARD_OSC_DIV 8 diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk new file mode 100644 index 0000000000..e5bc84adc6 --- /dev/null +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk @@ -0,0 +1,18 @@ +USB_VID = 0x239A +USB_PID = 0x805E +USB_PRODUCT = "STM32F407VG Discovery Board - CPy" +USB_MANUFACTURER = "STMicroelectronics" +USB_DEVICES = "CDC,MSC" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +#This is technically a F407 but there's no difference. +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f405xx +MCU_PACKAGE = 100 +CMSIS_MCU = STM32F405xx +LD_FILE = boards/STM32F405.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08020000 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f4_discovery/pins.c b/ports/stm32f4/boards/stm32f4_discovery/pins.c new file mode 100644 index 0000000000..712932145a --- /dev/null +++ b/ports/stm32f4/boards/stm32f4_discovery/pins.c @@ -0,0 +1,107 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + //P1 + { MP_ROM_QSTR(MP_QSTR_PC00), MP_ROM_PTR(&pin_PC00) }, + { MP_ROM_QSTR(MP_QSTR_PC01), MP_ROM_PTR(&pin_PC01) }, + { MP_ROM_QSTR(MP_QSTR_PC02), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_PC03), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_PA00), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_PC04), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_PC05), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_PB02), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_PE07), MP_ROM_PTR(&pin_PE07) }, + { MP_ROM_QSTR(MP_QSTR_PE08), MP_ROM_PTR(&pin_PE08) }, + { MP_ROM_QSTR(MP_QSTR_PE09), MP_ROM_PTR(&pin_PE09) }, + { MP_ROM_QSTR(MP_QSTR_PE10), MP_ROM_PTR(&pin_PE10) }, + { MP_ROM_QSTR(MP_QSTR_PE11), MP_ROM_PTR(&pin_PE11) }, + { MP_ROM_QSTR(MP_QSTR_PE12), MP_ROM_PTR(&pin_PE12) }, + { MP_ROM_QSTR(MP_QSTR_PE13), MP_ROM_PTR(&pin_PE13) }, + { MP_ROM_QSTR(MP_QSTR_PE14), MP_ROM_PTR(&pin_PE14) }, + { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) }, + { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, // Differs from F411 + { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_PD08), MP_ROM_PTR(&pin_PD08) }, + { MP_ROM_QSTR(MP_QSTR_PD09), MP_ROM_PTR(&pin_PD09) }, + { MP_ROM_QSTR(MP_QSTR_PD10), MP_ROM_PTR(&pin_PD10) }, + { MP_ROM_QSTR(MP_QSTR_PD11), MP_ROM_PTR(&pin_PD11) }, + { MP_ROM_QSTR(MP_QSTR_PD12), MP_ROM_PTR(&pin_PD12) }, + { MP_ROM_QSTR(MP_QSTR_PD13), MP_ROM_PTR(&pin_PD13) }, + { MP_ROM_QSTR(MP_QSTR_PD14), MP_ROM_PTR(&pin_PD14) }, + { MP_ROM_QSTR(MP_QSTR_PD15), MP_ROM_PTR(&pin_PD15) }, + //P2 + { MP_ROM_QSTR(MP_QSTR_PC14), MP_ROM_PTR(&pin_PC14) }, + { MP_ROM_QSTR(MP_QSTR_PC15), MP_ROM_PTR(&pin_PC15) }, + { MP_ROM_QSTR(MP_QSTR_PC13), MP_ROM_PTR(&pin_PC13) }, + { MP_ROM_QSTR(MP_QSTR_PE06), MP_ROM_PTR(&pin_PE06) }, + { MP_ROM_QSTR(MP_QSTR_PE05), MP_ROM_PTR(&pin_PE05) }, + { MP_ROM_QSTR(MP_QSTR_PE04), MP_ROM_PTR(&pin_PE04) }, + { MP_ROM_QSTR(MP_QSTR_PE03), MP_ROM_PTR(&pin_PE03) }, + { MP_ROM_QSTR(MP_QSTR_PE02), MP_ROM_PTR(&pin_PE02) }, + { MP_ROM_QSTR(MP_QSTR_PE01), MP_ROM_PTR(&pin_PE01) }, + { MP_ROM_QSTR(MP_QSTR_PE00), MP_ROM_PTR(&pin_PE00) }, + { MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_PD07), MP_ROM_PTR(&pin_PD07) }, + { MP_ROM_QSTR(MP_QSTR_PD06), MP_ROM_PTR(&pin_PD06) }, + { MP_ROM_QSTR(MP_QSTR_PD05), MP_ROM_PTR(&pin_PD05) }, + { MP_ROM_QSTR(MP_QSTR_PD04), MP_ROM_PTR(&pin_PD04) }, + { MP_ROM_QSTR(MP_QSTR_PD03), MP_ROM_PTR(&pin_PD03) }, + { MP_ROM_QSTR(MP_QSTR_PD02), MP_ROM_PTR(&pin_PD02) }, + { MP_ROM_QSTR(MP_QSTR_PD01), MP_ROM_PTR(&pin_PD01) }, + { MP_ROM_QSTR(MP_QSTR_PD00), MP_ROM_PTR(&pin_PD00) }, + { MP_ROM_QSTR(MP_QSTR_PC12), MP_ROM_PTR(&pin_PC12) }, + { MP_ROM_QSTR(MP_QSTR_PC11), MP_ROM_PTR(&pin_PC11) }, + { MP_ROM_QSTR(MP_QSTR_PC10), MP_ROM_PTR(&pin_PC10) }, + { MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_PA09), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_PC09), MP_ROM_PTR(&pin_PC09) }, + { MP_ROM_QSTR(MP_QSTR_PC08), MP_ROM_PTR(&pin_PC08) }, + { MP_ROM_QSTR(MP_QSTR_PC07), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_PC06), MP_ROM_PTR(&pin_PC06) }, + //ST LED names + { MP_ROM_QSTR(MP_QSTR_LD3), MP_ROM_PTR(&pin_PD13) }, + { MP_ROM_QSTR(MP_QSTR_LD4), MP_ROM_PTR(&pin_PD12) }, + { MP_ROM_QSTR(MP_QSTR_LD5), MP_ROM_PTR(&pin_PD14) }, + { MP_ROM_QSTR(MP_QSTR_LD6), MP_ROM_PTR(&pin_PD15) }, + //more useful LED names + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PD13) }, + { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PD12) }, + { MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PD14) }, + { MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PD15) }, + //AnalogIO names + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) }, + //actual LED names + { MP_ROM_QSTR(MP_QSTR_LED_ORANGE), MP_ROM_PTR(&pin_PD13) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PD12) }, + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PD14) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_PD15) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..18d9d60ebe --- /dev/null +++ b/ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h @@ -0,0 +1,439 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 19553b8f7c8155c8b3cd201980a7c8d0f2df59ee Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 31 Jan 2020 14:33:10 -0500 Subject: [PATCH 410/531] WIP --- ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk index e5bc84adc6..68ba3905f4 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk @@ -13,6 +13,5 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f405xx MCU_PACKAGE = 100 CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld -TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08020000 \ No newline at end of file +LD_FILE = boards/STM32F405_fs.ld + From 41aefc819bd177865d7114d58a00e8b67cbd6cb1 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 31 Jan 2020 14:35:54 -0500 Subject: [PATCH 411/531] Fix pyboard --- .../stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk | 3 ++- ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk index e7c5353b4b..3fc8581ef9 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk @@ -15,7 +15,8 @@ MCU_SUB_VARIANT = stm32f405xx MCU_PACKAGE = 64 CMSIS_MCU = STM32F405xx -LD_FS = boards/STM32F405_fs.ld # Default to internal FS +# Default includes filesystem, but uses external flash +LD_FS = boards/STM32F405_fs.ld LD_BOOT = boards/STM32F405_boot.ld # UF2 boot option UF2_OFFSET = 0x8010000 diff --git a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk index b83852c4cf..ef1b8f0ca1 100644 --- a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk +++ b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.mk @@ -12,5 +12,5 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f405xx MCU_PACKAGE = 64 CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405.ld +LD_FILE = boards/STM32F405_fs.ld From 4abd5f1f7b54d2fb3641ce2ab807db1d45e82731 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 31 Jan 2020 14:40:50 -0500 Subject: [PATCH 412/531] increase max connections from 2 to 5 --- ports/nrf/bluetooth/ble_drv.h | 2 -- ports/nrf/boards/common.template.ld | 9 ++++----- ports/nrf/common-hal/_bleio/Adapter.c | 23 +++++++++++++++++------ ports/nrf/common-hal/_bleio/Adapter.h | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ports/nrf/bluetooth/ble_drv.h b/ports/nrf/bluetooth/ble_drv.h index 91990da6df..ece4b2436f 100644 --- a/ports/nrf/bluetooth/ble_drv.h +++ b/ports/nrf/bluetooth/ble_drv.h @@ -33,8 +33,6 @@ #include "ble.h" -#define MAX_TX_IN_PROGRESS 10 - #ifndef BLE_GATT_ATT_MTU_DEFAULT #define BLE_GATT_ATT_MTU_DEFAULT GATT_MTU_SIZE_DEFAULT #endif diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index b110e6052a..607a1dc938 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -19,14 +19,13 @@ MEMORY /* 0x2000000 - RAM:ORIGIN is reserved for Softdevice */ - /* SoftDevice 6.1.0 takes 0x7b78 bytes (30.86 kb) minimum with high ATT MTU. */ + /* SoftDevice 6.1.0 with 5 connections and various increases takes just under 64kiB. /* To measure the minimum required amount of memory for given configuration, set this number high enough to work and then check the mutation of the value done by sd_ble_enable. */ - RAM (xrw) : ORIGIN = 0x20000000 + 32K, LENGTH = 256K - 32K + RAM (xrw) : ORIGIN = 0x20000000 + 64K, LENGTH = 256K - 64K } -/* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 40K; +/* produce a link error if there is not this amount of RAM available */ _minimum_heap_size = 0; /* top end of the stack */ @@ -125,7 +124,7 @@ SECTIONS .stack : { . = ALIGN(4); - . = . + _minimum_stack_size; + . = . + ${CIRCUITPY_DEFAULT_STACK_SIZE}; . = ALIGN(4); } >RAM diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index c92ce12a52..4aa8678a3f 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -108,6 +108,9 @@ STATIC uint32_t ble_stack_enable(void) { ble_cfg_t ble_conf; ble_conf.conn_cfg.conn_cfg_tag = BLE_CONN_CFG_TAG_CUSTOM; + // Each additional connection costs: + // about 3700-4300 bytes when .hvn_tx_queue_size is 1 + // about 9000 bytes when .hvn_tx_queue_size is 10 ble_conf.conn_cfg.params.gap_conn_cfg.conn_count = BLEIO_TOTAL_CONNECTION_COUNT; // Event length here can influence throughput so perhaps make multiple connection profiles // available. @@ -118,9 +121,12 @@ STATIC uint32_t ble_stack_enable(void) { } memset(&ble_conf, 0, sizeof(ble_conf)); + // adv_set_count must be == 1 for S140. Cannot be increased. ble_conf.gap_cfg.role_count_cfg.adv_set_count = 1; - ble_conf.gap_cfg.role_count_cfg.periph_role_count = 2; - ble_conf.gap_cfg.role_count_cfg.central_role_count = 1; + // periph_role_count costs 1232 bytes for 2 to 3, then ~1840 for each further increment. + ble_conf.gap_cfg.role_count_cfg.periph_role_count = 4; + // central_role_count costs 648 bytes for 1 to 2, then ~1250 for each further increment. + ble_conf.gap_cfg.role_count_cfg.central_role_count = 4; err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_conf, app_ram_start); if (err_code != NRF_SUCCESS) { return err_code; @@ -128,7 +134,10 @@ STATIC uint32_t ble_stack_enable(void) { memset(&ble_conf, 0, sizeof(ble_conf)); ble_conf.conn_cfg.conn_cfg_tag = BLE_CONN_CFG_TAG_CUSTOM; - ble_conf.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = MAX_TX_IN_PROGRESS; + // Each increment to hvn_tx_queue_size costs 2064 bytes. + // DevZone recommends not setting this directly, but instead changing gap_conn_cfg.event_length. + // However, we are setting connection extension, so this seems to make sense. + ble_conf.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 9; err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_conf, app_ram_start); if (err_code != NRF_SUCCESS) { return err_code; @@ -143,10 +152,11 @@ STATIC uint32_t ble_stack_enable(void) { return err_code; } - // Triple the GATT Server attribute size to accomodate both the CircuitPython built-in service + // Increase the GATT Server attribute size to accomodate both the CircuitPython built-in service // and anything the user does. memset(&ble_conf, 0, sizeof(ble_conf)); - ble_conf.gatts_cfg.attr_tab_size.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT * 3; + // Each increment to the BLE_GATTS_ATTR_TAB_SIZE_DEFAULT multiplier costs 1408 bytes. + ble_conf.gatts_cfg.attr_tab_size.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT * 5; err_code = sd_ble_cfg_set(BLE_GATTS_CFG_ATTR_TAB_SIZE, &ble_conf, app_ram_start); if (err_code != NRF_SUCCESS) { return err_code; @@ -155,7 +165,8 @@ STATIC uint32_t ble_stack_enable(void) { // Increase the number of vendor UUIDs supported. Apple uses a complete random number per // service and characteristic. memset(&ble_conf, 0, sizeof(ble_conf)); - ble_conf.common_cfg.vs_uuid_cfg.vs_uuid_count = 32; // Defaults to 10. + // Each additional vs_uuid_count costs 16 bytes. + ble_conf.common_cfg.vs_uuid_cfg.vs_uuid_count = 75; // Defaults to 10. err_code = sd_ble_cfg_set(BLE_COMMON_CFG_VS_UUID, &ble_conf, app_ram_start); if (err_code != NRF_SUCCESS) { return err_code; diff --git a/ports/nrf/common-hal/_bleio/Adapter.h b/ports/nrf/common-hal/_bleio/Adapter.h index 2ac568d661..90c88dcbe6 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.h +++ b/ports/nrf/common-hal/_bleio/Adapter.h @@ -35,7 +35,7 @@ #include "shared-bindings/_bleio/Connection.h" #include "shared-bindings/_bleio/ScanResults.h" -#define BLEIO_TOTAL_CONNECTION_COUNT 2 +#define BLEIO_TOTAL_CONNECTION_COUNT 5 extern bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; From fa11912b9b7c1636b097459529c587a4533ea1ea Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 31 Jan 2020 17:28:42 -0500 Subject: [PATCH 413/531] New configuration values --- ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h | 6 ++++-- ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk | 3 ++- ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h index 8a22a874e5..70f89d7e83 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h @@ -29,7 +29,9 @@ #define MICROPY_HW_BOARD_NAME "STM32F4_DISCO" #define MICROPY_HW_MCU_NAME "STM32F407VG" -#define FLASH_SIZE (0x80000) //512K -#define FLASH_PAGE_SIZE (0x4000) //16K +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define BOARD_NO_VBUS_SENSE #define BOARD_OSC_DIV 8 diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk index 68ba3905f4..3e3dba6e80 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk @@ -7,7 +7,8 @@ USB_DEVICES = "CDC,MSC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE -#This is technically a F407 but there's no difference. +# This is technically a F407 but there's no difference +# other than the camera and ethernet, which aren't supported. MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f405xx diff --git a/ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h index 18d9d60ebe..ee5832d49c 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h +++ b/ports/stm32f4/boards/stm32f4_discovery/stm32f4xx_hal_conf.h @@ -41,7 +41,7 @@ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_DAC_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED /* #define HAL_DCMI_MODULE_ENABLED */ /* #define HAL_DMA2D_MODULE_ENABLED */ /* #define HAL_ETH_MODULE_ENABLED */ @@ -55,7 +55,7 @@ #define HAL_I2S_MODULE_ENABLED /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_RNG_MODULE_ENABLED */ +#define HAL_RNG_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SAI_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ @@ -63,7 +63,7 @@ #define HAL_SPI_MODULE_ENABLED #define HAL_TIM_MODULE_ENABLED #define HAL_UART_MODULE_ENABLED -/* #define HAL_USART_MODULE_ENABLED */ +#define HAL_USART_MODULE_ENABLED /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ From be4e681d07cb89228dbf3f623b202413eb5cd19e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 31 Jan 2020 18:57:41 -0500 Subject: [PATCH 414/531] fix UICR check; do not use NULL for no MISO --- .../boards/hallowing_m4_express/board.c | 2 +- ports/atmel-samd/boards/monster_m4sk/board.c | 2 +- ports/atmel-samd/boards/openbook_m4/board.c | 2 +- ports/atmel-samd/boards/pewpew_m4/board.c | 2 +- ports/atmel-samd/boards/pybadge/board.c | 2 +- .../atmel-samd/boards/pybadge_airlift/board.c | 2 +- ports/atmel-samd/boards/pygamer/board.c | 2 +- .../atmel-samd/boards/pygamer_advance/board.c | 2 +- ports/nrf/boards/clue_nrf52840_express/board.c | 2 +- ports/nrf/boards/ohs2020_badge/board.c | 2 +- ports/nrf/common-hal/busio/SPI.c | 4 ++-- ports/nrf/peripherals/nrf/nrf52840/power.c | 18 ++++++++++++++---- 12 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ports/atmel-samd/boards/hallowing_m4_express/board.c b/ports/atmel-samd/boards/hallowing_m4_express/board.c index 6bb2a591f0..5d1ef6d9be 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/board.c @@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL); + common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/monster_m4sk/board.c b/ports/atmel-samd/boards/monster_m4sk/board.c index 2377f4a9da..40141ca157 100644 --- a/ports/atmel-samd/boards/monster_m4sk/board.c +++ b/ports/atmel-samd/boards/monster_m4sk/board.c @@ -50,7 +50,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL); + common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/openbook_m4/board.c b/ports/atmel-samd/boards/openbook_m4/board.c index 2d9b316474..85a5888799 100644 --- a/ports/atmel-samd/boards/openbook_m4/board.c +++ b/ports/atmel-samd/boards/openbook_m4/board.c @@ -55,7 +55,7 @@ uint8_t stop_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index 5f5a01e48e..1872d18763 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -97,7 +97,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, NULL); + common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index f3ac7176ab..3725f0ec34 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -72,7 +72,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pybadge_airlift/board.c b/ports/atmel-samd/boards/pybadge_airlift/board.c index 061f3d7772..fbb4441f0e 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/board.c +++ b/ports/atmel-samd/boards/pybadge_airlift/board.c @@ -50,7 +50,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index 8c6fbca065..b364ffccff 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -72,7 +72,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pygamer_advance/board.c b/ports/atmel-samd/boards/pygamer_advance/board.c index ff2da34a26..a138c7e504 100644 --- a/ports/atmel-samd/boards/pygamer_advance/board.c +++ b/ports/atmel-samd/boards/pygamer_advance/board.c @@ -50,7 +50,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB12, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB12, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index c118fe92f1..abc4e3cfae 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL); + common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index 189f7acdf2..457edf44a5 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL); + common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index 639bbcdd05..8e1d73bf0e 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -143,7 +143,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * self->clock_pin_number = clock->number; claim_pin(clock); - if (mosi != (mcu_pin_obj_t*)&mp_const_none_obj) { + if (mosi != mp_const_none) { config.mosi_pin = mosi->number; self->MOSI_pin_number = mosi->number; claim_pin(mosi); @@ -151,7 +151,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * self->MOSI_pin_number = NO_PIN; } - if (miso != (mcu_pin_obj_t*)&mp_const_none_obj) { + if (miso != mp_const_none) { config.miso_pin = miso->number; self->MISO_pin_number = mosi->number; claim_pin(miso); diff --git a/ports/nrf/peripherals/nrf/nrf52840/power.c b/ports/nrf/peripherals/nrf/nrf52840/power.c index 794872c5d9..d64c536bb3 100644 --- a/ports/nrf/peripherals/nrf/nrf52840/power.c +++ b/ports/nrf/peripherals/nrf/nrf52840/power.c @@ -25,16 +25,26 @@ */ #include "nrfx.h" -#include "nrfx_nvmc.h" +#include "hal/nrf_nvmc.h" void nrf_peripherals_power_init(void) { // Set GPIO reference voltage to 3.3V if it isn't already. REGOUT0 will get reset to 0xfffffff // if flash is erased, which sets the default to 1.8V // This matters only when "high voltage mode" is enabled, which is true on the PCA10059, // and might be true on other boards. - if (NRF_UICR->REGOUT0 == 0xffffffff) { - nrfx_nvmc_word_write((uint32_t) &NRF_UICR->REGOUT0, UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos); - // Must reset to make enable change. + if (NRF_UICR->REGOUT0 == 0xffffffff && NRF_POWER->MAINREGSTATUS & 1) { + // Expand what nrf_nvmc_word_write() did. + // It's missing from nrfx V2.0.0, and nrfx_nvmc_word_write() does bounds + // checking which prevents writes to UICR. + // Reported: https://devzone.nordicsemi.com/f/nordic-q-a/57243/nrfx_nvmc-h-api-cannot-write-to-uicr + NRF_NVMC->CONFIG = NRF_NVMC_MODE_WRITE; + while (!(NRF_NVMC->READY & NVMC_READY_READY_Msk)) {} + NRF_UICR->REGOUT0 = UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos; + __DMB(); + while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {} + NRF_NVMC->CONFIG = NRF_NVMC_MODE_READONLY; + + // Must reset to enable change. NVIC_SystemReset(); } } From dc964b346ca03405b6be768bc54820509477d17f Mon Sep 17 00:00:00 2001 From: Lady Ada Date: Fri, 31 Jan 2020 20:17:39 -0500 Subject: [PATCH 415/531] adjust CLUE madctl so rotation 0 is 'right' --- ports/nrf/boards/clue_nrf52840_express/board.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index abc4e3cfae..5f5337a3da 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -40,7 +40,7 @@ displayio_fourwire_obj_t board_display_obj; uint8_t display_init_sequence[] = { 0x01, 0 | DELAY, 150, // SWRESET 0x11, 0 | DELAY, 255, // SLPOUT - 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order. + 0x36, 1, 0b10100000, // _MADCTL for rotation 0 0x3a, 1, 0x55, // COLMOD - 16bit color 0x21, 0 | DELAY, 10, // _INVON 0x13, 0 | DELAY, 10, // _NORON @@ -67,9 +67,9 @@ void board_init(void) { bus, 240, // Width (after rotation) 240, // Height (after rotation) - 0, // column start + 80, // column start 0, // row start - 270, // rotation + 0, // rotation 16, // Color depth false, // Grayscale false, // Pixels in a byte share a row. Only used for depth < 8 From d99c2ffe4f37ad6a41f7f6fe4c55ae20f79c816f Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 1 Feb 2020 17:23:35 -0800 Subject: [PATCH 416/531] QSPI flash fixes We had the pin names swapped on the schematic and a different flash was populated. Signed-off-by: Michael Welling --- ports/nrf/boards/ohs2020_badge/mpconfigboard.h | 4 ++-- ports/nrf/boards/ohs2020_badge/mpconfigboard.mk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/nrf/boards/ohs2020_badge/mpconfigboard.h b/ports/nrf/boards/ohs2020_badge/mpconfigboard.h index 8e4e68dea3..8edc40423e 100644 --- a/ports/nrf/boards/ohs2020_badge/mpconfigboard.h +++ b/ports/nrf/boards/ohs2020_badge/mpconfigboard.h @@ -32,8 +32,8 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #if QSPI_FLASH_FILESYSTEM -#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 22) -#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(1, 0) +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(1, 0) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22) #define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 20) #define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(1, 2) #define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 1) diff --git a/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk b/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk index 46a4c3be61..7d2c6de987 100644 --- a/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk +++ b/ports/nrf/boards/ohs2020_badge/mpconfigboard.mk @@ -7,4 +7,4 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 -EXTERNAL_FLASH_DEVICES = "W25Q32JV_IQ" +EXTERNAL_FLASH_DEVICES = "W25Q128JV_SQ" From 33dcdd7c031a1f92d57ef08dda0aba5e8c7a424b Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 1 Feb 2020 18:28:22 -0800 Subject: [PATCH 417/531] Updates to enable working SPI TFT The backlight enable is active low on our board so the driver doesn't like it. Toggling to GPIO manually for now. As fixed the improper SPI bus pins definitions and it works! Signed-off-by: Michael Welling --- ports/nrf/boards/ohs2020_badge/board.c | 4 ++-- ports/nrf/boards/ohs2020_badge/pins.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index 457edf44a5..4ea11f163e 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, mp_const_none); + common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, mp_const_none); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; @@ -81,7 +81,7 @@ void board_init(void) { 0x37, // set vertical scroll command display_init_sequence, sizeof(display_init_sequence), - &pin_P0_02, // backlight pin + NULL, // backlight pin NO_BRIGHTNESS_COMMAND, 1.0f, // brightness (ignored) true, // auto_brightness diff --git a/ports/nrf/boards/ohs2020_badge/pins.c b/ports/nrf/boards/ohs2020_badge/pins.c index df87deeeb6..f5cd64accc 100644 --- a/ports/nrf/boards/ohs2020_badge/pins.c +++ b/ports/nrf/boards/ohs2020_badge/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[] = { { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_25) }, @@ -13,6 +14,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 6804b2a7fd1c6c167e1f10316655e2ffaaca1f73 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 2 Feb 2020 21:10:39 -0800 Subject: [PATCH 418/531] Add I2C pin definitions for interoperability with Adafruit libraries Signed-off-by: Michael Welling --- ports/nrf/boards/ohs2020_badge/pins.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/nrf/boards/ohs2020_badge/pins.c b/ports/nrf/boards/ohs2020_badge/pins.c index f5cd64accc..e984e3070f 100644 --- a/ports/nrf/boards/ohs2020_badge/pins.c +++ b/ports/nrf/boards/ohs2020_badge/pins.c @@ -12,6 +12,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_P0_11) }, { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P1_15) }, + { 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 64cafe82bcbffc54d882765d47df4a093b6e43aa Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 2 Feb 2020 22:01:09 -0800 Subject: [PATCH 419/531] Adjust OHS2020 madctl for default rotation Make to go faster I guess. Signed-off-by: Michael Welling --- ports/nrf/boards/ohs2020_badge/board.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index 4ea11f163e..7e3e058144 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -40,7 +40,7 @@ displayio_fourwire_obj_t board_display_obj; uint8_t display_init_sequence[] = { 0x01, 0 | DELAY, 150, // SWRESET 0x11, 0 | DELAY, 255, // SLPOUT - 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order. + 0x36, 1, 0b10100000, // _MADCTL bottom to top refresh in vsync aligned order. 0x3a, 1, 0x55, // COLMOD - 16bit color 0x21, 0 | DELAY, 10, // _INVON 0x13, 0 | DELAY, 10, // _NORON @@ -67,9 +67,9 @@ void board_init(void) { bus, 240, // Width (after rotation) 240, // Height (after rotation) - 0, // column start + 80, // column start 0, // row start - 270, // rotation + 0, // rotation 16, // Color depth false, // Grayscale false, // Pixels in a byte share a row. Only used for depth < 8 From 5a29b222eb460f58e09615772da2b3fbbcb804aa Mon Sep 17 00:00:00 2001 From: Lady Ada Date: Sat, 1 Feb 2020 13:29:49 -0500 Subject: [PATCH 420/531] add bluefruit sense - tested --- .../boards/feather_bluefruit_sense/board.c | 38 ++++++++++ .../feather_bluefruit_sense/mpconfigboard.h | 70 +++++++++++++++++++ .../feather_bluefruit_sense/mpconfigboard.mk | 10 +++ .../nrf/boards/feather_bluefruit_sense/pins.c | 58 +++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 ports/nrf/boards/feather_bluefruit_sense/board.c create mode 100644 ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h create mode 100644 ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.mk create mode 100644 ports/nrf/boards/feather_bluefruit_sense/pins.c diff --git a/ports/nrf/boards/feather_bluefruit_sense/board.c b/ports/nrf/boards/feather_bluefruit_sense/board.c new file mode 100644 index 0000000000..4421970eef --- /dev/null +++ b/ports/nrf/boards/feather_bluefruit_sense/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h new file mode 100644 index 0000000000..4b2b69e7e8 --- /dev/null +++ b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h @@ -0,0 +1,70 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 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. + */ + +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "Adafruit Feather Bluefruit Sense" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_NEOPIXEL (&pin_P0_16) + +#define MICROPY_HW_LED_STATUS (&pin_P1_11) + +// Board does not have a 32kHz crystal. It does have a 32MHz crystal. +#define BOARD_HAS_32KHZ_XTAL (0) + +#if QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 17) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 23) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 21) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 20) +#endif + +#if SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P0_17 +#define SPI_FLASH_MISO_PIN &pin_P0_22 +#define SPI_FLASH_SCK_PIN &pin_P0_19 +#define SPI_FLASH_CS_PIN &pin_P0_20 +#endif + +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_11) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_12) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_14) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_13) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_15) + +#define DEFAULT_UART_BUS_RX (&pin_P0_24) +#define DEFAULT_UART_BUS_TX (&pin_P0_25) diff --git a/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.mk b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.mk new file mode 100644 index 0000000000..5813e6136b --- /dev/null +++ b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.mk @@ -0,0 +1,10 @@ +USB_VID = 0x239A +USB_PID = 0x8088 +USB_PRODUCT = "Feather Bluefruit Sense" +USB_MANUFACTURER = "Adafruit Industries LLC" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = "GD25Q16C" diff --git a/ports/nrf/boards/feather_bluefruit_sense/pins.c b/ports/nrf/boards/feather_bluefruit_sense/pins.c new file mode 100644 index 0000000000..55eb764632 --- /dev/null +++ b/ports/nrf/boards/feather_bluefruit_sense/pins.c @@ -0,0 +1,58 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_P0_29) }, + + { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_P1_02) }, + + { MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_08) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_09) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_16) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_24) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_12) }, + + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_11) }, + { MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_P1_11) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P1_11) }, + + { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_P1_10) }, + + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_01) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_00) }, + + { MP_ROM_QSTR(MP_QSTR_PROXIMITY_LIGHT_INTERRUPT), MP_ROM_PTR(&pin_P1_00) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 391ca918b1fc919682a268cdf956144241469adc Mon Sep 17 00:00:00 2001 From: ladyada Date: Mon, 3 Feb 2020 13:54:24 -0500 Subject: [PATCH 421/531] add buildline --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50fafdc7ff..369c26a537 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,6 +144,7 @@ jobs: - "electronut_labs_blip" - "electronut_labs_papyr" - "escornabot_makech" + - "feather_bluefruit_sense" - "feather_m0_adalogger" - "feather_m0_basic" - "feather_m0_express" From 7fd30e7d2067bc0d94a57bd44519a59469a9f08b Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 3 Feb 2020 16:46:14 -0800 Subject: [PATCH 422/531] First draft of eveL, the low-level module of the Gameduino (and BridgeTek EVE) bindings. [adafruit/circuitpython#2578] --- .../boards/metro_m4_express/mpconfigboard.mk | 2 + .../metro_nrf52840_express/mpconfigboard.mk | 2 + py/circuitpy_defns.mk | 4 + py/circuitpy_mpconfig.h | 8 + py/circuitpy_mpconfig.mk | 5 + shared-bindings/eveL/__init__.c | 225 ++++++++++ shared-bindings/eveL/modeveL-gen.h | 412 ++++++++++++++++++ 7 files changed, 658 insertions(+) create mode 100644 shared-bindings/eveL/__init__.c create mode 100644 shared-bindings/eveL/modeveL-gen.h diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk index 62e6b7c72f..d4593f83a5 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk @@ -10,3 +10,5 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ + +CIRCUITPY_EVEL = 1 diff --git a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk index d421e52104..ade77f0765 100644 --- a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk +++ b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk @@ -8,3 +8,5 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "GD25Q16C" + +CIRCUITPY_EVEL = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 1f2d6c73ef..859d3837b1 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -157,6 +157,9 @@ endif ifeq ($(CIRCUITPY_MATH),1) SRC_PATTERNS += math/% endif +ifeq ($(CIRCUITPY_EVEL),1) +SRC_PATTERNS += eveL/% +endif ifeq ($(CIRCUITPY_MICROCONTROLLER),1) SRC_PATTERNS += microcontroller/% endif @@ -298,6 +301,7 @@ $(filter $(SRC_PATTERNS), \ fontio/Glyph.c \ microcontroller/RunMode.c \ math/__init__.c \ + eveL/__init__.c \ ) SRC_BINDINGS_ENUMS += \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 5b705a0883..8b7ac46b04 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -384,6 +384,13 @@ extern const struct _mp_obj_module_t math_module; #define MATH_MODULE #endif +#if CIRCUITPY_EVEL +extern const struct _mp_obj_module_t eveL_module; +#define EVEL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_eveL), (mp_obj_t)&eveL_module }, +#else +#define EVEL_MODULE +#endif + #if CIRCUITPY_MICROCONTROLLER extern const struct _mp_obj_module_t microcontroller_module; #define MICROCONTROLLER_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, @@ -617,6 +624,7 @@ extern const struct _mp_obj_module_t ustack_module; I2CSLAVE_MODULE \ JSON_MODULE \ MATH_MODULE \ + EVEL_MODULE \ MICROCONTROLLER_MODULE \ NEOPIXEL_WRITE_MODULE \ NETWORK_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 93175e136f..f56d994789 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -174,6 +174,11 @@ CIRCUITPY_MATH = $(CIRCUITPY_ALWAYS_BUILD) endif CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) +ifndef CIRCUITPY_EVEL +CIRCUITPY_EVEL = $(CIRCUITPY_ALWAYS_BUILD) +endif +CFLAGS += -DCIRCUITPY_EVEL=$(CIRCUITPY_EVEL) + ifndef CIRCUITPY_MICROCONTROLLER CIRCUITPY_MICROCONTROLLER = $(CIRCUITPY_DEFAULT_BUILD) endif diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c new file mode 100644 index 0000000000..3bbffa257f --- /dev/null +++ b/shared-bindings/eveL/__init__.c @@ -0,0 +1,225 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Paul Sokolovsky + * + * 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 + +#include "py/runtime.h" +#include "py/binary.h" + +// #if MICROPY_PY_BUILTINS_EVEL + +typedef struct _mp_obj_EVEL_t { + mp_obj_base_t base; + mp_obj_t writer; + mp_obj_t dest[3]; + + size_t n; + uint8_t buf[512]; +} mp_obj_EVEL_t; + +STATIC void _write(mp_obj_EVEL_t *EVEL, mp_obj_t b) { + EVEL->dest[2] = b; + mp_call_method_n_kw(1, 0, EVEL->dest); +} + +STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { + mp_obj_EVEL_t *EVEL = self; + EVEL->n = 0; + mp_printf(&mp_plat_print, "register %p %d\n", EVEL, EVEL->n); + mp_load_method(o, MP_QSTR_write, EVEL->dest); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); + +STATIC mp_obj_t _flush(mp_obj_t self) { + mp_obj_EVEL_t *EVEL = self; + // mp_printf(&mp_plat_print, "flush %p %d\n", EVEL, EVEL->n); + if (EVEL->n != 0) { + _write(EVEL, mp_obj_new_bytearray_by_ref(EVEL->n, EVEL->buf)); + EVEL->n = 0; + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); + +STATIC void *append(mp_obj_EVEL_t *EVEL, size_t m) { + if ((EVEL->n + m) > sizeof(EVEL->buf)) + _flush((mp_obj_t)EVEL); + uint8_t *r = EVEL->buf + EVEL->n; + EVEL->n += m; + return (void*)r; +} + +STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { + mp_obj_EVEL_t *EVEL = self; + mp_buffer_info_t buffer_info; + mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); + // mp_printf(&mp_plat_print, "flush %p %d %p\n", EVEL, buffer_info.len, EVEL->writer); + if (buffer_info.len <= sizeof(EVEL->buf)) { + uint8_t *p = (uint8_t*)append(EVEL, buffer_info.len); + // memcpy(p, buffer_info.buf, buffer_info.len); + uint8_t *s = buffer_info.buf; + for (size_t i = 0; i < buffer_info.len; i++) + *p++ = *s++; + } else { + _flush(self); + _write(EVEL, b); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); + +#define C4(self, u) (*(uint32_t*)append((self), sizeof(uint32_t)) = (u)) + +#include "modeveL-gen.h" + +// Hand-written functions { + +STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { + C4(self, (0xffffff00 | mp_obj_get_int_truncated(n))); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); + +STATIC mp_obj_t _vertex2f(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + int16_t x = (int16_t)(16 * mp_obj_get_float(a0)); + int16_t y = (int16_t)(16 * mp_obj_get_float(a1)); + C4(self, (0x40000000 | ((x & 32767) << 15) | (y & 32767))); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); + +STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { + mp_obj_t self = args[0]; + mp_obj_t num = args[1]; + mp_buffer_info_t fmt; + mp_get_buffer_raise(args[2], &fmt, MP_BUFFER_READ); + size_t len; + mp_obj_t *items; + mp_obj_tuple_get(args[3], &len, &items); + + // Count how many 32-bit words required + size_t n = 0; + for (size_t i = 0; i < fmt.len; n++) { + switch (((char*)fmt.buf)[i]) { + case 'I': + case 'i': + i += 1; + break; + case 'H': + case 'h': + i += 2; + break; + default: + break; + } + } + mp_printf(&mp_plat_print, "n=%d\n", n); + + uint32_t *p = (uint32_t*)append(self, sizeof(uint32_t) * (1 + n)); + *p++ = 0xffffff00 | mp_obj_get_int_truncated(num); + mp_obj_t *a = items; + uint32_t lo; + + for (size_t i = 0; i < fmt.len; ) { + switch (((char*)fmt.buf)[i]) { + case 'I': + case 'i': + *p++ = mp_obj_get_int_truncated(*a++); + mp_printf(&mp_plat_print, " %d %08x\n", p[-1]); + i += 1; + break; + case 'H': + case 'h': + lo = mp_obj_get_int_truncated(*a++) & 0xffff; + *p++ = lo | (mp_obj_get_int_truncated(*a++) << 16); + i += 2; + break; + default: + break; + } + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cmd_obj, 4, 4, _cmd); + +STATIC const mp_rom_map_elem_t EVEL_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(®ister_obj) }, + { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, + { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, + { MP_ROM_QSTR(MP_QSTR_Vertex2f), MP_ROM_PTR(&vertex2f_obj) }, + { MP_ROM_QSTR(MP_QSTR_cmd), MP_ROM_PTR(&cmd_obj) }, + { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, + ROM_DECLS +}; +STATIC MP_DEFINE_CONST_DICT(EVEL_locals_dict, EVEL_locals_dict_table); + +STATIC void EVEL_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + (void)self_in; + (void)kind; + mp_printf(print, ""); +} + +STATIC mp_obj_t EVEL_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + // mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_obj_EVEL_t *o = m_new_obj(mp_obj_EVEL_t); + mp_printf(&mp_plat_print, "EVEL init\n"); + o->base.type = type; + return o; +} + +// STATIC void EVEL_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { +// printf("HERE\n"); +// mp_type_type.attr(self_in, attr, dest); +// printf("THERE %p %p\n", dest[0], dest[1]); +// } + +STATIC const mp_obj_type_t EVEL_type = { + { &mp_type_type }, + // Save on qstr's, reuse same as for module + .name = MP_QSTR_EVEL, + .print = EVEL_print, + .make_new = EVEL_make_new, + // .attr = EVEL_attr, + .locals_dict = (void*)&EVEL_locals_dict, +}; + +STATIC const mp_rom_map_elem_t mp_module_eveL_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_eveL) }, + { MP_ROM_QSTR(MP_QSTR_EVEL), MP_OBJ_FROM_PTR(&EVEL_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mp_module_eveL_globals, mp_module_eveL_globals_table); + +const mp_obj_module_t eveL_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_eveL_globals, +}; + +// #endif // MICROPY_PY_BUILTINS_EVEL diff --git a/shared-bindings/eveL/modeveL-gen.h b/shared-bindings/eveL/modeveL-gen.h new file mode 100644 index 0000000000..1c8d5ae12a --- /dev/null +++ b/shared-bindings/eveL/modeveL-gen.h @@ -0,0 +1,412 @@ + +STATIC mp_obj_t _alphafunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t func = mp_obj_get_int_truncated(a0); + uint32_t ref = mp_obj_get_int_truncated(a1); + C4(self, ((9 << 24) | ((func & 7) << 8) | ((ref & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); + +STATIC mp_obj_t _begin(mp_obj_t self , mp_obj_t a0) { + uint32_t prim = mp_obj_get_int_truncated(a0); + C4(self, ((31 << 24) | ((prim & 15))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); + +STATIC mp_obj_t _bitmapextformat(mp_obj_t self , mp_obj_t a0) { + uint32_t fmt = mp_obj_get_int_truncated(a0); + C4(self, ((46 << 24) | (fmt & 65535)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); + +STATIC mp_obj_t _bitmaphandle(mp_obj_t self , mp_obj_t a0) { + uint32_t handle = mp_obj_get_int_truncated(a0); + C4(self, ((5 << 24) | ((handle & 31))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); + +STATIC mp_obj_t _bitmaplayouth(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t linestride = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + C4(self, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); + +STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { + uint32_t format = mp_obj_get_int_truncated(args[1]); + uint32_t linestride = mp_obj_get_int_truncated(args[2]); + uint32_t height = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); + +STATIC mp_obj_t _bitmapsizeh(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + C4(self, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); + +STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { + uint32_t filter = mp_obj_get_int_truncated(args[1]); + uint32_t wrapx = mp_obj_get_int_truncated(args[2]); + uint32_t wrapy = mp_obj_get_int_truncated(args[3]); + uint32_t width = mp_obj_get_int_truncated(args[4]); + uint32_t height = mp_obj_get_int_truncated(args[5]); + C4(args[0], ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); + +STATIC mp_obj_t _bitmapsource(mp_obj_t self , mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + C4(self, ((1 << 24) | ((addr & 0xffffff))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); + +STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + C4(args[0], ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); + +STATIC mp_obj_t _bitmaptransforma(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t a = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((21 << 24) | ((p & 1) << 17) | ((a & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); + +STATIC mp_obj_t _bitmaptransformb(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t b = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((22 << 24) | ((p & 1) << 17) | ((b & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); + +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t c = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); + +STATIC mp_obj_t _bitmaptransformd(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t d = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((24 << 24) | ((p & 1) << 17) | ((d & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); + +STATIC mp_obj_t _bitmaptransforme(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t e = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((25 << 24) | ((p & 1) << 17) | ((e & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); + +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t f = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + C4(self, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); + +STATIC mp_obj_t _blendfunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t src = mp_obj_get_int_truncated(a0); + uint32_t dst = mp_obj_get_int_truncated(a1); + C4(self, ((11 << 24) | ((src & 7) << 3) | ((dst & 7))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); + +STATIC mp_obj_t _call(mp_obj_t self , mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + C4(self, ((29 << 24) | ((dest & 65535))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); + +STATIC mp_obj_t _cell(mp_obj_t self , mp_obj_t a0) { + uint32_t cell = mp_obj_get_int_truncated(a0); + C4(self, ((6 << 24) | ((cell & 127))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); + +STATIC mp_obj_t _clearcolora(mp_obj_t self , mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + C4(self, ((15 << 24) | ((alpha & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); + +STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); + +STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { + uint32_t c = mp_obj_get_int_truncated(args[1]); + uint32_t s = mp_obj_get_int_truncated(args[2]); + uint32_t t = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 4, 4, _clear); + +STATIC mp_obj_t _clearstencil(mp_obj_t self , mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + C4(self, ((17 << 24) | ((s & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); + +STATIC mp_obj_t _cleartag(mp_obj_t self , mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + C4(self, ((18 << 24) | ((s & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); + +STATIC mp_obj_t _colora(mp_obj_t self , mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + C4(self, ((16 << 24) | ((alpha & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); + +STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + C4(args[0], ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); + +STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); + +STATIC mp_obj_t _display(mp_obj_t self ) { + + C4(self, ((0 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); + +STATIC mp_obj_t _end(mp_obj_t self ) { + + C4(self, ((33 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); + +STATIC mp_obj_t _jump(mp_obj_t self , mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + C4(self, ((30 << 24) | ((dest & 65535))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); + +STATIC mp_obj_t _linewidth(mp_obj_t self , mp_obj_t a0) { + uint32_t width = mp_obj_get_int_truncated(a0); + C4(self, ((14 << 24) | ((width & 4095))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); + +STATIC mp_obj_t _macro(mp_obj_t self , mp_obj_t a0) { + uint32_t m = mp_obj_get_int_truncated(a0); + C4(self, ((37 << 24) | ((m & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); + +STATIC mp_obj_t _nop(mp_obj_t self ) { + + C4(self, ((45 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); + +STATIC mp_obj_t _palettesource(mp_obj_t self , mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + C4(self, ((42 << 24) | (((addr) & 4194303))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); + +STATIC mp_obj_t _pointsize(mp_obj_t self , mp_obj_t a0) { + uint32_t size = mp_obj_get_int_truncated(a0); + C4(self, ((13 << 24) | ((size & 8191))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); + +STATIC mp_obj_t _restorecontext(mp_obj_t self ) { + + C4(self, ((35 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); + +STATIC mp_obj_t _return(mp_obj_t self ) { + + C4(self, ((36 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); + +STATIC mp_obj_t _savecontext(mp_obj_t self ) { + + C4(self, ((34 << 24)) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); + +STATIC mp_obj_t _scissorsize(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + C4(self, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); + +STATIC mp_obj_t _scissorxy(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t x = mp_obj_get_int_truncated(a0); + uint32_t y = mp_obj_get_int_truncated(a1); + C4(self, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); + +STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { + uint32_t func = mp_obj_get_int_truncated(args[1]); + uint32_t ref = mp_obj_get_int_truncated(args[2]); + uint32_t mask = mp_obj_get_int_truncated(args[3]); + C4(args[0], ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); + +STATIC mp_obj_t _stencilmask(mp_obj_t self , mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + C4(self, ((19 << 24) | ((mask & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); + +STATIC mp_obj_t _stencilop(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { + uint32_t sfail = mp_obj_get_int_truncated(a0); + uint32_t spass = mp_obj_get_int_truncated(a1); + C4(self, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); + +STATIC mp_obj_t _tagmask(mp_obj_t self , mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + C4(self, ((20 << 24) | ((mask & 1))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); + +STATIC mp_obj_t _tag(mp_obj_t self , mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + C4(self, ((3 << 24) | ((s & 255))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); + +STATIC mp_obj_t _vertextranslatex(mp_obj_t self , mp_obj_t a0) { + uint32_t x = mp_obj_get_int_truncated(a0); + C4(self, ((43 << 24) | (((x) & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); + +STATIC mp_obj_t _vertextranslatey(mp_obj_t self , mp_obj_t a0) { + uint32_t y = mp_obj_get_int_truncated(a0); + C4(self, ((44 << 24) | (((y) & 131071))) +); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); +#define N_METHODS 47 +#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; } while (0) +#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) } From 0bcfabbc87b3702e0bc37442ae68856c65ac9751 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 3 Feb 2020 18:41:32 -0800 Subject: [PATCH 423/531] Add header for module eveL explaining what it is. Exclude modeveL-gen.h from Sphinx build --- conf.py | 1 + shared-bindings/eveL/__init__.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/conf.py b/conf.py index 3b29986c06..79af70cbac 100644 --- a/conf.py +++ b/conf.py @@ -156,6 +156,7 @@ exclude_patterns = ["**/build*", "ports/zephyr", "py", "shared-bindings/util.*", + "shared-bindings/eveL/modeveL-gen.h", "shared-module", "supervisor", "tests", diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c index 3bbffa257f..7a549b856c 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/eveL/__init__.c @@ -33,6 +33,18 @@ // #if MICROPY_PY_BUILTINS_EVEL +//| :mod:`eveL` --- low-level BridgeTek EVE bindings +//| ================================================ +//| +//| .. module:: eveL +//| :synopsis: low-level BridgeTek EVE bindings +//| :platform: SAMD21/SAMD51 +//| +//| The `eveL` module provides a class EVEL which +//| contains methods for constructing EVE command +//| buffers and appending basic graphics commands. +//| + typedef struct _mp_obj_EVEL_t { mp_obj_base_t base; mp_obj_t writer; From a4ebd2f7c112dc5d185d198e28e00edabd395a84 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 3 Feb 2020 22:09:53 -0500 Subject: [PATCH 424/531] allow tuple or list for Palette color --- ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk | 3 +++ shared-bindings/displayio/Palette.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 1d1891e8e8..51b4fc993c 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -10,6 +10,9 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_SMALL_BUILD = 1 +# TODO: Turn off analogio for now for space reasons, but restore it +# when frozen module gets smaller. +CIRCUITPY_ANALOGIO = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index dda58e3c53..67a7db85b8 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -86,7 +86,8 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1. //| //| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value). -//| Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), or bytearray. +//| Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), bytearray, +//| or a tuple or list of 3 integers. //| //| This allows you to:: //| @@ -94,6 +95,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[1] = b'\xff\xff\x00' # set using 3 bytes //| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes +//| palette[4] = (10, 20, 30) # set using a tuple of 3 integers //| STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { @@ -111,6 +113,12 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_palette_get_color(self, index)); } + // Convert a tuple or list to a bytearray. + if (MP_OBJ_IS_TYPE(value, &mp_type_tuple) || + MP_OBJ_IS_TYPE(value, &mp_type_list)) { + value = mp_type_bytes.make_new(&mp_type_bytes, 1, &value, NULL); + } + uint32_t color; mp_int_t int_value; mp_buffer_info_t bufinfo; @@ -130,7 +138,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val } color = int_value; } else { - mp_raise_TypeError(translate("color buffer must be a buffer or int")); + mp_raise_TypeError(translate("color buffer must be a buffer, tuple, list, or int")); } common_hal_displayio_palette_set_color(self, index, color); return mp_const_none; From 8347f2b5c3a441e9c30ff70d4d779f9b236cf7df Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 3 Feb 2020 19:23:42 -0800 Subject: [PATCH 425/531] Correct default state to off for eveL module. Fix build break because of overflowing small ports --- py/circuitpy_mpconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index f56d994789..b72eec7c5b 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -175,7 +175,7 @@ endif CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) ifndef CIRCUITPY_EVEL -CIRCUITPY_EVEL = $(CIRCUITPY_ALWAYS_BUILD) +CIRCUITPY_EVEL = 0 endif CFLAGS += -DCIRCUITPY_EVEL=$(CIRCUITPY_EVEL) From 66ca659709b0033a3199375deef2eaa75d2e1d53 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 3 Feb 2020 23:41:15 -0500 Subject: [PATCH 426/531] make translate --- locale/ID.po | 4 ++-- locale/circuitpython.pot | 4 ++-- locale/de_DE.po | 12 ++++++------ locale/en_US.po | 4 ++-- locale/en_x_pirate.po | 4 ++-- locale/es.po | 14 ++++++-------- locale/fil.po | 11 ++++++----- locale/fr.po | 16 +++++++--------- locale/it_IT.po | 12 ++++++------ locale/ko.po | 4 ++-- locale/pl.po | 14 ++++++-------- locale/pt_BR.po | 4 ++-- locale/zh_Latn_pinyin.po | 14 ++++++-------- 13 files changed, 55 insertions(+), 62 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 36bfc4df64..02b7376cc5 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1845,7 +1845,7 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" +msgid "color buffer must be a buffer, tuple, list, or int" msgstr "" #: shared-bindings/displayio/Palette.c diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index f85bcba83f..acd4c3eb0f 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1821,7 +1821,7 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" +msgid "color buffer must be a buffer, tuple, list, or int" msgstr "" #: shared-bindings/displayio/Palette.c diff --git a/locale/de_DE.po b/locale/de_DE.po index ba1915e430..435050c8d8 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -1849,8 +1849,8 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "Farbpuffer muss 3 Bytes (RGB) oder 4 Bytes (RGB + pad byte) sein" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" -msgstr "Farbpuffer muss ein Puffer oder ein int sein" +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" @@ -2853,7 +2853,6 @@ msgstr "" #~ msgid "C-level assert" #~ msgstr "C-Level Assert" -#, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Kann dotstar nicht mit %s verwenden" @@ -3167,17 +3166,18 @@ msgstr "" #~ "Sie laufen im abgesicherten Modus, was bedeutet, dass etwas Unerwartetes " #~ "passiert ist.\n" -#, c-format #~ msgid "buf is too small. need %d bytes" #~ msgstr "buf ist zu klein. brauche %d Bytes" #~ msgid "buffer too long" #~ msgstr "Buffer zu lang" -#, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "byteorder ist keine Instanz von ByteOrder (%s erhalten)" +#~ msgid "color buffer must be a buffer or int" +#~ msgstr "Farbpuffer muss ein Puffer oder ein int sein" + #~ msgid "expected a DigitalInOut" #~ msgstr "erwarte DigitalInOut" diff --git a/locale/en_US.po b/locale/en_US.po index c6a78b505b..7c44dc02ff 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -1821,7 +1821,7 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" +msgid "color buffer must be a buffer, tuple, list, or int" msgstr "" #: shared-bindings/displayio/Palette.c diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 12ca1d6082..e84725f4f1 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -1825,7 +1825,7 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" +msgid "color buffer must be a buffer, tuple, list, or int" msgstr "" #: shared-bindings/displayio/Palette.c diff --git a/locale/es.po b/locale/es.po index b4e0981650..c86a1e1e36 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -1850,8 +1850,8 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "color buffer debe ser 3 bytes (RGB) ó 4 bytes (RGB + pad byte)" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" -msgstr "color buffer deber ser un buffer o un int" +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" @@ -2853,7 +2853,6 @@ msgstr "paso cero" #~ "Intento de allocation de heap cuando la VM de MicroPython no estaba " #~ "corriendo.\n" -#, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "No se puede usar dotstar con %s" @@ -3194,14 +3193,12 @@ msgstr "paso cero" #~ msgid "bad GATT role" #~ msgstr "mal GATT role" -#, c-format #~ msgid "buf is too small. need %d bytes" #~ msgstr "buf es demasiado pequeño. necesita %d bytes" #~ msgid "buffer too long" #~ msgstr "buffer demasiado largo" -#, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "byteorder no es instancia de ByteOrder (encontarmos un %s)" @@ -3223,6 +3220,9 @@ msgstr "paso cero" #~ msgid "characteristics includes an object that is not a Characteristic" #~ msgstr "characteristics incluye un objeto que no es una Characteristica" +#~ msgid "color buffer must be a buffer or int" +#~ msgstr "color buffer deber ser un buffer o un int" + #~ msgid "either pos or kw args are allowed" #~ msgstr "ya sea pos o kw args son permitidos" @@ -3312,11 +3312,9 @@ msgstr "paso cero" #~ msgid "unknown config param" #~ msgstr "parámetro config desconocido" -#, c-format #~ msgid "unknown format code '%c' for object of type 'float'" #~ msgstr "codigo format desconocido '%c' para el typo de objeto 'float'" -#, c-format #~ msgid "unknown format code '%c' for object of type 'str'" #~ msgstr "codigo format desconocido '%c' para objeto de tipo 'str'" diff --git a/locale/fil.po b/locale/fil.po index 86378ba107..27c0accbf7 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -1861,8 +1861,8 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "color buffer ay dapat na 3 bytes (RGB) o 4 bytes (RGB + pad byte)" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" -msgstr "color buffer ay dapat buffer or int" +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" @@ -3176,6 +3176,9 @@ msgstr "zero step" #~ msgid "can't set STA config" #~ msgstr "hindi makuha ang STA config" +#~ msgid "color buffer must be a buffer or int" +#~ msgstr "color buffer ay dapat buffer or int" + #~ msgid "either pos or kw args are allowed" #~ msgstr "pos o kw args ang pinahihintulutan" @@ -3254,11 +3257,9 @@ msgstr "zero step" #~ msgid "unknown config param" #~ msgstr "hindi alam na config param" -#, c-format #~ msgid "unknown format code '%c' for object of type 'float'" #~ msgstr "hindi alam ang format code '%c' sa object na ang type ay 'float'" -#, c-format #~ msgid "unknown format code '%c' for object of type 'str'" #~ msgstr "" #~ "hindi alam ang format ng code na '%c' para sa object ng type ay 'str'" diff --git a/locale/fr.po b/locale/fr.po index b522b253da..504cc8a29f 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -1884,9 +1884,8 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "le tampon de couleur doit faire 3 octets (RVB) ou 4 (RVB + pad byte)" #: shared-bindings/displayio/Palette.c -#, fuzzy -msgid "color buffer must be a buffer or int" -msgstr "le tampon de couleur doit être un tampon ou un entier 'int'" +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" #: shared-bindings/displayio/Palette.c #, fuzzy @@ -2903,7 +2902,6 @@ msgstr "'step' nul" #~ msgstr "" #~ "Tentative d'allocation de tas alors que la VM MicroPython ne tourne pas.\n" -#, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Impossible d'utiliser 'dotstar' avec %s" @@ -3253,14 +3251,12 @@ msgstr "'step' nul" #~ msgid "bad GATT role" #~ msgstr "mauvais rôle GATT" -#, c-format #~ msgid "buf is too small. need %d bytes" #~ msgstr "'buf' est trop petit. Besoin de %d octets" #~ msgid "buffer too long" #~ msgstr "tampon trop long" -#, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "'byteorder' n'est pas une instance de ByteOrder (reçu un %s)" @@ -3283,6 +3279,10 @@ msgstr "'step' nul" #~ msgstr "" #~ "'characteristics' inclut un objet qui n'est pas une 'Characteristic'" +#, fuzzy +#~ msgid "color buffer must be a buffer or int" +#~ msgstr "le tampon de couleur doit être un tampon ou un entier 'int'" + #~ msgid "either pos or kw args are allowed" #~ msgstr "soit 'pos', soit 'kw' est permis en argument" @@ -3368,11 +3368,9 @@ msgstr "'step' nul" #~ msgid "unknown config param" #~ msgstr "paramètre de config. inconnu" -#, c-format #~ msgid "unknown format code '%c' for object of type 'float'" #~ msgstr "code de format '%c' inconnu pour un objet de type 'float'" -#, c-format #~ msgid "unknown format code '%c' for object of type 'str'" #~ msgstr "code de format '%c' inconnu pour un objet de type 'str'" diff --git a/locale/it_IT.po b/locale/it_IT.po index e4a06b7691..65e733c8bc 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -1862,8 +1862,8 @@ msgstr "" "il buffer del colore deve esseer di 3 byte (RGB) o 4 byte (RGB + pad byte)" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" -msgstr "il buffer del colore deve essere un buffer o un int" +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" @@ -2870,7 +2870,6 @@ msgstr "zero step" #~ msgid "C-level assert" #~ msgstr "assert a livello C" -#, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "dotstar non può essere usato con %s" @@ -3166,6 +3165,9 @@ msgstr "zero step" #~ msgid "can't set STA config" #~ msgstr "impossibile impostare le configurazioni della STA" +#~ msgid "color buffer must be a buffer or int" +#~ msgstr "il buffer del colore deve essere un buffer o un int" + #~ msgid "either pos or kw args are allowed" #~ msgstr "sono permesse solo gli argomenti pos o kw" @@ -3241,12 +3243,10 @@ msgstr "zero step" #~ msgid "unknown config param" #~ msgstr "parametro di configurazione sconosciuto" -#, c-format #~ msgid "unknown format code '%c' for object of type 'float'" #~ msgstr "" #~ "codice di formattazione '%c' sconosciuto per oggetto di tipo 'float'" -#, c-format #~ msgid "unknown format code '%c' for object of type 'str'" #~ msgstr "codice di formattazione '%c' sconosciuto per oggetto di tipo 'str'" diff --git a/locale/ko.po b/locale/ko.po index fa49366825..68df091529 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -1826,7 +1826,7 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" +msgid "color buffer must be a buffer, tuple, list, or int" msgstr "" #: shared-bindings/displayio/Palette.c diff --git a/locale/pl.po b/locale/pl.po index 70106112ed..7570a47b59 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -1829,8 +1829,8 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "bufor kolorów musi nieć 3 bajty (RGB) lub 4 bajty (RGB + wypełnienie)" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" -msgstr "bufor kolorów musi być typu buffer lub int" +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" @@ -2816,7 +2816,6 @@ msgstr "zerowy krok" #~ msgid "Attempted heap allocation when MicroPython VM not running.\n" #~ msgstr "Próba alokacji pamięci na stercie gdy VM nie działa.\n" -#, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Nie można używać dotstar z %s" @@ -3035,11 +3034,9 @@ msgstr "zerowy krok" #~ msgid "bad GATT role" #~ msgstr "zła rola GATT" -#, c-format #~ msgid "buf is too small. need %d bytes" #~ msgstr "buf zbyt mały. Wymagane %d bajtów" -#, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "byteorder musi być typu ByteOrder (jest %s)" @@ -3047,6 +3044,9 @@ msgstr "zerowy krok" #~ msgstr "" #~ "charakterystyki zawierają obiekt, który nie jest typu Characteristic" +#~ msgid "color buffer must be a buffer or int" +#~ msgstr "bufor kolorów musi być typu buffer lub int" + #~ msgid "interval not in range 0.0020 to 10.24" #~ msgstr "przedział poza zakresem 0.0020 do 10.24" @@ -3068,11 +3068,9 @@ msgstr "zerowy krok" #~ msgid "timeout >100 (units are now seconds, not msecs)" #~ msgstr "timeout > 100 (jednostkami są sekundy)" -#, c-format #~ msgid "unknown format code '%c' for object of type 'float'" #~ msgstr "zły kod foratowania '%c' dla obiektu typu 'float'" -#, c-format #~ msgid "unknown format code '%c' for object of type 'str'" #~ msgstr "zły kod formatowania '%c' dla obiektu typu 'str'" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 755dc6d972..772aba0893 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -1842,7 +1842,7 @@ msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" msgstr "" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" +msgid "color buffer must be a buffer, tuple, list, or int" msgstr "" #: shared-bindings/displayio/Palette.c diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 369ce4426c..b7375d48cb 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-03 23:41-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -1839,8 +1839,8 @@ msgstr "" "yánsè huǎnchōng qū bìxū wèi 3 zì jié (RGB) huò 4 zì jié (RGB + pad zì jié)" #: shared-bindings/displayio/Palette.c -msgid "color buffer must be a buffer or int" -msgstr "yánsè huǎnchōng qū bìxū shì huǎnchōng qū huò zhěngshù" +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" @@ -2829,7 +2829,6 @@ msgstr "líng bù" #~ msgid "Attempted heap allocation when MicroPython VM not running.\n" #~ msgstr "MicroPython VM wèi yùnxíng shí chángshì duī fēnpèi.\n" -#, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" @@ -3091,17 +3090,18 @@ msgstr "líng bù" #~ msgid "bad GATT role" #~ msgstr "zǒng xiédìng de bùliáng juésè" -#, c-format #~ msgid "buf is too small. need %d bytes" #~ msgstr "huǎnchōng tài xiǎo. Xūyào%d zì jié" -#, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "zì jié bùshì zì jié xù shílì (yǒu %s)" #~ msgid "characteristics includes an object that is not a Characteristic" #~ msgstr "tèxìng bāokuò bùshì zìfú de wùtǐ" +#~ msgid "color buffer must be a buffer or int" +#~ msgstr "yánsè huǎnchōng qū bìxū shì huǎnchōng qū huò zhěngshù" + #~ msgid "expected a DigitalInOut" #~ msgstr "qídài de DigitalInOut" @@ -3132,11 +3132,9 @@ msgstr "líng bù" #~ msgid "too many arguments" #~ msgstr "tài duō cānshù" -#, c-format #~ msgid "unknown format code '%c' for object of type 'float'" #~ msgstr "lèixíng 'float' duìxiàng wèizhī de géshì dàimǎ '%c'" -#, c-format #~ msgid "unknown format code '%c' for object of type 'str'" #~ msgstr "lèixíng 'str' duìxiàng wèizhī de géshì dàimǎ '%c'" From 3ce6fc89a4b5bb97edc8568d1cd41aed04635b94 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 4 Feb 2020 10:38:45 -0500 Subject: [PATCH 427/531] Implement new linker for external flash only --- ports/stm32f4/Makefile | 2 +- ports/stm32f4/boards/STM32F405_default.ld | 107 ++++++++++++++++++ .../mpconfigboard.mk | 2 +- 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 ports/stm32f4/boards/STM32F405_default.ld diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 082d050390..3a6191c851 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -119,7 +119,7 @@ ifndef LD_FILE BOOTLOADER_OFFSET = $(UF2_OFFSET) CFLAGS += -DUF2_BOOTLOADER_ENABLED else - LD_FILE = $(LD_FS) + LD_FILE = $(LD_DEFAULT) endif endif diff --git a/ports/stm32f4/boards/STM32F405_default.ld b/ports/stm32f4/boards/STM32F405_default.ld new file mode 100644 index 0000000000..c2b8c843ee --- /dev/null +++ b/ports/stm32f4/boards/STM32F405_default.ld @@ -0,0 +1,107 @@ +/* + GNU linker script for STM32F405 via Micropython +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ + FLASH_TEXT (rx) : ORIGIN = 0x08004000, LENGTH = 1008K /* sectors 0-7*/ + CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 2K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +ENTRY(Reset_Handler) + +/* define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + + /* This first flash block is 16K annd 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. */ + + . = ALIGN(4); + } >FLASH_ISR + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + /* *(.glue_7) */ /* glue arm to thumb code */ + /* *(.glue_7t) */ /* glue thumb to arm code */ + + . = ALIGN(4); + _etext = .; /* define a global symbol at end of code */ + } >FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ + } >RAM AT> FLASH_TEXT + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + _sbss = .; /* define a global symbol at bss start; used by startup code */ + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ + } >RAM + + /* this is to define the start of the heap, and make sure we have a minimum size */ + .heap : + { + . = ALIGN(4); + . = . + _minimum_heap_size; + . = ALIGN(4); + } >RAM + + /* this just checks there is enough RAM for the stack */ + .stack : + { + . = ALIGN(4); + . = . + _minimum_stack_size; + . = ALIGN(4); + } >RAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk index 3fc8581ef9..312ca6b480 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk @@ -16,7 +16,7 @@ MCU_PACKAGE = 64 CMSIS_MCU = STM32F405xx # Default includes filesystem, but uses external flash -LD_FS = boards/STM32F405_fs.ld +LD_DEFAULT = boards/STM32F405_default.ld LD_BOOT = boards/STM32F405_boot.ld # UF2 boot option UF2_OFFSET = 0x8010000 From 04f93c82739a0511dc06295c595a5b1f58541e8f Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 4 Feb 2020 10:45:26 -0500 Subject: [PATCH 428/531] add board to workflow --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50fafdc7ff..ea2e724878 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -215,6 +215,7 @@ jobs: - "stm32f411ce_blackpill" - "stm32f411ve_discovery" - "stm32f412zg_discovery" + - "stm32f4_discovery" - "stringcar_m0_express" - "teensy40" - "teknikio_bluebird" From 6f731267562a78a5451e631eacfce5056e13f214 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 4 Feb 2020 10:46:44 -0500 Subject: [PATCH 429/531] add correct PID --- ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk index 3e3dba6e80..9bdc624044 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x805E +USB_PID = 0x808A USB_PRODUCT = "STM32F407VG Discovery Board - CPy" USB_MANUFACTURER = "STMicroelectronics" USB_DEVICES = "CDC,MSC" From 57b566e73614c74a9fc74cd2d2007d91cdb507db Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 4 Feb 2020 13:32:39 -0500 Subject: [PATCH 430/531] Include filename for 'No such file/directory', etc. --- extmod/vfs_fat_file.c | 2 +- py/runtime.c | 9 +++++++++ py/runtime.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 3ea9cee529..dc0a893a5c 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -199,7 +199,7 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode); if (res != FR_OK) { m_del_obj(pyb_file_obj_t, o); - mp_raise_OSError(fresult_to_errno_table[res]); + mp_raise_OSError_errno_str(fresult_to_errno_table[res], fname); } // If we're reading, turn on fast seek. if (mode == FA_READ) { diff --git a/py/runtime.c b/py/runtime.c index 48416bab26..cb174837c7 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -29,10 +29,12 @@ #include #include + #include "extmod/vfs.h" #include "py/parsenum.h" #include "py/compile.h" +#include "py/mperrno.h" #include "py/objstr.h" #include "py/objtuple.h" #include "py/objtype.h" @@ -1576,6 +1578,13 @@ NORETURN 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_, const char *str) { + char decompressed[50]; + const char *errno_str = mp_common_errno_to_str(MP_OBJ_NEW_SMALL_INT(errno_), + decompressed, sizeof(decompressed)); + mp_raise_OSError_msg_varg(translate("[Errno %d] %s: %s"), errno_, errno_str, str); +} + NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); diff --git a/py/runtime.h b/py/runtime.h index 4121352dfd..319de5bb96 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -161,6 +161,7 @@ NORETURN void mp_raise_RuntimeError(const compressed_string_t *msg); NORETURN void mp_raise_ImportError(const compressed_string_t *msg); NORETURN void mp_raise_IndexError(const compressed_string_t *msg); NORETURN void mp_raise_OSError(int errno_); +NORETURN void mp_raise_OSError_errno_str(int errno_, const char *str); NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg); NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg); From 5164719e67878418cff51d26f40e4813da02bc83 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 4 Feb 2020 16:19:40 -0500 Subject: [PATCH 431/531] preserve errno in OSError --- extmod/vfs_fat_file.c | 3 ++- py/objexcept.c | 7 +++++-- py/runtime.c | 11 ++++++----- py/runtime.h | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index dc0a893a5c..422f057a85 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -28,6 +28,7 @@ #if MICROPY_VFS && MICROPY_VFS_FAT #include +#include #include "py/runtime.h" #include "py/stream.h" @@ -199,7 +200,7 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode); if (res != FR_OK) { m_del_obj(pyb_file_obj_t, o); - mp_raise_OSError_errno_str(fresult_to_errno_table[res], fname); + mp_raise_OSError_errno_str(fresult_to_errno_table[res], args[0].u_obj); } // If we're reading, turn on fast seek. if (mode == FA_READ) { diff --git a/py/objexcept.c b/py/objexcept.c index c33ada0d69..8664060ec5 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -112,14 +112,17 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin if (o->args == NULL || o->args->len == 0) { mp_print_str(print, ""); return; - } else if (o->args->len == 1) { - // try to provide a nice OSError error message + } else if (o->args->len <= 2) { + // try to provide a nice OSError error message; second arg might exist (e.g. filename). if (MP_OBJ_IS_SMALL_INT(o->args->items[0]) && mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(o->base.type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { char decompressed[50]; const char *msg = mp_common_errno_to_str(o->args->items[0], decompressed, sizeof(decompressed)); if (msg != NULL) { mp_printf(print, "[Errno " INT_FMT "] %s", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), msg); + if (o->args->len == 2) { + mp_printf(print, ": '%s'", mp_obj_str_get_str(o->args->items[1])); + } return; } } diff --git a/py/runtime.c b/py/runtime.c index cb174837c7..c1c311ae4c 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1578,11 +1578,12 @@ NORETURN 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_, const char *str) { - char decompressed[50]; - const char *errno_str = mp_common_errno_to_str(MP_OBJ_NEW_SMALL_INT(errno_), - decompressed, sizeof(decompressed)); - mp_raise_OSError_msg_varg(translate("[Errno %d] %s: %s"), errno_, errno_str, str); +NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str) { + mp_obj_t args[2] = { + MP_OBJ_NEW_SMALL_INT(errno_), + 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, ...) { diff --git a/py/runtime.h b/py/runtime.h index 319de5bb96..f811035571 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -161,7 +161,7 @@ NORETURN void mp_raise_RuntimeError(const compressed_string_t *msg); NORETURN void mp_raise_ImportError(const compressed_string_t *msg); NORETURN void mp_raise_IndexError(const compressed_string_t *msg); NORETURN void mp_raise_OSError(int errno_); -NORETURN void mp_raise_OSError_errno_str(int errno_, const char *str); +NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str); NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg); NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg); From 4ba050d46d2b6e9cd347f1b749a1a102affbd0b5 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 4 Feb 2020 16:26:24 -0500 Subject: [PATCH 432/531] Add ADC for temp sensor --- .../common-hal/microcontroller/Processor.c | 92 ++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/common-hal/microcontroller/Processor.c b/ports/stm32f4/common-hal/microcontroller/Processor.c index 3ab746685d..0f8824ee57 100644 --- a/ports/stm32f4/common-hal/microcontroller/Processor.c +++ b/ports/stm32f4/common-hal/microcontroller/Processor.c @@ -3,7 +3,6 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Dan Halbert for Adafruit Industries * Copyright (c) 2019 Lucian Copeland for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -34,11 +33,100 @@ #define STM32_UUID ((uint32_t *)0x1FFF7A10) +//Factory calibration locations +#define ADC_CAL_ADDRESS (0x1fff7a2a) +#define ADC_CAL1 ((uint16_t*)(ADC_CAL_ADDRESS + 2)) +#define ADC_CAL2 ((uint16_t*)(ADC_CAL_ADDRESS + 4)) + +// correction factor for reference value +STATIC volatile float adc_refcor = 1.0f; + +#define CORE_TEMP_V25 (943) /* (0.76v/3.3v)*(2^ADC resoultion) */ +#define CORE_TEMP_AVG_SLOPE (3) /* (2.5mv/3.3v)*(2^ADC resoultion) */ + float common_hal_mcu_processor_get_temperature(void) { - return NAN; + __HAL_RCC_ADC1_CLK_ENABLE(); + + //HAL Implementation + ADC_HandleTypeDef AdcHandle; + ADC_ChannelConfTypeDef sConfig; + + AdcHandle.Instance = ADC1; + AdcHandle.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; + AdcHandle.Init.Resolution = ADC_RESOLUTION_12B; + AdcHandle.Init.ScanConvMode = DISABLE; + AdcHandle.Init.ContinuousConvMode = DISABLE; + AdcHandle.Init.DiscontinuousConvMode = DISABLE; + AdcHandle.Init.NbrOfDiscConversion = 0; + AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START; + AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; + AdcHandle.Init.NbrOfConversion = 1; + AdcHandle.Init.DMAContinuousRequests = DISABLE; + AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + HAL_ADC_Init(&AdcHandle); + + ADC->CCR |= ADC_CCR_TSVREFE; + ADC->CCR &= ~ADC_CCR_VBATE; // If this somehow got turned on, it'll return bad values. + + sConfig.Channel = ADC_CHANNEL_TEMPSENSOR; //either 16 or 18, depending on chip + sConfig.Rank = 1; + sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES; //Taken from micropython + HAL_ADC_ConfigChannel(&AdcHandle, &sConfig); + + HAL_ADC_Start(&AdcHandle); + if (HAL_ADC_PollForConversion(&AdcHandle,1) != HAL_OK) { + mp_raise_RuntimeError(translate("Temperature read timed out")); + } + uint32_t value = (uint32_t)HAL_ADC_GetValue(&AdcHandle); + HAL_ADC_Stop(&AdcHandle); + + //There's no F4 specific appnote for this but it works the same as the L1 in AN3964 + float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0; + return (((float)value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f; + + // STATIC uint32_t adc_config_and_read_channel(ADC_HandleTypeDef *adcHandle, uint32_t channel) { + // adc_config_channel(adcHandle, channel); + // uint32_t raw_value = adc_read_channel(adcHandle); + + // #if defined(STM32F4) || defined(STM32F7) + // // ST docs say that (at least on STM32F42x and STM32F43x), VBATE must + // // be disabled when TSVREFE is enabled for TEMPSENSOR and VREFINT + // // conversions to work. VBATE is enabled by the above call to read + // // the channel, and here we disable VBATE so a subsequent call for + // // TEMPSENSOR or VREFINT works correctly. + // if (channel == ADC_CHANNEL_VBAT) { + // ADC->CCR &= ~ADC_CCR_VBATE; + // } + // #endif + + // return raw_value; + + // int adc_read_core_temp(ADC_HandleTypeDef *adcHandle) { + // int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR); + // return ((raw_value - CORE_TEMP_V25) / CORE_TEMP_AVG_SLOPE) + 25; + // } + + // #if MICROPY_PY_BUILTINS_FLOAT + // // correction factor for reference value + // STATIC volatile float adc_refcor = 1.0f; + + // float adc_read_core_temp_float(ADC_HandleTypeDef *adcHandle) { + // int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR); + // float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0; + // return (((float)raw_value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f; + // } } float common_hal_mcu_processor_get_voltage(void) { +// float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) { +// uint32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_VREFINT); + +// // update the reference correction factor +// adc_refcor = ((float)(*VREFIN_CAL)) / ((float)raw_value); + +// return (*VREFIN_CAL) * ADC_SCALE; +// } return NAN; } From 7fe959ab39e14b000934b15d7cce13aae9f6a525 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 4 Feb 2020 16:41:25 -0500 Subject: [PATCH 433/531] fix multi-arg exception printing --- py/objexcept.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/py/objexcept.c b/py/objexcept.c index 8664060ec5..f211b87ee0 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -112,20 +112,22 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin if (o->args == NULL || o->args->len == 0) { mp_print_str(print, ""); return; - } else if (o->args->len <= 2) { - // try to provide a nice OSError error message; second arg might exist (e.g. filename). - if (MP_OBJ_IS_SMALL_INT(o->args->items[0]) && - mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(o->base.type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { - char decompressed[50]; - const char *msg = mp_common_errno_to_str(o->args->items[0], decompressed, sizeof(decompressed)); - if (msg != NULL) { - mp_printf(print, "[Errno " INT_FMT "] %s", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), msg); - if (o->args->len == 2) { - mp_printf(print, ": '%s'", mp_obj_str_get_str(o->args->items[1])); - } - return; + } + if (MP_OBJ_IS_SMALL_INT(o->args->items[0]) && + mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(o->base.type), MP_OBJ_FROM_PTR(&mp_type_OSError)) && + o->args->len <= 2) { + // try to provide a nice OSError error message + char decompressed[50]; + const char *msg = mp_common_errno_to_str(o->args->items[0], decompressed, sizeof(decompressed)); + if (msg != NULL) { + mp_printf(print, "[Errno " INT_FMT "] %s", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), msg); + // if second arg exists, it is filename. + if (o->args->len == 2) { + mp_printf(print, ": '%s'", mp_obj_str_get_str(o->args->items[1])); } + return; } + } else if (o->args->len == 1) { mp_obj_print_helper(print, o->args->items[0], PRINT_STR); return; } From e13642351c2827e62a614d569138de8971ebd7c8 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 4 Feb 2020 16:55:56 -0500 Subject: [PATCH 434/531] fix printing single-arg exceptions --- py/objexcept.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py/objexcept.c b/py/objexcept.c index f211b87ee0..b7a536c5e3 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -127,7 +127,8 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin } return; } - } else if (o->args->len == 1) { + } + if (o->args->len == 1) { mp_obj_print_helper(print, o->args->items[0], PRINT_STR); return; } From b6da2fa17321305d957d54cd278910a81cfb9392 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 5 Feb 2020 11:25:31 -0500 Subject: [PATCH 435/531] nrf: fix i2c frequency setting --- ports/nrf/common-hal/busio/I2C.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index 219fbf4470..37cb192df8 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -137,11 +137,17 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG(scl->number, sda->number); - // change freq. only if it's less than the default 400K - if (frequency < 100000) { - config.frequency = NRF_TWIM_FREQ_100K; - } else if (frequency < 250000) { +#if defined(TWIM_FREQUENCY_FREQUENCY_K1000) + if (frequency >= 1000000) { + config.frequency = NRF_TWIM_FREQ_1000K; + } else +#endif + if (frequency >= 400000) { + config.frequency = NRF_TWIM_FREQ_400K; + } else if (frequency >= 250000) { config.frequency = NRF_TWIM_FREQ_250K; + } else { + config.frequency = NRF_TWIM_FREQ_100K; } self->scl_pin_number = scl->number; From cedf6489f7ed04e403afff7d9edbbfa83b2c337c Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 5 Feb 2020 12:39:12 -0500 Subject: [PATCH 436/531] Add voltage ADC, standardize mphalport --- .../common-hal/microcontroller/Processor.c | 98 ++++++++----------- ports/stm32f4/mphalport.c | 21 ++-- ports/stm32f4/mphalport.h | 28 ++++-- 3 files changed, 75 insertions(+), 72 deletions(-) diff --git a/ports/stm32f4/common-hal/microcontroller/Processor.c b/ports/stm32f4/common-hal/microcontroller/Processor.c index 0f8824ee57..324659cefa 100644 --- a/ports/stm32f4/common-hal/microcontroller/Processor.c +++ b/ports/stm32f4/common-hal/microcontroller/Processor.c @@ -37,12 +37,26 @@ #define ADC_CAL_ADDRESS (0x1fff7a2a) #define ADC_CAL1 ((uint16_t*)(ADC_CAL_ADDRESS + 2)) #define ADC_CAL2 ((uint16_t*)(ADC_CAL_ADDRESS + 4)) +#define VREFIN_CAL ((uint16_t *)ADC_CAL_ADDRESS) // correction factor for reference value STATIC volatile float adc_refcor = 1.0f; -#define CORE_TEMP_V25 (943) /* (0.76v/3.3v)*(2^ADC resoultion) */ -#define CORE_TEMP_AVG_SLOPE (3) /* (2.5mv/3.3v)*(2^ADC resoultion) */ +STATIC void set_adc_params(ADC_HandleTypeDef *AdcHandle) { + AdcHandle->Instance = ADC1; + AdcHandle->Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; + AdcHandle->Init.Resolution = ADC_RESOLUTION_12B; + AdcHandle->Init.ScanConvMode = DISABLE; + AdcHandle->Init.ContinuousConvMode = DISABLE; + AdcHandle->Init.DiscontinuousConvMode = DISABLE; + AdcHandle->Init.NbrOfDiscConversion = 0; + AdcHandle->Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + AdcHandle->Init.ExternalTrigConv = ADC_SOFTWARE_START; + AdcHandle->Init.DataAlign = ADC_DATAALIGN_RIGHT; + AdcHandle->Init.NbrOfConversion = 1; + AdcHandle->Init.DMAContinuousRequests = DISABLE; + AdcHandle->Init.EOCSelection = ADC_EOC_SINGLE_CONV; +} float common_hal_mcu_processor_get_temperature(void) { __HAL_RCC_ADC1_CLK_ENABLE(); @@ -50,20 +64,7 @@ float common_hal_mcu_processor_get_temperature(void) { //HAL Implementation ADC_HandleTypeDef AdcHandle; ADC_ChannelConfTypeDef sConfig; - - AdcHandle.Instance = ADC1; - AdcHandle.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; - AdcHandle.Init.Resolution = ADC_RESOLUTION_12B; - AdcHandle.Init.ScanConvMode = DISABLE; - AdcHandle.Init.ContinuousConvMode = DISABLE; - AdcHandle.Init.DiscontinuousConvMode = DISABLE; - AdcHandle.Init.NbrOfDiscConversion = 0; - AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START; - AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; - AdcHandle.Init.NbrOfConversion = 1; - AdcHandle.Init.DMAContinuousRequests = DISABLE; - AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + set_adc_params(&AdcHandle); HAL_ADC_Init(&AdcHandle); ADC->CCR |= ADC_CCR_TSVREFE; @@ -71,7 +72,7 @@ float common_hal_mcu_processor_get_temperature(void) { sConfig.Channel = ADC_CHANNEL_TEMPSENSOR; //either 16 or 18, depending on chip sConfig.Rank = 1; - sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES; //Taken from micropython + sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES; // Temp sensor likes 10us minimum HAL_ADC_ConfigChannel(&AdcHandle, &sConfig); HAL_ADC_Start(&AdcHandle); @@ -84,50 +85,35 @@ float common_hal_mcu_processor_get_temperature(void) { //There's no F4 specific appnote for this but it works the same as the L1 in AN3964 float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0; return (((float)value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f; - - // STATIC uint32_t adc_config_and_read_channel(ADC_HandleTypeDef *adcHandle, uint32_t channel) { - // adc_config_channel(adcHandle, channel); - // uint32_t raw_value = adc_read_channel(adcHandle); - - // #if defined(STM32F4) || defined(STM32F7) - // // ST docs say that (at least on STM32F42x and STM32F43x), VBATE must - // // be disabled when TSVREFE is enabled for TEMPSENSOR and VREFINT - // // conversions to work. VBATE is enabled by the above call to read - // // the channel, and here we disable VBATE so a subsequent call for - // // TEMPSENSOR or VREFINT works correctly. - // if (channel == ADC_CHANNEL_VBAT) { - // ADC->CCR &= ~ADC_CCR_VBATE; - // } - // #endif - - // return raw_value; - - // int adc_read_core_temp(ADC_HandleTypeDef *adcHandle) { - // int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR); - // return ((raw_value - CORE_TEMP_V25) / CORE_TEMP_AVG_SLOPE) + 25; - // } - - // #if MICROPY_PY_BUILTINS_FLOAT - // // correction factor for reference value - // STATIC volatile float adc_refcor = 1.0f; - - // float adc_read_core_temp_float(ADC_HandleTypeDef *adcHandle) { - // int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR); - // float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0; - // return (((float)raw_value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f; - // } } float common_hal_mcu_processor_get_voltage(void) { -// float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) { -// uint32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_VREFINT); + __HAL_RCC_ADC1_CLK_ENABLE(); -// // update the reference correction factor -// adc_refcor = ((float)(*VREFIN_CAL)) / ((float)raw_value); + //HAL Implementation + ADC_HandleTypeDef AdcHandle; + ADC_ChannelConfTypeDef sConfig; + set_adc_params(&AdcHandle); + HAL_ADC_Init(&AdcHandle); -// return (*VREFIN_CAL) * ADC_SCALE; -// } - return NAN; + ADC->CCR |= ADC_CCR_TSVREFE; + + sConfig.Channel = ADC_CHANNEL_VREFINT; + sConfig.Rank = 1; + sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES; + HAL_ADC_ConfigChannel(&AdcHandle, &sConfig); + + HAL_ADC_Start(&AdcHandle); + if (HAL_ADC_PollForConversion(&AdcHandle,1) != HAL_OK) { + mp_raise_RuntimeError(translate("Voltage read timed out")); + } + uint32_t value = (uint32_t)HAL_ADC_GetValue(&AdcHandle); + HAL_ADC_Stop(&AdcHandle); + + //This value could be used to actively correct ADC values. + adc_refcor = ((float)(*VREFIN_CAL)) / ((float)value); + + return adc_refcor * 3.3f; } uint32_t common_hal_mcu_processor_get_frequency(void) { diff --git a/ports/stm32f4/mphalport.c b/ports/stm32f4/mphalport.c index f78e9c7501..47ff493e2d 100644 --- a/ports/stm32f4/mphalport.c +++ b/ports/stm32f4/mphalport.c @@ -31,18 +31,15 @@ #include "py/mpstate.h" #include "py/gc.h" +#include "shared-bindings/microcontroller/__init__.h" #include "supervisor/shared/tick.h" +#include "stm32f4xx_hal.h" -/*------------------------------------------------------------------*/ -/* delay - *------------------------------------------------------------------*/ void mp_hal_delay_ms(mp_uint_t delay) { uint64_t start_tick = supervisor_ticks_ms64(); uint64_t duration = 0; while (duration < delay) { - #ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP - #endif + RUN_BACKGROUND_TASKS; // Check to see if we've been CTRL-Ced by autoreload or the user. if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) || MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { @@ -52,3 +49,15 @@ void mp_hal_delay_ms(mp_uint_t delay) { // TODO(tannewt): Go to sleep for a little while while we wait. } } + +void mp_hal_delay_us(mp_uint_t delay) { + common_hal_mcu_delay_us(); +} + +void mp_hal_disable_all_interrupts(void) { + common_hal_mcu_disable_interrupts(); +} + +void mp_hal_enable_all_interrupts(void) { + common_hal_mcu_enable_interrupts(); +} diff --git a/ports/stm32f4/mphalport.h b/ports/stm32f4/mphalport.h index df2f0ca65a..b392cb0f84 100644 --- a/ports/stm32f4/mphalport.h +++ b/ports/stm32f4/mphalport.h @@ -24,20 +24,28 @@ * THE SOFTWARE. */ -#ifndef __STM32F4_HAL -#define __STM32F4_HAL +#ifndef MICROPY_INCLUDED_STM32F4_MPHALPORT_H +#define MICROPY_INCLUDED_STM32F4_MPHALPORT_H -#include -#include +#include "py/obj.h" + +#include "lib/oofatfs/ff.h" -#include "lib/utils/interrupt_char.h" -#include "py/mpconfig.h" #include "supervisor/shared/tick.h" +// Global millisecond tick count (driven by SysTick interrupt). +static inline mp_uint_t mp_hal_ticks_ms(void) { + return supervisor_ticks_ms32(); +} +// Number of bytes in receive buffer +volatile uint8_t usb_rx_count; +volatile bool mp_cdc_enabled; -#define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32()) -//#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us)) +int receive_usb(void); -bool mp_hal_stdin_any(void); +void mp_hal_set_interrupt_char(int c); -#endif +void mp_hal_disable_all_interrupts(void); +void mp_hal_enable_all_interrupts(void); + +#endif // MICROPY_INCLUDED_STM32F4_MPHALPORT_H From 788464a59499c89959fbaae515070e1a34b5f255 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 5 Feb 2020 15:45:27 -0500 Subject: [PATCH 437/531] board uses VBUS --- ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h index 70f89d7e83..c51fa2e044 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h @@ -32,6 +32,4 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) -#define BOARD_NO_VBUS_SENSE - #define BOARD_OSC_DIV 8 From f3188669e4f5c839b0cf8c49f21edd3b2a2a7d57 Mon Sep 17 00:00:00 2001 From: neubauek Date: Wed, 5 Feb 2020 14:52:47 -0600 Subject: [PATCH 438/531] Added CircuitBrains Basic and Deluxe Boards --- .../boards/circuitbrains_basic_m0/board.c | 40 ++++++++++++++ .../circuitbrains_basic_m0/mpconfigboard.h | 41 ++++++++++++++ .../circuitbrains_basic_m0/mpconfigboard.mk | 17 ++++++ .../boards/circuitbrains_basic_m0/pins.c | 35 ++++++++++++ .../boards/circuitbrains_deluxe_m4/board.c | 40 ++++++++++++++ .../circuitbrains_deluxe_m4/mpconfigboard.h | 38 +++++++++++++ .../circuitbrains_deluxe_m4/mpconfigboard.mk | 17 ++++++ .../boards/circuitbrains_deluxe_m4/pins.c | 55 +++++++++++++++++++ 8 files changed, 283 insertions(+) create mode 100755 ports/atmel-samd/boards/circuitbrains_basic_m0/board.c create mode 100755 ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h create mode 100755 ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk create mode 100755 ports/atmel-samd/boards/circuitbrains_basic_m0/pins.c create mode 100755 ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c create mode 100755 ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h create mode 100755 ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk create mode 100755 ports/atmel-samd/boards/circuitbrains_deluxe_m4/pins.c diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c b/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c new file mode 100755 index 0000000000..efafd152db --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Original work copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Modified work copyright (c) 2019 Kevin Neubauer for Null Byte Labs LLC + * + * 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 "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h new file mode 100755 index 0000000000..e58dfa2fd3 --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h @@ -0,0 +1,41 @@ +#define MICROPY_HW_BOARD_NAME "CircuitBrains Basic" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define CIRCUITPY_MCU_FAMILY samd21 + +#define MICROPY_HW_LED_STATUS (&pin_PA14) + +#define SPI_FLASH_BAUDRATE (8000000) + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PA16 +#define SPI_FLASH_MISO_PIN &pin_PA18 +#define SPI_FLASH_SCK_PIN &pin_PA17 +#define SPI_FLASH_CS_PIN &pin_PA19 + +// These are pins not to reset. +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code. +#define CIRCUITPY_INTERNAL_NVM_SIZE 256 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define CALIBRATE_CRYSTALLESS 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PA05) +#define DEFAULT_I2C_BUS_SDA (&pin_PA04) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA11) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA10) +#define DEFAULT_SPI_BUS_MISO (&pin_PA09) + +#define DEFAULT_UART_BUS_RX (&pin_PA07) +#define DEFAULT_UART_BUS_TX (&pin_PA06) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 \ No newline at end of file diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk new file mode 100755 index 0000000000..0e75efd082 --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk @@ -0,0 +1,17 @@ +LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld +USB_VID = 0x04D8 +USB_PID = 0xEC63 +USB_PRODUCT = "CircuitBrains Basic" +USB_MANUFACTURER = "Kevin Neubauer" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = "W25Q32JV_IQ" +LONGINT_IMPL = MPZ + +CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CSLAVE = 0 \ No newline at end of file diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/pins.c b/ports/atmel-samd/boards/circuitbrains_basic_m0/pins.c new file mode 100755 index 0000000000..5acad5e988 --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/pins.c @@ -0,0 +1,35 @@ +#include "shared-bindings/board/__init__.h" + +// This mapping only includes functional names because pins broken +// out on connectors are labeled with their MCU name available from +// microcontroller.pin. +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA08) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA01) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA28) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA27) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_STATUS_LED),MP_ROM_PTR(&pin_PA14) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_PA04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_PA05) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK),MP_ROM_PTR(&pin_PA11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI),MP_ROM_PTR(&pin_PA10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO),MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c new file mode 100755 index 0000000000..efafd152db --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Original work copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Modified work copyright (c) 2019 Kevin Neubauer for Null Byte Labs LLC + * + * 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 "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h new file mode 100755 index 0000000000..6a9dc8ebe9 --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h @@ -0,0 +1,38 @@ +#define MICROPY_HW_BOARD_NAME "CircuitBrains Deluxe" +#define MICROPY_HW_MCU_NAME "samd51j19" + +#define CIRCUITPY_MCU_FAMILY samd51 + +#define MICROPY_HW_LED_STATUS (&pin_PB13) + +// These are pins not to reset. +// QSPI Data pins +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +// QSPI CS, QSPI SCK +#define MICROPY_PORT_B (PORT_PB10 | PORT_PB11) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +#define AUTORESET_DELAY_MS 500 + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB03) +#define DEFAULT_I2C_BUS_SDA (&pin_PB02) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA12) +#define DEFAULT_SPI_BUS_MISO (&pin_PA14) + +#define DEFAULT_UART_BUS_RX (&pin_PA23) +#define DEFAULT_UART_BUS_TX (&pin_PA22) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 \ No newline at end of file diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk new file mode 100755 index 0000000000..2dcfed1f67 --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk @@ -0,0 +1,17 @@ +LD_FILE = boards/samd51x19-bootloader-external-flash.ld +USB_VID = 0x04D8 +USB_PID = 0xEC64 +USB_PRODUCT = "CircuitBrains Deluxe" +USB_MANUFACTURER = "Kevin Neubauer" + +CHIP_VARIANT = SAMD51J19A +CHIP_FAMILY = samd51 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 2 +EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, S25FL064L" +LONGINT_IMPL = MPZ + +CIRCUITPY_NETWORK = 1 +MICROPY_PY_WIZNET5K = 5500 +CIRCUITPY_PS2IO = 1 \ No newline at end of file diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/pins.c b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/pins.c new file mode 100755 index 0000000000..45fcd04640 --- /dev/null +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/pins.c @@ -0,0 +1,55 @@ +#include "shared-bindings/board/__init__.h" + +// This mapping only includes functional names because pins broken +// out on connectors are labeled with their MCU name available from +// microcontroller.pin. +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PB07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PB00) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_PB01) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA21) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA20) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PB17) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PB16) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA19) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA18) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA17) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA16) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PB15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PB14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PB13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_STATUS_LED),MP_ROM_PTR(&pin_PB13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PB12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PB31) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_PA27) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_PB23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_PB22) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_PB02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_PB03) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK),MP_ROM_PTR(&pin_PA13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI),MP_ROM_PTR(&pin_PA12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO),MP_ROM_PTR(&pin_PA14) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 9e34483419870148680f8c9782c552715429e4d5 Mon Sep 17 00:00:00 2001 From: neubauek Date: Wed, 5 Feb 2020 15:13:05 -0600 Subject: [PATCH 439/531] Update build.yml --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 369c26a537..2564ac503b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -130,6 +130,8 @@ jobs: - "bast_pro_mini_m0" - "capablerobot_usbhub" - "catwan_usbstick" + - "circuitbrains_basic_m0" + - "circuitbrains_deluxe_m4" - "circuitplayground_bluefruit" - "circuitplayground_express" - "circuitplayground_express_crickit" From e28d244a0d03998f664e7fecec84853dc3249f0e Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 5 Feb 2020 18:03:54 -0500 Subject: [PATCH 440/531] Add espruino pico pinout --- ports/stm32f4/boards/STM32F401_fs.ld | 4 +- ports/stm32f4/boards/STM32F401xd_fs.ld | 107 +++++ ports/stm32f4/boards/espruino_pico/board.c | 39 ++ .../boards/espruino_pico/mpconfigboard.h | 39 ++ .../boards/espruino_pico/mpconfigboard.mk | 16 + ports/stm32f4/boards/espruino_pico/pins.c | 29 ++ .../boards/espruino_pico/stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ 7 files changed, 672 insertions(+), 2 deletions(-) create mode 100644 ports/stm32f4/boards/STM32F401xd_fs.ld create mode 100644 ports/stm32f4/boards/espruino_pico/board.c create mode 100644 ports/stm32f4/boards/espruino_pico/mpconfigboard.h create mode 100644 ports/stm32f4/boards/espruino_pico/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/espruino_pico/pins.c create mode 100644 ports/stm32f4/boards/espruino_pico/stm32f4xx_hal_conf.h diff --git a/ports/stm32f4/boards/STM32F401_fs.ld b/ports/stm32f4/boards/STM32F401_fs.ld index fd30e16228..c42dfcca8c 100644 --- a/ports/stm32f4/boards/STM32F401_fs.ld +++ b/ports/stm32f4/boards/STM32F401_fs.ld @@ -5,10 +5,10 @@ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 384K /* entire flash */ FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ - FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 320K /* sector 4 is 64K, sectors 5,6,7 are 128K */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K } diff --git a/ports/stm32f4/boards/STM32F401xd_fs.ld b/ports/stm32f4/boards/STM32F401xd_fs.ld new file mode 100644 index 0000000000..fd30e16228 --- /dev/null +++ b/ports/stm32f4/boards/STM32F401xd_fs.ld @@ -0,0 +1,107 @@ +/* + GNU linker script for STM32F401 with bootloader (such as the Meowbit) +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ + FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 2K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +ENTRY(Reset_Handler) + +/* define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + + /* This first flash block is 16K annd 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. */ + + . = ALIGN(4); + } >FLASH_ISR + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + /* *(.glue_7) */ /* glue arm to thumb code */ + /* *(.glue_7t) */ /* glue thumb to arm code */ + + . = ALIGN(4); + _etext = .; /* define a global symbol at end of code */ + } >FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ + } >RAM AT> FLASH_TEXT + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + _sbss = .; /* define a global symbol at bss start; used by startup code */ + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ + } >RAM + + /* this is to define the start of the heap, and make sure we have a minimum size */ + .heap : + { + . = ALIGN(4); + . = . + _minimum_heap_size; + . = ALIGN(4); + } >RAM + + /* this just checks there is enough RAM for the stack */ + .stack : + { + . = ALIGN(4); + . = . + _minimum_stack_size; + . = ALIGN(4); + } >RAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/ports/stm32f4/boards/espruino_pico/board.c b/ports/stm32f4/boards/espruino_pico/board.c new file mode 100644 index 0000000000..82b0c506ed --- /dev/null +++ b/ports/stm32f4/boards/espruino_pico/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/espruino_pico/mpconfigboard.h b/ports/stm32f4/boards/espruino_pico/mpconfigboard.h new file mode 100644 index 0000000000..aa179c7931 --- /dev/null +++ b/ports/stm32f4/boards/espruino_pico/mpconfigboard.h @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "Espruino Pico" +#define MICROPY_HW_MCU_NAME "STM32F401xD" + +#define FLASH_SIZE (0x60000) +#define FLASH_PAGE_SIZE (0x4000) + +#define AUTORESET_DELAY_MS 500 +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) + +#define BOARD_OSC_DIV 8 + diff --git a/ports/stm32f4/boards/espruino_pico/mpconfigboard.mk b/ports/stm32f4/boards/espruino_pico/mpconfigboard.mk new file mode 100644 index 0000000000..1db3939112 --- /dev/null +++ b/ports/stm32f4/boards/espruino_pico/mpconfigboard.mk @@ -0,0 +1,16 @@ +USB_VID = 0x239A +USB_PID = 0x805A +USB_PRODUCT = "Espruino Pico" +USB_MANUFACTURER = "Espruino" +USB_DEVICES = "CDC,MSC" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f401xe +MCU_PACKAGE = 48 +CMSIS_MCU = STM32F401xE +LD_FILE = boards/STM32F401xd_fs.ld # use for internal flash + diff --git a/ports/stm32f4/boards/espruino_pico/pins.c b/ports/stm32f4/boards/espruino_pico/pins.c new file mode 100644 index 0000000000..89f618c259 --- /dev/null +++ b/ports/stm32f4/boards/espruino_pico/pins.c @@ -0,0 +1,29 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_B15), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_B14), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_B13), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_B10), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_B1), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) }, + + { MP_ROM_QSTR(MP_QSTR_B3), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_B4), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_B5), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_B6), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_B7), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_B9), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_B8), MP_ROM_PTR(&pin_PB08) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/espruino_pico/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/espruino_pico/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..ab04df3182 --- /dev/null +++ b/ports/stm32f4/boards/espruino_pico/stm32f4xx_hal_conf.h @@ -0,0 +1,440 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)40000) +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From cdd1622350fb8413f2d26977a4bcdfd436233eb9 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 5 Feb 2020 18:12:48 -0500 Subject: [PATCH 441/531] Fix oscillator oversight in clocks.c --- ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h | 2 ++ ports/stm32f4/boards/pyboard_v11/mpconfigboard.h | 1 + ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h | 2 ++ ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c | 3 ++- ports/stm32f4/peripherals/stm32f4/stm32f405xx/clocks.c | 3 ++- ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c | 3 ++- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h index ad9bba7b0a..3ea469383d 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h @@ -34,6 +34,8 @@ #define MICROPY_HW_NEOPIXEL (&pin_PC00) +#define BOARD_OSC_DIV 12 + // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB05) #define SPI_FLASH_MISO_PIN (&pin_PB04) diff --git a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h index 7093442d09..2da2c6da95 100644 --- a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h +++ b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h @@ -32,6 +32,7 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) +#define BOARD_OSC_DIV 12 #define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SDA (&pin_PB07) diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h index 3ab9a55853..b6d28cb127 100644 --- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h @@ -32,5 +32,7 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) +#define BOARD_OSC_DIV 8 + #define DEFAULT_I2C_BUS_SCL (&pin_PB10) #define DEFAULT_I2C_BUS_SDA (&pin_PB09) diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c index 53af29b3b7..53810af263 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c @@ -25,6 +25,7 @@ * THE SOFTWARE. */ #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" void stm32f4_peripherals_clocks_init(void) { //System clock init @@ -44,7 +45,7 @@ void stm32f4_peripherals_clocks_init(void) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 12; + RCC_OscInitStruct.PLL.PLLM = BOARD_OSC_DIV; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLQ = 7; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f405xx/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f405xx/clocks.c index c259f54fa1..2afca64e83 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f405xx/clocks.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f405xx/clocks.c @@ -25,6 +25,7 @@ * THE SOFTWARE. */ #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" void stm32f4_peripherals_clocks_init(void) { //TODO: All parameters must be moved to board level, due to relationship with HSE Osc. @@ -46,7 +47,7 @@ void stm32f4_peripherals_clocks_init(void) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 12; + RCC_OscInitStruct.PLL.PLLM = BOARD_OSC_DIV; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 7; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c index 1070565507..b208f9dfb3 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c @@ -25,6 +25,7 @@ * THE SOFTWARE. */ #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" void stm32f4_peripherals_clocks_init(void) { //System clock init @@ -46,7 +47,7 @@ void stm32f4_peripherals_clocks_init(void) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLM = BOARD_OSC_DIV; RCC_OscInitStruct.PLL.PLLN = 200; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 7; From 72a1bdab30cc93bcef16c6c81cad4eee175531f0 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 5 Feb 2020 15:54:31 -0800 Subject: [PATCH 442/531] Add another error message for extended advertisements at the same time as scan response. The SD can't do it. --- locale/ID.po | 6 +++++- locale/circuitpython.pot | 6 +++++- locale/de_DE.po | 6 +++++- locale/en_US.po | 6 +++++- locale/en_x_pirate.po | 6 +++++- locale/es.po | 6 +++++- locale/fil.po | 6 +++++- locale/fr.po | 6 +++++- locale/it_IT.po | 6 +++++- locale/ko.po | 6 +++++- locale/pl.po | 6 +++++- locale/pt_BR.po | 6 +++++- locale/zh_Latn_pinyin.po | 6 +++++- ports/nrf/common-hal/_bleio/Adapter.c | 4 ++++ 14 files changed, 69 insertions(+), 13 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 02b7376cc5..bcdad29942 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -676,6 +676,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index acd4c3eb0f..6069bdd971 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -665,6 +665,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 435050c8d8..f2d8537f61 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -669,6 +669,10 @@ msgstr "Erwartet eine Adresse" msgid "Expected tuple of length %d, got %d" msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "Kommando nicht gesendet." diff --git a/locale/en_US.po b/locale/en_US.po index 7c44dc02ff..680c535a99 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -665,6 +665,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index e84725f4f1..5ff575cdf8 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -669,6 +669,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/es.po b/locale/es.po index c86a1e1e36..873c4d3e73 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -671,6 +671,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Se esperaba un tuple de %d, se obtuvo %d" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "Fallo enviando comando" diff --git a/locale/fil.po b/locale/fil.po index 27c0accbf7..63feb3316a 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -679,6 +679,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 504cc8a29f..ba1d56211a 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -682,6 +682,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Tuple de longueur %d attendu, obtenu %d" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 65e733c8bc..6bc116f219 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -679,6 +679,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 68df091529..64bd2e9dd4 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -669,6 +669,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 7570a47b59..77357d05d5 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -668,6 +668,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Oczekiwano krotkę długości %d, otrzymano %d" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 772aba0893..e5dde29f47 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -674,6 +674,10 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "Falha ao enviar comando." diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index b7375d48cb..dbe1605b69 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-03 23:41-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -669,6 +669,10 @@ msgstr "Qídài yīgè dìzhǐ" msgid "Expected tuple of length %d, got %d" msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d" +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." msgstr "Fāsòng mìnglìng shībài." diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 4aa8678a3f..09b7c95b9f 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -646,6 +646,10 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool check_data_fit(advertising_data_bufinfo->len, connectable); check_data_fit(scan_response_data_bufinfo->len, connectable); + + if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) { + mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported.")); + } // The advertising data buffers must not move, because the SoftDevice depends on them. // So make them long-lived and reuse them onwards. if (self->advertising_data == NULL) { From 53f7e2be4fae30359b8208c87b7ae71fdf25f421 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 17:58:59 -0800 Subject: [PATCH 443/531] Use mp_instance_cast_to_native_base() throughout --- shared-bindings/eveL/__init__.c | 44 +++++++++++---------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c index 7a549b856c..06b4e0337e 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/eveL/__init__.c @@ -31,8 +31,6 @@ #include "py/runtime.h" #include "py/binary.h" -// #if MICROPY_PY_BUILTINS_EVEL - //| :mod:`eveL` --- low-level BridgeTek EVE bindings //| ================================================ //| @@ -47,30 +45,28 @@ typedef struct _mp_obj_EVEL_t { mp_obj_base_t base; - mp_obj_t writer; mp_obj_t dest[3]; - size_t n; uint8_t buf[512]; } mp_obj_EVEL_t; +STATIC const mp_obj_type_t EVEL_type; + STATIC void _write(mp_obj_EVEL_t *EVEL, mp_obj_t b) { EVEL->dest[2] = b; mp_call_method_n_kw(1, 0, EVEL->dest); } STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { - mp_obj_EVEL_t *EVEL = self; + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); EVEL->n = 0; - mp_printf(&mp_plat_print, "register %p %d\n", EVEL, EVEL->n); mp_load_method(o, MP_QSTR_write, EVEL->dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); STATIC mp_obj_t _flush(mp_obj_t self) { - mp_obj_EVEL_t *EVEL = self; - // mp_printf(&mp_plat_print, "flush %p %d\n", EVEL, EVEL->n); + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); if (EVEL->n != 0) { _write(EVEL, mp_obj_new_bytearray_by_ref(EVEL->n, EVEL->buf)); EVEL->n = 0; @@ -79,19 +75,19 @@ STATIC mp_obj_t _flush(mp_obj_t self) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); -STATIC void *append(mp_obj_EVEL_t *EVEL, size_t m) { - if ((EVEL->n + m) > sizeof(EVEL->buf)) - _flush((mp_obj_t)EVEL); - uint8_t *r = EVEL->buf + EVEL->n; - EVEL->n += m; - return (void*)r; +STATIC void *append(mp_obj_t self, size_t m) { + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); + if ((EVEL->n + m) > sizeof(EVEL->buf)) + _flush((mp_obj_t)EVEL); + uint8_t *r = EVEL->buf + EVEL->n; + EVEL->n += m; + return (void*)r; } STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { - mp_obj_EVEL_t *EVEL = self; + mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); - // mp_printf(&mp_plat_print, "flush %p %d %p\n", EVEL, buffer_info.len, EVEL->writer); if (buffer_info.len <= sizeof(EVEL->buf)) { uint8_t *p = (uint8_t*)append(EVEL, buffer_info.len); // memcpy(p, buffer_info.buf, buffer_info.len); @@ -152,7 +148,6 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { break; } } - mp_printf(&mp_plat_print, "n=%d\n", n); uint32_t *p = (uint32_t*)append(self, sizeof(uint32_t) * (1 + n)); *p++ = 0xffffff00 | mp_obj_get_int_truncated(num); @@ -164,7 +159,6 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { case 'I': case 'i': *p++ = mp_obj_get_int_truncated(*a++); - mp_printf(&mp_plat_print, " %d %08x\n", p[-1]); i += 1; break; case 'H': @@ -201,17 +195,11 @@ STATIC void EVEL_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ STATIC mp_obj_t EVEL_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); mp_obj_EVEL_t *o = m_new_obj(mp_obj_EVEL_t); - mp_printf(&mp_plat_print, "EVEL init\n"); - o->base.type = type; - return o; + mp_printf(&mp_plat_print, "EVEL %p make_new\n", o); + o->base.type = &EVEL_type; + return MP_OBJ_FROM_PTR(o); } -// STATIC void EVEL_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { -// printf("HERE\n"); -// mp_type_type.attr(self_in, attr, dest); -// printf("THERE %p %p\n", dest[0], dest[1]); -// } - STATIC const mp_obj_type_t EVEL_type = { { &mp_type_type }, // Save on qstr's, reuse same as for module @@ -233,5 +221,3 @@ const mp_obj_module_t eveL_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_eveL_globals, }; - -// #endif // MICROPY_PY_BUILTINS_EVEL From a9b34f45dc821ad14c24aec7df6be74138fe4196 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 18:01:25 -0800 Subject: [PATCH 444/531] My name --- shared-bindings/eveL/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/eveL/__init__.c index 06b4e0337e..fa4439cbe2 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/eveL/__init__.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2014 Paul Sokolovsky + * Copyright (c) 2020 James Bowman * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From acef93a25391594111c1ded0614c440e04e23d26 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 18:17:58 -0800 Subject: [PATCH 445/531] Rename eveL to _eve, EVEL to _EVE --- .../boards/metro_m4_express/mpconfigboard.mk | 2 +- .../metro_nrf52840_express/mpconfigboard.mk | 2 +- py/circuitpy_defns.mk | 6 +- py/circuitpy_mpconfig.h | 10 +- py/circuitpy_mpconfig.mk | 6 +- shared-bindings/{eveL => _eve}/__init__.c | 92 +++++++++---------- .../modeveL-gen.h => _eve/mod_eve-gen.h} | 0 7 files changed, 59 insertions(+), 59 deletions(-) rename shared-bindings/{eveL => _eve}/__init__.c (71%) rename shared-bindings/{eveL/modeveL-gen.h => _eve/mod_eve-gen.h} (100%) diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk index d4593f83a5..c2603002cd 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk @@ -11,4 +11,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ -CIRCUITPY_EVEL = 1 +CIRCUITPY__EVE = 1 diff --git a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk index ade77f0765..b972bcbed7 100644 --- a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk +++ b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.mk @@ -9,4 +9,4 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "GD25Q16C" -CIRCUITPY_EVEL = 1 +CIRCUITPY__EVE = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 859d3837b1..e7d49ae248 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -157,8 +157,8 @@ endif ifeq ($(CIRCUITPY_MATH),1) SRC_PATTERNS += math/% endif -ifeq ($(CIRCUITPY_EVEL),1) -SRC_PATTERNS += eveL/% +ifeq ($(CIRCUITPY__EVE),1) +SRC_PATTERNS += _eve/% endif ifeq ($(CIRCUITPY_MICROCONTROLLER),1) SRC_PATTERNS += microcontroller/% @@ -301,7 +301,7 @@ $(filter $(SRC_PATTERNS), \ fontio/Glyph.c \ microcontroller/RunMode.c \ math/__init__.c \ - eveL/__init__.c \ + _eve/__init__.c \ ) SRC_BINDINGS_ENUMS += \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 8b7ac46b04..c1ac2cddb6 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -384,11 +384,11 @@ extern const struct _mp_obj_module_t math_module; #define MATH_MODULE #endif -#if CIRCUITPY_EVEL -extern const struct _mp_obj_module_t eveL_module; -#define EVEL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_eveL), (mp_obj_t)&eveL_module }, +#if CIRCUITPY__EVE +extern const struct _mp_obj_module_t _eve_module; +#define _EVE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__eve), (mp_obj_t)&_eve_module }, #else -#define EVEL_MODULE +#define _EVE_MODULE #endif #if CIRCUITPY_MICROCONTROLLER @@ -624,7 +624,7 @@ extern const struct _mp_obj_module_t ustack_module; I2CSLAVE_MODULE \ JSON_MODULE \ MATH_MODULE \ - EVEL_MODULE \ + _EVE_MODULE \ MICROCONTROLLER_MODULE \ NEOPIXEL_WRITE_MODULE \ NETWORK_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index b72eec7c5b..93e5982d5c 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -174,10 +174,10 @@ CIRCUITPY_MATH = $(CIRCUITPY_ALWAYS_BUILD) endif CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) -ifndef CIRCUITPY_EVEL -CIRCUITPY_EVEL = 0 +ifndef CIRCUITPY__EVE +CIRCUITPY__EVE = 0 endif -CFLAGS += -DCIRCUITPY_EVEL=$(CIRCUITPY_EVEL) +CFLAGS += -DCIRCUITPY__EVE=$(CIRCUITPY__EVE) ifndef CIRCUITPY_MICROCONTROLLER CIRCUITPY_MICROCONTROLLER = $(CIRCUITPY_DEFAULT_BUILD) diff --git a/shared-bindings/eveL/__init__.c b/shared-bindings/_eve/__init__.c similarity index 71% rename from shared-bindings/eveL/__init__.c rename to shared-bindings/_eve/__init__.c index fa4439cbe2..5263fe1274 100644 --- a/shared-bindings/eveL/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -31,72 +31,72 @@ #include "py/runtime.h" #include "py/binary.h" -//| :mod:`eveL` --- low-level BridgeTek EVE bindings +//| :mod:`_eve` --- low-level BridgeTek EVE bindings //| ================================================ //| -//| .. module:: eveL +//| .. module:: _eve //| :synopsis: low-level BridgeTek EVE bindings //| :platform: SAMD21/SAMD51 //| -//| The `eveL` module provides a class EVEL which +//| The `_eve` module provides a class _EVE which //| contains methods for constructing EVE command //| buffers and appending basic graphics commands. //| -typedef struct _mp_obj_EVEL_t { +typedef struct _mp_obj__EVE_t { mp_obj_base_t base; mp_obj_t dest[3]; size_t n; uint8_t buf[512]; -} mp_obj_EVEL_t; +} mp_obj__EVE_t; -STATIC const mp_obj_type_t EVEL_type; +STATIC const mp_obj_type_t _EVE_type; -STATIC void _write(mp_obj_EVEL_t *EVEL, mp_obj_t b) { - EVEL->dest[2] = b; - mp_call_method_n_kw(1, 0, EVEL->dest); +STATIC void _write(mp_obj__EVE_t *_EVE, mp_obj_t b) { + _EVE->dest[2] = b; + mp_call_method_n_kw(1, 0, _EVE->dest); } STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); - EVEL->n = 0; - mp_load_method(o, MP_QSTR_write, EVEL->dest); + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + _EVE->n = 0; + mp_load_method(o, MP_QSTR_write, _EVE->dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); STATIC mp_obj_t _flush(mp_obj_t self) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); - if (EVEL->n != 0) { - _write(EVEL, mp_obj_new_bytearray_by_ref(EVEL->n, EVEL->buf)); - EVEL->n = 0; + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + if (_EVE->n != 0) { + _write(_EVE, mp_obj_new_bytearray_by_ref(_EVE->n, _EVE->buf)); + _EVE->n = 0; } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); STATIC void *append(mp_obj_t self, size_t m) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); - if ((EVEL->n + m) > sizeof(EVEL->buf)) - _flush((mp_obj_t)EVEL); - uint8_t *r = EVEL->buf + EVEL->n; - EVEL->n += m; + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + if ((_EVE->n + m) > sizeof(_EVE->buf)) + _flush((mp_obj_t)_EVE); + uint8_t *r = _EVE->buf + _EVE->n; + _EVE->n += m; return (void*)r; } STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { - mp_obj_EVEL_t *EVEL = mp_instance_cast_to_native_base(self, &EVEL_type); + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); - if (buffer_info.len <= sizeof(EVEL->buf)) { - uint8_t *p = (uint8_t*)append(EVEL, buffer_info.len); + if (buffer_info.len <= sizeof(_EVE->buf)) { + uint8_t *p = (uint8_t*)append(_EVE, buffer_info.len); // memcpy(p, buffer_info.buf, buffer_info.len); uint8_t *s = buffer_info.buf; for (size_t i = 0; i < buffer_info.len; i++) *p++ = *s++; } else { _flush(self); - _write(EVEL, b); + _write(_EVE, b); } return mp_const_none; @@ -105,7 +105,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); #define C4(self, u) (*(uint32_t*)append((self), sizeof(uint32_t)) = (u)) -#include "modeveL-gen.h" +#include "mod_eve-gen.h" // Hand-written functions { @@ -175,7 +175,7 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cmd_obj, 4, 4, _cmd); -STATIC const mp_rom_map_elem_t EVEL_locals_dict_table[] = { +STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_register), MP_ROM_PTR(®ister_obj) }, { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, @@ -184,40 +184,40 @@ STATIC const mp_rom_map_elem_t EVEL_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, ROM_DECLS }; -STATIC MP_DEFINE_CONST_DICT(EVEL_locals_dict, EVEL_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(_EVE_locals_dict, _EVE_locals_dict_table); -STATIC void EVEL_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void _EVE_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)self_in; (void)kind; - mp_printf(print, ""); + mp_printf(print, "<_EVE>"); } -STATIC mp_obj_t EVEL_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); - mp_obj_EVEL_t *o = m_new_obj(mp_obj_EVEL_t); - mp_printf(&mp_plat_print, "EVEL %p make_new\n", o); - o->base.type = &EVEL_type; + mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); + mp_printf(&mp_plat_print, "_EVE %p make_new\n", o); + o->base.type = &_EVE_type; return MP_OBJ_FROM_PTR(o); } -STATIC const mp_obj_type_t EVEL_type = { +STATIC const mp_obj_type_t _EVE_type = { { &mp_type_type }, // Save on qstr's, reuse same as for module - .name = MP_QSTR_EVEL, - .print = EVEL_print, - .make_new = EVEL_make_new, - // .attr = EVEL_attr, - .locals_dict = (void*)&EVEL_locals_dict, + .name = MP_QSTR__EVE, + .print = _EVE_print, + .make_new = _EVE_make_new, + // .attr = _EVE_attr, + .locals_dict = (void*)&_EVE_locals_dict, }; -STATIC const mp_rom_map_elem_t mp_module_eveL_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_eveL) }, - { MP_ROM_QSTR(MP_QSTR_EVEL), MP_OBJ_FROM_PTR(&EVEL_type) }, +STATIC const mp_rom_map_elem_t mp_module__eve_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__eve) }, + { MP_ROM_QSTR(MP_QSTR__EVE), MP_OBJ_FROM_PTR(&_EVE_type) }, }; -STATIC MP_DEFINE_CONST_DICT(mp_module_eveL_globals, mp_module_eveL_globals_table); +STATIC MP_DEFINE_CONST_DICT(mp_module__eve_globals, mp_module__eve_globals_table); -const mp_obj_module_t eveL_module = { +const mp_obj_module_t _eve_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_eveL_globals, + .globals = (mp_obj_dict_t*)&mp_module__eve_globals, }; diff --git a/shared-bindings/eveL/modeveL-gen.h b/shared-bindings/_eve/mod_eve-gen.h similarity index 100% rename from shared-bindings/eveL/modeveL-gen.h rename to shared-bindings/_eve/mod_eve-gen.h From 09a9e365dd7d45db112ace927d9c1d3f9d7ddf1a Mon Sep 17 00:00:00 2001 From: James Bowman Date: Wed, 5 Feb 2020 19:56:29 -0800 Subject: [PATCH 446/531] Fix sphinx exclude for eveL -> _eve rename --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 79af70cbac..4ea4ba4e80 100644 --- a/conf.py +++ b/conf.py @@ -156,7 +156,7 @@ exclude_patterns = ["**/build*", "ports/zephyr", "py", "shared-bindings/util.*", - "shared-bindings/eveL/modeveL-gen.h", + "shared-bindings/_eve/mod_eve-gen.h", "shared-module", "supervisor", "tests", From 698ad745f6f707cf759a617990d186e1a8527b68 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 6 Feb 2020 10:49:03 -0500 Subject: [PATCH 447/531] Fix oscillator issue, add button and LED pins --- ports/stm32f4/boards/espruino_pico/pins.c | 4 ++++ ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c | 3 ++- ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/boards/espruino_pico/pins.c b/ports/stm32f4/boards/espruino_pico/pins.c index 89f618c259..55c0336c54 100644 --- a/ports/stm32f4/boards/espruino_pico/pins.c +++ b/ports/stm32f4/boards/espruino_pico/pins.c @@ -25,5 +25,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, { MP_ROM_QSTR(MP_QSTR_B9), MP_ROM_PTR(&pin_PB09) }, { MP_ROM_QSTR(MP_QSTR_B8), MP_ROM_PTR(&pin_PB08) }, + + { MP_ROM_QSTR(MP_QSTR_BTN), MP_ROM_PTR(&pin_PC13) }, + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PB12) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c index 53af29b3b7..53810af263 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/clocks.c @@ -25,6 +25,7 @@ * THE SOFTWARE. */ #include "stm32f4xx_hal.h" +#include "py/mpconfig.h" void stm32f4_peripherals_clocks_init(void) { //System clock init @@ -44,7 +45,7 @@ void stm32f4_peripherals_clocks_init(void) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 12; + RCC_OscInitStruct.PLL.PLLM = BOARD_OSC_DIV; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLQ = 7; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c index 28afee5d8e..7bd6196627 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f401xe/gpio.c @@ -38,7 +38,6 @@ void stm32f4_peripherals_gpio_init(void) { __HAL_RCC_GPIOH_CLK_ENABLE(); //Never reset pins - never_reset_pin_number(2,13); //PC13 anti tamp never_reset_pin_number(2,14); //PC14 OSC32_IN never_reset_pin_number(2,15); //PC15 OSC32_OUT never_reset_pin_number(0,13); //PA13 SWDIO From 08cf152aa82eb3b982088b0f4cba10cf1bd70b0a Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 6 Feb 2020 11:11:51 -0500 Subject: [PATCH 448/531] Document flashing process --- ports/stm32f4/boards/espruino_pico/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ports/stm32f4/boards/espruino_pico/README.md diff --git a/ports/stm32f4/boards/espruino_pico/README.md b/ports/stm32f4/boards/espruino_pico/README.md new file mode 100644 index 0000000000..69225721ec --- /dev/null +++ b/ports/stm32f4/boards/espruino_pico/README.md @@ -0,0 +1,15 @@ +# Flashing the Espruino Pico + +The Espruino Pico is normally updated via a bootloader activated by the Espruino web app. This approach is not practical for Circuitpython as it takes too much space from the internal filesystem - thus, you will need to follow the instructions for advanced reflashing using the built-in ROM bootloader on all STM32F4 MCUs (instructions sourced from https://www.espruino.com/Pico#advanced-reflashing) + + - Short out the BOOT0/BTN solder jumper on the back of the board - you can do this by drawing over it with a pencil. + - Install ST's DFU utility on Windows, or dfu-util for Mac or Linux + - **Mac**: install Homebrew: `brew install dfu-util` + - **Linux**: install with apt-get: `sudo apt-get install dfu-util` + - **Windows**: download [ST's application](https://www.st.com/en/development-tools/stsw-stm32080.html) or install the Linux subsystem for Windows 10 and follow the linux instructions. + - Hold down the Pico's button while plugging it into USB (when overwriting Espruino's default firmware) + - Navigate to the same directory as your firmware.bin file for Circuitpython and run the following command: `sudo dfu-util -a 0 -s 0x08000000 -D firmware.bin` or use the ST utility on Windows. + - Restart the board. + + +To reinstall Espruino, follow the same steps with the latest Espruino Pico binary from espruino.com/binaries. This will reinstall the usual Espruino bootloader. You must un-short the BOOT0/BTN jumper to re-use the original Espruino Bootloader again. If you used a Pencil mark then you may need to use cleaning fluid and a small brush to totally clear out the graphite. \ No newline at end of file From 383854ac5076efa90a6ac3b3312de3858a580ecf Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 6 Feb 2020 11:25:07 -0500 Subject: [PATCH 449/531] Add espruino pico to board list --- .github/workflows/build.yml | 1 + ports/stm32f4/boards/espruino_pico/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 369c26a537..fa9a6f7e0f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,6 +144,7 @@ jobs: - "electronut_labs_blip" - "electronut_labs_papyr" - "escornabot_makech" + - "espruino_pico" - "feather_bluefruit_sense" - "feather_m0_adalogger" - "feather_m0_basic" diff --git a/ports/stm32f4/boards/espruino_pico/README.md b/ports/stm32f4/boards/espruino_pico/README.md index 69225721ec..9f0321c474 100644 --- a/ports/stm32f4/boards/espruino_pico/README.md +++ b/ports/stm32f4/boards/espruino_pico/README.md @@ -4,7 +4,7 @@ The Espruino Pico is normally updated via a bootloader activated by the Espruino - Short out the BOOT0/BTN solder jumper on the back of the board - you can do this by drawing over it with a pencil. - Install ST's DFU utility on Windows, or dfu-util for Mac or Linux - - **Mac**: install Homebrew: `brew install dfu-util` + - **Mac**: install with Homebrew: `brew install dfu-util` - **Linux**: install with apt-get: `sudo apt-get install dfu-util` - **Windows**: download [ST's application](https://www.st.com/en/development-tools/stsw-stm32080.html) or install the Linux subsystem for Windows 10 and follow the linux instructions. - Hold down the Pico's button while plugging it into USB (when overwriting Espruino's default firmware) From a20490c0b3f17355765f22cd6b102d27824d33ec Mon Sep 17 00:00:00 2001 From: James Bowman Date: Thu, 6 Feb 2020 08:49:07 -0800 Subject: [PATCH 450/531] Add method VertexFormat() and variable fixed-point scaling in Vertex2f() --- shared-bindings/_eve/__init__.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 5263fe1274..8d36118da2 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -45,9 +45,10 @@ typedef struct _mp_obj__EVE_t { mp_obj_base_t base; - mp_obj_t dest[3]; - size_t n; - uint8_t buf[512]; + mp_obj_t dest[3]; // Own 'write' method, plus argument + int vscale; // fixed-point scaling used for Vertex2f + size_t n; // Current size of command buffer + uint8_t buf[512]; // Command buffer } mp_obj__EVE_t; STATIC const mp_obj_type_t _EVE_type; @@ -59,7 +60,6 @@ STATIC void _write(mp_obj__EVE_t *_EVE, mp_obj_t b) { STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - _EVE->n = 0; mp_load_method(o, MP_QSTR_write, _EVE->dest); return mp_const_none; } @@ -115,14 +115,24 @@ STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); -STATIC mp_obj_t _vertex2f(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - int16_t x = (int16_t)(16 * mp_obj_get_float(a0)); - int16_t y = (int16_t)(16 * mp_obj_get_float(a1)); +STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + int16_t x = (int16_t)(_EVE->vscale * mp_obj_get_float(a0)); + int16_t y = (int16_t)(_EVE->vscale * mp_obj_get_float(a1)); C4(self, (0x40000000 | ((x & 32767) << 15) | (y & 32767))); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); +STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { + mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); + uint32_t frac = mp_obj_get_int_truncated(a0); + C4(self, ((0x27 << 24) | (frac & 3))); + _EVE->vscale = 1 << frac; + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); + STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; mp_obj_t num = args[1]; @@ -180,6 +190,7 @@ STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2f), MP_ROM_PTR(&vertex2f_obj) }, + { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd), MP_ROM_PTR(&cmd_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, ROM_DECLS @@ -197,6 +208,8 @@ STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); mp_printf(&mp_plat_print, "_EVE %p make_new\n", o); o->base.type = &_EVE_type; + o->n = 0; + o->vscale = 16; return MP_OBJ_FROM_PTR(o); } From 4122f858887c1757e95690e11cb2cc440abee793 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 6 Feb 2020 12:19:19 -0500 Subject: [PATCH 451/531] Create board definitions, add to board list --- .github/workflows/build.yml | 1 + ports/stm32f4/boards/espruino_wifi/README.MD | 15 + ports/stm32f4/boards/espruino_wifi/board.c | 38 ++ .../boards/espruino_wifi/mpconfigboard.h | 36 ++ .../boards/espruino_wifi/mpconfigboard.mk | 16 + ports/stm32f4/boards/espruino_wifi/pins.c | 39 ++ .../boards/espruino_wifi/stm32f4xx_hal_conf.h | 439 ++++++++++++++++++ .../peripherals/stm32f4/stm32f411xe/gpio.c | 4 + 8 files changed, 588 insertions(+) create mode 100644 ports/stm32f4/boards/espruino_wifi/README.MD create mode 100644 ports/stm32f4/boards/espruino_wifi/board.c create mode 100644 ports/stm32f4/boards/espruino_wifi/mpconfigboard.h create mode 100644 ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk create mode 100644 ports/stm32f4/boards/espruino_wifi/pins.c create mode 100644 ports/stm32f4/boards/espruino_wifi/stm32f4xx_hal_conf.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 369c26a537..6398793a93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,6 +144,7 @@ jobs: - "electronut_labs_blip" - "electronut_labs_papyr" - "escornabot_makech" + - "espruino_wifi" - "feather_bluefruit_sense" - "feather_m0_adalogger" - "feather_m0_basic" diff --git a/ports/stm32f4/boards/espruino_wifi/README.MD b/ports/stm32f4/boards/espruino_wifi/README.MD new file mode 100644 index 0000000000..8c2cd3be2b --- /dev/null +++ b/ports/stm32f4/boards/espruino_wifi/README.MD @@ -0,0 +1,15 @@ +# Flashing the Espruino Wifi + +The Espruino Wifi is normally updated via a bootloader activated by the Espruino web app. This approach is not practical for Circuitpython as it takes too much space from the internal filesystem - thus, you will need to follow the instructions for advanced reflashing using the built-in ROM bootloader on all STM32F4 MCUs (instructions sourced from https://www.espruino.com/Wifi#advanced-reflashing) + + - Short out the BOOT0/BTN solder jumper on the back of the board - you can do this by drawing over it with a pencil. + - Install ST's DFU utility on Windows, or dfu-util for Mac or Linux + - **Mac**: install with Homebrew: `brew install dfu-util` + - **Linux**: install with apt-get: `sudo apt-get install dfu-util` + - **Windows**: download [ST's application](https://www.st.com/en/development-tools/stsw-stm32080.html) or install the Linux subsystem for Windows 10 and follow the linux instructions. + - Hold down the Wifi's button while plugging it into USB (when overwriting Espruino's default firmware) + - Navigate to the same directory as your firmware.bin file for Circuitpython and run the following command: `sudo dfu-util -a 0 -s 0x08000000 -D firmware.bin` or use the ST utility on Windows. + - Restart the board. + + +To reinstall Espruino, follow the same steps with the latest Espruino Wifi binary from espruino.com/binaries. This will reinstall the usual Espruino bootloader. You must un-short the BOOT0/BTN jumper to re-use the original Espruino Bootloader again. If you used a Pencil mark then you may need to use cleaning fluid and a small brush to totally clear out the graphite. \ No newline at end of file diff --git a/ports/stm32f4/boards/espruino_wifi/board.c b/ports/stm32f4/boards/espruino_wifi/board.c new file mode 100644 index 0000000000..4421970eef --- /dev/null +++ b/ports/stm32f4/boards/espruino_wifi/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/stm32f4/boards/espruino_wifi/mpconfigboard.h b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.h new file mode 100644 index 0000000000..611a41d93b --- /dev/null +++ b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.h @@ -0,0 +1,36 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Lucian Copeland 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 "Espruino Wifi" +#define MICROPY_HW_MCU_NAME "STM32F411xE" + +#define FLASH_SIZE (0x80000) //512K +#define FLASH_PAGE_SIZE (0x4000) //16K + +#define BOARD_OSC_DIV 8 +#define BOARD_OVERWRITE_SWD diff --git a/ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk new file mode 100644 index 0000000000..9dbb097c03 --- /dev/null +++ b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk @@ -0,0 +1,16 @@ +USB_VID = 0x239A +USB_PID = 0x805E +USB_PRODUCT = "Espruino Wifi" +USB_MANUFACTURER = "Espruino" +USB_DEVICES = "CDC,MSC" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +MCU_SERIES = m4 +MCU_VARIANT = stm32f4 +MCU_SUB_VARIANT = stm32f411xe +MCU_PACKAGE = 48 +CMSIS_MCU = STM32F411xE +LD_FILE = boards/STM32F411VETx_FLASH.ld + diff --git a/ports/stm32f4/boards/espruino_wifi/pins.c b/ports/stm32f4/boards/espruino_wifi/pins.c new file mode 100644 index 0000000000..8800317d50 --- /dev/null +++ b/ports/stm32f4/boards/espruino_wifi/pins.c @@ -0,0 +1,39 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + //P1 + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_B1), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_B10), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_B13), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_B14), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_B15), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_B0), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_B9), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_B8), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_B7), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_B6), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_B5), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_B4), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_B3), MP_ROM_PTR(&pin_PB03) }, + + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_BTN), MP_ROM_PTR(&pin_PC13) }, + + { MP_ROM_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_ESP_GPIO0), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_ESP_CHPD), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_ESP_GPIO13), MP_ROM_PTR(&pin_PA15) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm32f4/boards/espruino_wifi/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/espruino_wifi/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..18d9d60ebe --- /dev/null +++ b/ports/stm32f4/boards/espruino_wifi/stm32f4xx_hal_conf.h @@ -0,0 +1,439 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +/* #define HAL_SAI_MODULE_ENABLED */ +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c index 651aea2691..77888c4657 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c @@ -26,6 +26,7 @@ #include "stm32f4xx_hal.h" #include "stm32f4/gpio.h" +#include "py/mpconfig.h" #include "common-hal/microcontroller/Pin.h" void stm32f4_peripherals_gpio_init(void) { @@ -40,8 +41,11 @@ void stm32f4_peripherals_gpio_init(void) { //Never reset pins never_reset_pin_number(2,14); //PC14 OSC32_IN never_reset_pin_number(2,15); //PC15 OSC32_OUT + + #if !defined(BOARD_OVERWRITE_SWD) never_reset_pin_number(0,13); //PA13 SWDIO never_reset_pin_number(0,14); //PA14 SWCLK + #endif // Port H is not included in GPIO port array // never_reset_pin_number(5,0); //PH0 JTDO From aee26b1c79e23b723b73857b31a77a3431956ab4 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 6 Feb 2020 12:25:17 -0500 Subject: [PATCH 452/531] Add proper PID --- ports/stm32f4/boards/espruino_pico/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm32f4/boards/espruino_pico/mpconfigboard.mk b/ports/stm32f4/boards/espruino_pico/mpconfigboard.mk index 1db3939112..151ca1437a 100644 --- a/ports/stm32f4/boards/espruino_pico/mpconfigboard.mk +++ b/ports/stm32f4/boards/espruino_pico/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x805A +USB_PID = 0x808E USB_PRODUCT = "Espruino Pico" USB_MANUFACTURER = "Espruino" USB_DEVICES = "CDC,MSC" From 848577e830b10ff226900f978a5fdd39089c8dc0 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 6 Feb 2020 12:55:36 -0500 Subject: [PATCH 453/531] Update PID --- ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk index 9dbb097c03..8b28cf07c7 100644 --- a/ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk +++ b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x805E +USB_PID = 0x8090 USB_PRODUCT = "Espruino Wifi" USB_MANUFACTURER = "Espruino" USB_DEVICES = "CDC,MSC" From d93d491a611f2d987c818909810d30314762c3b6 Mon Sep 17 00:00:00 2001 From: neubauek Date: Thu, 6 Feb 2020 14:47:22 -0600 Subject: [PATCH 454/531] Cleaned up CircuitBrains Basic and Deluxe board definitions --- .../boards/circuitbrains_basic_m0/mpconfigboard.h | 8 +------- .../boards/circuitbrains_basic_m0/mpconfigboard.mk | 3 +-- .../boards/circuitbrains_deluxe_m4/mpconfigboard.h | 8 +------- .../boards/circuitbrains_deluxe_m4/mpconfigboard.mk | 3 +-- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h index e58dfa2fd3..592160b84f 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.h @@ -5,8 +5,6 @@ #define MICROPY_HW_LED_STATUS (&pin_PA14) -#define SPI_FLASH_BAUDRATE (8000000) - // On-board flash #define SPI_FLASH_MOSI_PIN &pin_PA16 #define SPI_FLASH_MISO_PIN &pin_PA18 @@ -18,11 +16,7 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code. -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE) +#define SPI_FLASH_BAUDRATE (8000000) #define CALIBRATE_CRYSTALLESS 1 diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk index 0e75efd082..3587f1a33b 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x04D8 USB_PID = 0xEC63 USB_PRODUCT = "CircuitBrains Basic" @@ -14,4 +13,4 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CSLAVE = 0 \ No newline at end of file +CIRCUITPY_I2CSLAVE = 0 diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h index 6a9dc8ebe9..687e97a5a3 100755 --- a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h @@ -15,12 +15,6 @@ #define AUTORESET_DELAY_MS 500 -// If you change this, then make sure to update the linker scripts as well to -// make sure you don't overwrite code -#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) @@ -35,4 +29,4 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 -#define IGNORE_PIN_PA25 1 \ No newline at end of file +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk index 2dcfed1f67..7a9e5a7808 100755 --- a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk @@ -1,4 +1,3 @@ -LD_FILE = boards/samd51x19-bootloader-external-flash.ld USB_VID = 0x04D8 USB_PID = 0xEC64 USB_PRODUCT = "CircuitBrains Deluxe" @@ -14,4 +13,4 @@ LONGINT_IMPL = MPZ CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 -CIRCUITPY_PS2IO = 1 \ No newline at end of file +CIRCUITPY_PS2IO = 1 From 789e311b63688d7dd49d1963bf736e9dbf2cf690 Mon Sep 17 00:00:00 2001 From: Lady Ada Date: Thu, 6 Feb 2020 16:28:02 -0500 Subject: [PATCH 455/531] update rotation so 0 is the default, for much faster ondiskbitmaps --- ports/atmel-samd/boards/pybadge/board.c | 4 ++-- ports/atmel-samd/boards/pygamer/board.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index 3725f0ec34..28e1aec131 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -52,7 +52,7 @@ uint8_t display_init_sequence[] = { 0xc4, 2, 0x8a, 0xee, 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x2a, 0, // _INVOFF - 0x36, 1, 0x00, // _MADCTL top to bottom refresh in vsync aligned order. + 0x36, 1, 0b10100000, // _MADCTL for rotation 0 // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color @@ -92,7 +92,7 @@ void board_init(void) { 128, // Height (after rotation) 0, // column start 0, // row start - 270, // rotation + 0, // rotation 16, // Color depth false, // grayscale false, // pixels in byte share row. only used for depth < 8 diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index b364ffccff..c052614dbb 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[] = { 0xc4, 2, 0x8a, 0xee, 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x2a, 0, // _INVOFF - 0x36, 1, 0x00, // _MADCTL top to bottom refresh in vsync aligned order. + 0x36, 1, 0b10100000, // _MADCTL for rotation 0 // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color @@ -92,7 +92,7 @@ void board_init(void) { 128, // Height 0, // column start 0, // row start - 270, // rotation + 0, // rotation 16, // Color depth false, // Grayscale false, // pixels in a byte share a row. Only valid for depths < 8 From 41b5f737850d77fc56f9272159dc7765f5942968 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Thu, 6 Feb 2020 18:47:06 -0500 Subject: [PATCH 456/531] revert mixed up linkers --- ports/stm32f4/boards/STM32F401xd_fs.ld | 4 ++-- .../stm32f4/boards/{STM32F401_boot.ld => STM32F401xe_boot.ld} | 0 ports/stm32f4/boards/{STM32F401_fs.ld => STM32F401xe_fs.ld} | 4 ++-- ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename ports/stm32f4/boards/{STM32F401_boot.ld => STM32F401xe_boot.ld} (100%) rename ports/stm32f4/boards/{STM32F401_fs.ld => STM32F401xe_fs.ld} (96%) diff --git a/ports/stm32f4/boards/STM32F401xd_fs.ld b/ports/stm32f4/boards/STM32F401xd_fs.ld index fd30e16228..c42dfcca8c 100644 --- a/ports/stm32f4/boards/STM32F401xd_fs.ld +++ b/ports/stm32f4/boards/STM32F401xd_fs.ld @@ -5,10 +5,10 @@ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 384K /* entire flash */ FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ - FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 320K /* sector 4 is 64K, sectors 5,6,7 are 128K */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K } diff --git a/ports/stm32f4/boards/STM32F401_boot.ld b/ports/stm32f4/boards/STM32F401xe_boot.ld similarity index 100% rename from ports/stm32f4/boards/STM32F401_boot.ld rename to ports/stm32f4/boards/STM32F401xe_boot.ld diff --git a/ports/stm32f4/boards/STM32F401_fs.ld b/ports/stm32f4/boards/STM32F401xe_fs.ld similarity index 96% rename from ports/stm32f4/boards/STM32F401_fs.ld rename to ports/stm32f4/boards/STM32F401xe_fs.ld index c42dfcca8c..fd30e16228 100644 --- a/ports/stm32f4/boards/STM32F401_fs.ld +++ b/ports/stm32f4/boards/STM32F401xe_fs.ld @@ -5,10 +5,10 @@ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 384K /* entire flash */ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ - FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 320K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K } diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk index dce69276d2..16268ba119 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk @@ -19,6 +19,6 @@ MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f401xe MCU_PACKAGE = 64 CMSIS_MCU = STM32F401xE -LD_FILE = boards/STM32F401_boot.ld -# LD_FILE = boards/STM32F401_fs.ld # use for internal flash +LD_FILE = boards/STM32F401xe_boot.ld +# LD_FILE = boards/STM32F401xe_fs.ld # use for internal flash From 76d8e5b39966adb2a5c17dc0a8be9cd44e7957a9 Mon Sep 17 00:00:00 2001 From: Langston Nashold Date: Wed, 5 Feb 2020 21:53:55 -0800 Subject: [PATCH 457/531] Add support for external flash device Winbond.com W25Q80DV Currently, we only support external flash device W25Q80DL. This adds support for the W25Q80DL. tweak --- supervisor/shared/external_flash/devices.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/supervisor/shared/external_flash/devices.h b/supervisor/shared/external_flash/devices.h index 08d0a78fdd..55a52b40d3 100644 --- a/supervisor/shared/external_flash/devices.h +++ b/supervisor/shared/external_flash/devices.h @@ -371,6 +371,23 @@ typedef struct { .single_status_byte = false, \ } +// Settings for the Winbond W25Q80DV 1MiB SPI flash.. Note that W25Q80DL has a different memory type (0x60) +// Datasheet: https://www.winbond.com/resource-files/w25q80dv%20dl_revh_10022015.pdf +#define W25Q80DV {\ + .total_size = (1 << 20), /* 1 MiB */ \ + .start_up_time_us = 5000, \ + .manufacturer_id = 0xef, \ + .memory_type = 0x40, \ + .capacity = 0x14, \ + .max_clock_speed_mhz = 104, \ + .quad_enable_bit_mask = 0x02, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = true, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} // Settings for the Winbond W25Q128JV-SQ 16MiB SPI flash. Note that JV-IM has a different .memory_type (0x70) // Datasheet: https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf From 857d8ab40a6e4ef7d0cc78f481511070c1af15e3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 7 Feb 2020 10:02:50 -0500 Subject: [PATCH 458/531] improve time.monotonic_ns() accuracy from ms to us --- locale/circuitpython.pot | 2 +- ports/atmel-samd/common-hal/time/__init__.c | 9 +++++++++ ports/cxd56/common-hal/time/__init__.c | 8 ++++++++ ports/mimxrt10xx/common-hal/time/__init__.c | 10 ++++++++++ ports/nrf/common-hal/time/__init__.c | 8 ++++++++ ports/stm32f4/common-hal/time/__init__.c | 8 ++++++++ shared-bindings/time/__init__.c | 2 +- shared-bindings/time/__init__.h | 1 + 8 files changed, 46 insertions(+), 2 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 6069bdd971..3e44130688 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-07 10:02-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/ports/atmel-samd/common-hal/time/__init__.c b/ports/atmel-samd/common-hal/time/__init__.c index 2d82b3d1ad..1499964527 100644 --- a/ports/atmel-samd/common-hal/time/__init__.c +++ b/ports/atmel-samd/common-hal/time/__init__.c @@ -29,11 +29,20 @@ #include "shared-bindings/time/__init__.h" #include "supervisor/shared/tick.h" +#include "tick.h" inline uint64_t common_hal_time_monotonic() { return supervisor_ticks_ms64(); } +uint64_t common_hal_time_monotonic_ns() { + uint64_t ms; + uint32_t us_until_ms; + current_tick(&ms, &us_until_ms); + // us counts down. + return 1000 * (ms * 1000 + (1000 - us_until_ms)); +} + void common_hal_time_delay_ms(uint32_t delay) { mp_hal_delay_ms(delay); } diff --git a/ports/cxd56/common-hal/time/__init__.c b/ports/cxd56/common-hal/time/__init__.c index 6f5eedd419..fa915782df 100644 --- a/ports/cxd56/common-hal/time/__init__.c +++ b/ports/cxd56/common-hal/time/__init__.c @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +#include + #include "py/mphal.h" #include "supervisor/shared/tick.h" @@ -32,6 +34,12 @@ uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } +uint64_t common_hal_time_monotonic_ns() { + struct timeval tv; + gettimeofday(&tv, NULL); + return 1000 * ((uint64_t) tv.tv_sec * 1000000 + (uint64_t) tv.tv_usec); +} + void common_hal_time_delay_ms(uint32_t delay) { mp_hal_delay_ms(delay); } diff --git a/ports/mimxrt10xx/common-hal/time/__init__.c b/ports/mimxrt10xx/common-hal/time/__init__.c index 2d82b3d1ad..4497d8e86c 100644 --- a/ports/mimxrt10xx/common-hal/time/__init__.c +++ b/ports/mimxrt10xx/common-hal/time/__init__.c @@ -30,10 +30,20 @@ #include "supervisor/shared/tick.h" +#include "tick.h" + inline uint64_t common_hal_time_monotonic() { return supervisor_ticks_ms64(); } +uint64_t common_hal_time_monotonic_ns() { + uint64_t ms; + uint32_t us_until_ms; + current_tick(&ms, &us_until_ms); + // us counts down. + return 1000 * (ms * 1000 + (1000 - us_until_ms)); +} + void common_hal_time_delay_ms(uint32_t delay) { mp_hal_delay_ms(delay); } diff --git a/ports/nrf/common-hal/time/__init__.c b/ports/nrf/common-hal/time/__init__.c index 976f519db2..dcfe55eca7 100644 --- a/ports/nrf/common-hal/time/__init__.c +++ b/ports/nrf/common-hal/time/__init__.c @@ -32,6 +32,14 @@ uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } +uint64_t common_hal_time_monotonic_ns() { + uint64_t ms; + uint32_t us_until_ms; + current_tick(&ms, &us_until_ms); + // us counts down. + return 1000 * (ms * 1000 + (1000 - us_until_ms)); +} + void common_hal_time_delay_ms(uint32_t delay) { mp_hal_delay_ms(delay); } diff --git a/ports/stm32f4/common-hal/time/__init__.c b/ports/stm32f4/common-hal/time/__init__.c index 976f519db2..dcfe55eca7 100644 --- a/ports/stm32f4/common-hal/time/__init__.c +++ b/ports/stm32f4/common-hal/time/__init__.c @@ -32,6 +32,14 @@ uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } +uint64_t common_hal_time_monotonic_ns() { + uint64_t ms; + uint32_t us_until_ms; + current_tick(&ms, &us_until_ms); + // us counts down. + return 1000 * (ms * 1000 + (1000 - us_until_ms)); +} + void common_hal_time_delay_ms(uint32_t delay) { mp_hal_delay_ms(delay); } diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index b3e4604b51..2c1aebc2e7 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -216,7 +216,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); //| :rtype: int //| STATIC mp_obj_t time_monotonic_ns(void) { - uint64_t time64 = common_hal_time_monotonic() * 1000000llu; + uint64_t time64 = common_hal_time_monotonic_ns(); return mp_obj_new_int_from_ll((long long) time64); } MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns); diff --git a/shared-bindings/time/__init__.h b/shared-bindings/time/__init__.h index c5a0b47fc1..ec96aea24f 100644 --- a/shared-bindings/time/__init__.h +++ b/shared-bindings/time/__init__.h @@ -36,6 +36,7 @@ extern mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm); extern void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm); extern uint64_t common_hal_time_monotonic(void); +extern uint64_t common_hal_time_monotonic_ns(void); extern void common_hal_time_delay_ms(uint32_t); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_TIME___INIT___H From cbd519bfa6bb3e2f56a07e977c47159059f1fc8d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 7 Feb 2020 10:24:11 -0500 Subject: [PATCH 459/531] time.sleep() rounds to nearest msec --- shared-bindings/time/__init__.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 2c1aebc2e7..8d7f2f3fd2 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -70,14 +70,16 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic); //| STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { #if MICROPY_PY_BUILTINS_FLOAT - float seconds = mp_obj_get_float(seconds_o); + mp_float_t seconds = mp_obj_get_float(seconds_o); + mp_float_t msecs = 1000.0f * seconds + 0.5f; #else - int seconds = mp_obj_get_int(seconds_o); + mp_int_t seconds = mp_obj_get_int(seconds_o); + mp_int_t msecs = 1000 * seconds; #endif if (seconds < 0) { mp_raise_ValueError(translate("sleep length must be non-negative")); } - common_hal_time_delay_ms(1000 * seconds); + common_hal_time_delay_ms(msecs); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep); From 005c4caf8c5c76deab661a1f8bc2ea743ba40c6d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 7 Feb 2020 10:32:37 -0500 Subject: [PATCH 460/531] fix function defs for compiler --- ports/atmel-samd/common-hal/time/__init__.c | 4 ++-- ports/cxd56/common-hal/time/__init__.c | 2 +- ports/mimxrt10xx/common-hal/time/__init__.c | 4 ++-- ports/nrf/common-hal/time/__init__.c | 2 +- ports/stm32f4/common-hal/time/__init__.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ports/atmel-samd/common-hal/time/__init__.c b/ports/atmel-samd/common-hal/time/__init__.c index 1499964527..652e455fc4 100644 --- a/ports/atmel-samd/common-hal/time/__init__.c +++ b/ports/atmel-samd/common-hal/time/__init__.c @@ -31,11 +31,11 @@ #include "supervisor/shared/tick.h" #include "tick.h" -inline uint64_t common_hal_time_monotonic() { +inline uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } -uint64_t common_hal_time_monotonic_ns() { +uint64_t common_hal_time_monotonic_ns(void) { uint64_t ms; uint32_t us_until_ms; current_tick(&ms, &us_until_ms); diff --git a/ports/cxd56/common-hal/time/__init__.c b/ports/cxd56/common-hal/time/__init__.c index fa915782df..31c63cbb29 100644 --- a/ports/cxd56/common-hal/time/__init__.c +++ b/ports/cxd56/common-hal/time/__init__.c @@ -34,7 +34,7 @@ uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } -uint64_t common_hal_time_monotonic_ns() { +uint64_t common_hal_time_monotonic_ns(void) { struct timeval tv; gettimeofday(&tv, NULL); return 1000 * ((uint64_t) tv.tv_sec * 1000000 + (uint64_t) tv.tv_usec); diff --git a/ports/mimxrt10xx/common-hal/time/__init__.c b/ports/mimxrt10xx/common-hal/time/__init__.c index 4497d8e86c..524e31d1ae 100644 --- a/ports/mimxrt10xx/common-hal/time/__init__.c +++ b/ports/mimxrt10xx/common-hal/time/__init__.c @@ -32,11 +32,11 @@ #include "tick.h" -inline uint64_t common_hal_time_monotonic() { +inline uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } -uint64_t common_hal_time_monotonic_ns() { +uint64_t common_hal_time_monotonic_ns(void) { uint64_t ms; uint32_t us_until_ms; current_tick(&ms, &us_until_ms); diff --git a/ports/nrf/common-hal/time/__init__.c b/ports/nrf/common-hal/time/__init__.c index dcfe55eca7..c85077868a 100644 --- a/ports/nrf/common-hal/time/__init__.c +++ b/ports/nrf/common-hal/time/__init__.c @@ -32,7 +32,7 @@ uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } -uint64_t common_hal_time_monotonic_ns() { +uint64_t common_hal_time_monotonic_ns(void) { uint64_t ms; uint32_t us_until_ms; current_tick(&ms, &us_until_ms); diff --git a/ports/stm32f4/common-hal/time/__init__.c b/ports/stm32f4/common-hal/time/__init__.c index dcfe55eca7..c85077868a 100644 --- a/ports/stm32f4/common-hal/time/__init__.c +++ b/ports/stm32f4/common-hal/time/__init__.c @@ -32,7 +32,7 @@ uint64_t common_hal_time_monotonic(void) { return supervisor_ticks_ms64(); } -uint64_t common_hal_time_monotonic_ns() { +uint64_t common_hal_time_monotonic_ns(void) { uint64_t ms; uint32_t us_until_ms; current_tick(&ms, &us_until_ms); From 5c6d94d3e5ac2c4bb8514ac920d59a465300465b Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 7 Feb 2020 10:30:49 -0800 Subject: [PATCH 461/531] Split into shared-module and shared-bindings --- py/circuitpy_defns.mk | 3 +- shared-bindings/_eve/__init__.c | 80 ++----- shared-bindings/_eve/mod_eve-gen.h | 372 +++++++++++++---------------- shared-module/_eve/__init__.c | 270 +++++++++++++++++++++ shared-module/_eve/__init__.h | 91 +++++++ 5 files changed, 557 insertions(+), 259 deletions(-) create mode 100644 shared-module/_eve/__init__.c create mode 100644 shared-module/_eve/__init__.h diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index e7d49ae248..68fa25d8d8 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -363,7 +363,8 @@ SRC_SHARED_MODULE_ALL = \ uheap/__init__.c \ ustack/__init__.c \ _pew/__init__.c \ - _pew/PewPew.c + _pew/PewPew.c \ + _eve/__init__.c # All possible sources are listed here, and are filtered by SRC_PATTERNS. SRC_SHARED_MODULE = $(filter $(SRC_PATTERNS), $(SRC_SHARED_MODULE_ALL)) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 8d36118da2..6f2a39db50 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -31,6 +31,8 @@ #include "py/runtime.h" #include "py/binary.h" +#include "shared-module/_eve/__init__.h" + //| :mod:`_eve` --- low-level BridgeTek EVE bindings //| ================================================ //| @@ -45,94 +47,57 @@ typedef struct _mp_obj__EVE_t { mp_obj_base_t base; - mp_obj_t dest[3]; // Own 'write' method, plus argument - int vscale; // fixed-point scaling used for Vertex2f - size_t n; // Current size of command buffer - uint8_t buf[512]; // Command buffer + common_hal__eve_t _eve; } mp_obj__EVE_t; STATIC const mp_obj_type_t _EVE_type; -STATIC void _write(mp_obj__EVE_t *_EVE, mp_obj_t b) { - _EVE->dest[2] = b; - mp_call_method_n_kw(1, 0, _EVE->dest); -} +#define EVEHAL(s) \ + (&((mp_obj__EVE_t*)mp_instance_cast_to_native_base((s), &_EVE_type))->_eve) STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - mp_load_method(o, MP_QSTR_write, _EVE->dest); + common_hal__eve_t *eve = EVEHAL(self); + mp_load_method(o, MP_QSTR_write, eve->dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); STATIC mp_obj_t _flush(mp_obj_t self) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - if (_EVE->n != 0) { - _write(_EVE, mp_obj_new_bytearray_by_ref(_EVE->n, _EVE->buf)); - _EVE->n = 0; - } + common_hal__eve_flush(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); -STATIC void *append(mp_obj_t self, size_t m) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - if ((_EVE->n + m) > sizeof(_EVE->buf)) - _flush((mp_obj_t)_EVE); - uint8_t *r = _EVE->buf + _EVE->n; - _EVE->n += m; - return (void*)r; -} - STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); - if (buffer_info.len <= sizeof(_EVE->buf)) { - uint8_t *p = (uint8_t*)append(_EVE, buffer_info.len); - // memcpy(p, buffer_info.buf, buffer_info.len); - uint8_t *s = buffer_info.buf; - for (size_t i = 0; i < buffer_info.len; i++) - *p++ = *s++; - } else { - _flush(self); - _write(_EVE, b); - } - + common_hal__eve_add(EVEHAL(self), buffer_info.len, buffer_info.buf); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); -#define C4(self, u) (*(uint32_t*)append((self), sizeof(uint32_t)) = (u)) - #include "mod_eve-gen.h" // Hand-written functions { +#define ADD_X(self, x) \ + common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); + STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { - C4(self, (0xffffff00 | mp_obj_get_int_truncated(n))); + uint32_t code = 0xffffff00 | mp_obj_get_int_truncated(n); + ADD_X(self, code); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - int16_t x = (int16_t)(_EVE->vscale * mp_obj_get_float(a0)); - int16_t y = (int16_t)(_EVE->vscale * mp_obj_get_float(a1)); - C4(self, (0x40000000 | ((x & 32767) << 15) | (y & 32767))); + mp_float_t x = mp_obj_get_float(a0); + mp_float_t y = mp_obj_get_float(a1); + common_hal__eve_Vertex2f(EVEHAL(self), x, y); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); -STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { - mp_obj__EVE_t *_EVE = mp_instance_cast_to_native_base(self, &_EVE_type); - uint32_t frac = mp_obj_get_int_truncated(a0); - C4(self, ((0x27 << 24) | (frac & 3))); - _EVE->vscale = 1 << frac; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); - STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; mp_obj_t num = args[1]; @@ -159,7 +124,8 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { } } - uint32_t *p = (uint32_t*)append(self, sizeof(uint32_t) * (1 + n)); + uint32_t buf[16]; + uint32_t *p = buf; *p++ = 0xffffff00 | mp_obj_get_int_truncated(num); mp_obj_t *a = items; uint32_t lo; @@ -181,6 +147,8 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { break; } } + + common_hal__eve_add(EVEHAL(self), sizeof(uint32_t) * (1 + n), buf); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(cmd_obj, 4, 4, _cmd); @@ -190,7 +158,6 @@ STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_cc), MP_ROM_PTR(&cc_obj) }, { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&flush_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2f), MP_ROM_PTR(&vertex2f_obj) }, - { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd), MP_ROM_PTR(&cmd_obj) }, { MP_ROM_QSTR(MP_QSTR_cmd0), MP_ROM_PTR(&cmd0_obj) }, ROM_DECLS @@ -206,10 +173,9 @@ STATIC void _EVE_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); - mp_printf(&mp_plat_print, "_EVE %p make_new\n", o); o->base.type = &_EVE_type; - o->n = 0; - o->vscale = 16; + o->_eve.n = 0; + o->_eve.vscale = 16; return MP_OBJ_FROM_PTR(o); } diff --git a/shared-bindings/_eve/mod_eve-gen.h b/shared-bindings/_eve/mod_eve-gen.h index 1c8d5ae12a..c5dafb16f0 100644 --- a/shared-bindings/_eve/mod_eve-gen.h +++ b/shared-bindings/_eve/mod_eve-gen.h @@ -1,42 +1,37 @@ -STATIC mp_obj_t _alphafunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t func = mp_obj_get_int_truncated(a0); - uint32_t ref = mp_obj_get_int_truncated(a1); - C4(self, ((9 << 24) | ((func & 7) << 8) | ((ref & 255))) -); +STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t func = mp_obj_get_int_truncated(a0); + uint32_t ref = mp_obj_get_int_truncated(a1); + common_hal__eve_AlphaFunc(EVEHAL(self), func, ref); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); -STATIC mp_obj_t _begin(mp_obj_t self , mp_obj_t a0) { - uint32_t prim = mp_obj_get_int_truncated(a0); - C4(self, ((31 << 24) | ((prim & 15))) -); +STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { + uint32_t prim = mp_obj_get_int_truncated(a0); + common_hal__eve_Begin(EVEHAL(self), prim); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); -STATIC mp_obj_t _bitmapextformat(mp_obj_t self , mp_obj_t a0) { - uint32_t fmt = mp_obj_get_int_truncated(a0); - C4(self, ((46 << 24) | (fmt & 65535)) -); +STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { + uint32_t fmt = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapExtFormat(EVEHAL(self), fmt); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); -STATIC mp_obj_t _bitmaphandle(mp_obj_t self , mp_obj_t a0) { +STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { uint32_t handle = mp_obj_get_int_truncated(a0); - C4(self, ((5 << 24) | ((handle & 31))) -); + common_hal__eve_BitmapHandle(EVEHAL(self), handle); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); -STATIC mp_obj_t _bitmaplayouth(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { +STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t linestride = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); - C4(self, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3))) -); + common_hal__eve_BitmapLayoutH(EVEHAL(self), linestride, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); @@ -45,368 +40,343 @@ STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { uint32_t format = mp_obj_get_int_truncated(args[1]); uint32_t linestride = mp_obj_get_int_truncated(args[2]); uint32_t height = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511))) -); + common_hal__eve_BitmapLayout(EVEHAL(args[0]), format, linestride, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); -STATIC mp_obj_t _bitmapsizeh(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); +STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); - C4(self, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3))) -); + common_hal__eve_BitmapSizeH(EVEHAL(self), width, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { uint32_t filter = mp_obj_get_int_truncated(args[1]); - uint32_t wrapx = mp_obj_get_int_truncated(args[2]); - uint32_t wrapy = mp_obj_get_int_truncated(args[3]); - uint32_t width = mp_obj_get_int_truncated(args[4]); + uint32_t wrapx = mp_obj_get_int_truncated(args[2]); + uint32_t wrapy = mp_obj_get_int_truncated(args[3]); + uint32_t width = mp_obj_get_int_truncated(args[4]); uint32_t height = mp_obj_get_int_truncated(args[5]); - C4(args[0], ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511))) -); + common_hal__eve_BitmapSize(EVEHAL(args[0]), filter, wrapx, wrapy, width, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); -STATIC mp_obj_t _bitmapsource(mp_obj_t self , mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - C4(self, ((1 << 24) | ((addr & 0xffffff))) -); +STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapSource(EVEHAL(self), addr); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - C4(args[0], ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7))) -); + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_BitmapSwizzle(EVEHAL(args[0]), r, g, b, a); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); -STATIC mp_obj_t _bitmaptransforma(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t a = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((21 << 24) | ((p & 1) << 17) | ((a & 131071))) -); +STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t a = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); -STATIC mp_obj_t _bitmaptransformb(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t b = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((22 << 24) | ((p & 1) << 17) | ((b & 131071))) -); +STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t b = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); -STATIC mp_obj_t _bitmaptransformc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t c = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215))) -); +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t c = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); -STATIC mp_obj_t _bitmaptransformd(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t d = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((24 << 24) | ((p & 1) << 17) | ((d & 131071))) -); +STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t d = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); -STATIC mp_obj_t _bitmaptransforme(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t e = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((25 << 24) | ((p & 1) << 17) | ((e & 131071))) -); +STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t e = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); -STATIC mp_obj_t _bitmaptransformf(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t f = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - C4(self, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215))) -); +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t f = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); -STATIC mp_obj_t _blendfunc(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t src = mp_obj_get_int_truncated(a0); - uint32_t dst = mp_obj_get_int_truncated(a1); - C4(self, ((11 << 24) | ((src & 7) << 3) | ((dst & 7))) -); +STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t src = mp_obj_get_int_truncated(a0); + uint32_t dst = mp_obj_get_int_truncated(a1); + common_hal__eve_BlendFunc(EVEHAL(self), src, dst); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); -STATIC mp_obj_t _call(mp_obj_t self , mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - C4(self, ((29 << 24) | ((dest & 65535))) -); +STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Call(EVEHAL(self), dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); -STATIC mp_obj_t _cell(mp_obj_t self , mp_obj_t a0) { - uint32_t cell = mp_obj_get_int_truncated(a0); - C4(self, ((6 << 24) | ((cell & 127))) -); +STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { + uint32_t cell = mp_obj_get_int_truncated(a0); + common_hal__eve_Cell(EVEHAL(self), cell); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); -STATIC mp_obj_t _clearcolora(mp_obj_t self , mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - C4(self, ((15 << 24) | ((alpha & 255))) -); +STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearColorA(EVEHAL(self), alpha); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) -); + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ClearColorRGB(EVEHAL(args[0]), red, green, blue); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { - uint32_t c = mp_obj_get_int_truncated(args[1]); - uint32_t s = mp_obj_get_int_truncated(args[2]); - uint32_t t = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1))) -); + uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; + uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; + uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; + common_hal__eve_Clear(EVEHAL(args[0]), c, s, t); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 4, 4, _clear); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); -STATIC mp_obj_t _clearstencil(mp_obj_t self , mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - C4(self, ((17 << 24) | ((s & 255))) -); +STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearStencil(EVEHAL(self), s); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); -STATIC mp_obj_t _cleartag(mp_obj_t self , mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - C4(self, ((18 << 24) | ((s & 255))) -); +STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearTag(EVEHAL(self), s); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); -STATIC mp_obj_t _colora(mp_obj_t self , mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - C4(self, ((16 << 24) | ((alpha & 255))) -); +STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ColorA(EVEHAL(self), alpha); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - C4(args[0], ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1))) -); + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_ColorMask(EVEHAL(args[0]), r, g, b, a); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255))) -); + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ColorRGB(EVEHAL(args[0]), red, green, blue); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); -STATIC mp_obj_t _display(mp_obj_t self ) { +STATIC mp_obj_t _display(mp_obj_t self) { - C4(self, ((0 << 24)) -); + common_hal__eve_Display(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); -STATIC mp_obj_t _end(mp_obj_t self ) { +STATIC mp_obj_t _end(mp_obj_t self) { - C4(self, ((33 << 24)) -); + common_hal__eve_End(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); -STATIC mp_obj_t _jump(mp_obj_t self , mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - C4(self, ((30 << 24) | ((dest & 65535))) -); +STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Jump(EVEHAL(self), dest); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); -STATIC mp_obj_t _linewidth(mp_obj_t self , mp_obj_t a0) { - uint32_t width = mp_obj_get_int_truncated(a0); - C4(self, ((14 << 24) | ((width & 4095))) -); +STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { + uint32_t width = mp_obj_get_int_truncated(a0); + common_hal__eve_LineWidth(EVEHAL(self), width); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); -STATIC mp_obj_t _macro(mp_obj_t self , mp_obj_t a0) { - uint32_t m = mp_obj_get_int_truncated(a0); - C4(self, ((37 << 24) | ((m & 1))) -); +STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { + uint32_t m = mp_obj_get_int_truncated(a0); + common_hal__eve_Macro(EVEHAL(self), m); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); -STATIC mp_obj_t _nop(mp_obj_t self ) { +STATIC mp_obj_t _nop(mp_obj_t self) { - C4(self, ((45 << 24)) -); + common_hal__eve_Nop(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); -STATIC mp_obj_t _palettesource(mp_obj_t self , mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - C4(self, ((42 << 24) | (((addr) & 4194303))) -); +STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_PaletteSource(EVEHAL(self), addr); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); -STATIC mp_obj_t _pointsize(mp_obj_t self , mp_obj_t a0) { - uint32_t size = mp_obj_get_int_truncated(a0); - C4(self, ((13 << 24) | ((size & 8191))) -); +STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { + uint32_t size = mp_obj_get_int_truncated(a0); + common_hal__eve_PointSize(EVEHAL(self), size); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); -STATIC mp_obj_t _restorecontext(mp_obj_t self ) { +STATIC mp_obj_t _restorecontext(mp_obj_t self) { - C4(self, ((35 << 24)) -); + common_hal__eve_RestoreContext(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); -STATIC mp_obj_t _return(mp_obj_t self ) { +STATIC mp_obj_t _return(mp_obj_t self) { - C4(self, ((36 << 24)) -); + common_hal__eve_Return(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); -STATIC mp_obj_t _savecontext(mp_obj_t self ) { +STATIC mp_obj_t _savecontext(mp_obj_t self) { - C4(self, ((34 << 24)) -); + common_hal__eve_SaveContext(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); -STATIC mp_obj_t _scissorsize(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); +STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); - C4(self, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095))) -); + common_hal__eve_ScissorSize(EVEHAL(self), width, height); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); -STATIC mp_obj_t _scissorxy(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t x = mp_obj_get_int_truncated(a0); - uint32_t y = mp_obj_get_int_truncated(a1); - C4(self, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047))) -); +STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t x = mp_obj_get_int_truncated(a0); + uint32_t y = mp_obj_get_int_truncated(a1); + common_hal__eve_ScissorXY(EVEHAL(self), x, y); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { - uint32_t func = mp_obj_get_int_truncated(args[1]); - uint32_t ref = mp_obj_get_int_truncated(args[2]); - uint32_t mask = mp_obj_get_int_truncated(args[3]); - C4(args[0], ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255))) -); + uint32_t func = mp_obj_get_int_truncated(args[1]); + uint32_t ref = mp_obj_get_int_truncated(args[2]); + uint32_t mask = mp_obj_get_int_truncated(args[3]); + common_hal__eve_StencilFunc(EVEHAL(args[0]), func, ref, mask); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); -STATIC mp_obj_t _stencilmask(mp_obj_t self , mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - C4(self, ((19 << 24) | ((mask & 255))) -); +STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_StencilMask(EVEHAL(self), mask); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); -STATIC mp_obj_t _stencilop(mp_obj_t self , mp_obj_t a0, mp_obj_t a1) { - uint32_t sfail = mp_obj_get_int_truncated(a0); - uint32_t spass = mp_obj_get_int_truncated(a1); - C4(self, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7))) -); +STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t sfail = mp_obj_get_int_truncated(a0); + uint32_t spass = mp_obj_get_int_truncated(a1); + common_hal__eve_StencilOp(EVEHAL(self), sfail, spass); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); -STATIC mp_obj_t _tagmask(mp_obj_t self , mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - C4(self, ((20 << 24) | ((mask & 1))) -); +STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_TagMask(EVEHAL(self), mask); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); -STATIC mp_obj_t _tag(mp_obj_t self , mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - C4(self, ((3 << 24) | ((s & 255))) -); +STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_Tag(EVEHAL(self), s); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); -STATIC mp_obj_t _vertextranslatex(mp_obj_t self , mp_obj_t a0) { - uint32_t x = mp_obj_get_int_truncated(a0); - C4(self, ((43 << 24) | (((x) & 131071))) -); +STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { + uint32_t x = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateX(EVEHAL(self), x); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); -STATIC mp_obj_t _vertextranslatey(mp_obj_t self , mp_obj_t a0) { - uint32_t y = mp_obj_get_int_truncated(a0); - C4(self, ((44 << 24) | (((y) & 131071))) -); +STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { + uint32_t y = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateY(EVEHAL(self), y); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); -#define N_METHODS 47 -#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; } while (0) -#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) } + +STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { + uint32_t frac = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexFormat(EVEHAL(self), frac); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); + +STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { + uint32_t x = mp_obj_get_int_truncated(args[1]); + uint32_t y = mp_obj_get_int_truncated(args[2]); + uint32_t handle = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 0; + uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; + common_hal__eve_Vertex2ii(EVEHAL(args[0]), x, y, handle, cell); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); +#define N_METHODS 49 +#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) +#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c new file mode 100644 index 0000000000..ca6fd4031b --- /dev/null +++ b/shared-module/_eve/__init__.c @@ -0,0 +1,270 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 James Bowman for Excamera Labs + * + * 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 "py/runtime.h" +#include "shared-module/_eve/__init__.h" + +STATIC void write(common_hal__eve_t *eve, size_t len, void *buf) { + eve->dest[2] = mp_obj_new_bytearray_by_ref(len, buf); + mp_call_method_n_kw(1, 0, eve->dest); +} + +void common_hal__eve_flush(common_hal__eve_t *eve) { + if (eve->n != 0) { + write(eve, eve->n, eve->buf); + eve->n = 0; + } +} + +static void *append(common_hal__eve_t *eve, size_t m) { + if ((eve->n + m) > sizeof(eve->buf)) + common_hal__eve_flush(eve); + uint8_t *r = eve->buf + eve->n; + eve->n += m; + return (void*)r; +} + +void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf) { + if (len <= sizeof(eve->buf)) { + uint8_t *p = (uint8_t*)append(eve, len); + // memcpy(p, buffer_info.buf, buffer_info.len); + uint8_t *s = buf; for (size_t i = 0; i < len; i++) *p++ = *s++; + } else { + common_hal__eve_flush(eve); + write(eve, len, buf); + } +} + +#define C4(eve, u) (*(uint32_t*)append((eve), sizeof(uint32_t)) = (u)) + +void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y) { + int16_t ix = (int)(eve->vscale * x); + int16_t iy = (int)(eve->vscale * y); + C4(eve, (1 << 30) | ((ix & 32767) << 15) | (iy & 32767)); +} + +void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac) +{ + C4(eve, ((27 << 24) | ((frac & 7)))); + eve->vscale = 1 << eve->vscale; +} + + + +void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref) { + C4(eve, ((9 << 24) | ((func & 7) << 8) | ((ref & 255)))); +} + +void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim) { + C4(eve, ((31 << 24) | ((prim & 15)))); +} + +void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt) { + C4(eve, ((46 << 24) | (fmt & 65535))); +} + +void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle) { + C4(eve, ((5 << 24) | ((handle & 31)))); +} + +void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height) { + C4(eve, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3)))); +} + +void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height) { + C4(eve, ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511)))); +} + +void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height) { + C4(eve, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3)))); +} + +void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height) { + C4(eve, ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511)))); +} + +void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr) { + C4(eve, ((1 << 24) | ((addr & 0xffffff)))); +} + +void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { + C4(eve, ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7)))); +} + +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p) { + C4(eve, ((21 << 24) | ((p & 1) << 17) | ((a & 131071)))); +} + +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p) { + C4(eve, ((22 << 24) | ((p & 1) << 17) | ((b & 131071)))); +} + +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p) { + C4(eve, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215)))); +} + +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p) { + C4(eve, ((24 << 24) | ((p & 1) << 17) | ((d & 131071)))); +} + +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p) { + C4(eve, ((25 << 24) | ((p & 1) << 17) | ((e & 131071)))); +} + +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p) { + C4(eve, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215)))); +} + +void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst) { + C4(eve, ((11 << 24) | ((src & 7) << 3) | ((dst & 7)))); +} + +void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest) { + C4(eve, ((29 << 24) | ((dest & 65535)))); +} + +void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell) { + C4(eve, ((6 << 24) | ((cell & 127)))); +} + +void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha) { + C4(eve, ((15 << 24) | ((alpha & 255)))); +} + +void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { + C4(eve, ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); +} + +void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t) { + C4(eve, ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1)))); +} + +void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s) { + C4(eve, ((17 << 24) | ((s & 255)))); +} + +void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s) { + C4(eve, ((18 << 24) | ((s & 255)))); +} + +void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha) { + C4(eve, ((16 << 24) | ((alpha & 255)))); +} + +void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { + C4(eve, ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1)))); +} + +void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { + C4(eve, ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); +} + +void common_hal__eve_Display(common_hal__eve_t *eve) { + C4(eve, ((0 << 24))); +} + +void common_hal__eve_End(common_hal__eve_t *eve) { + C4(eve, ((33 << 24))); +} + +void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest) { + C4(eve, ((30 << 24) | ((dest & 65535)))); +} + +void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width) { + C4(eve, ((14 << 24) | ((width & 4095)))); +} + +void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m) { + C4(eve, ((37 << 24) | ((m & 1)))); +} + +void common_hal__eve_Nop(common_hal__eve_t *eve) { + C4(eve, ((45 << 24))); +} + +void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr) { + C4(eve, ((42 << 24) | (((addr) & 4194303)))); +} + +void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size) { + C4(eve, ((13 << 24) | ((size & 8191)))); +} + +void common_hal__eve_RestoreContext(common_hal__eve_t *eve) { + C4(eve, ((35 << 24))); +} + +void common_hal__eve_Return(common_hal__eve_t *eve) { + C4(eve, ((36 << 24))); +} + +void common_hal__eve_SaveContext(common_hal__eve_t *eve) { + C4(eve, ((34 << 24))); +} + +void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height) { + C4(eve, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095)))); +} + +void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y) { + C4(eve, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047)))); +} + +void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask) { + C4(eve, ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255)))); +} + +void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask) { + C4(eve, ((19 << 24) | ((mask & 255)))); +} + +void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass) { + C4(eve, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7)))); +} + +void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask) { + C4(eve, ((20 << 24) | ((mask & 1)))); +} + +void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s) { + C4(eve, ((3 << 24) | ((s & 255)))); +} + +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x) { + C4(eve, ((43 << 24) | (((x) & 131071)))); +} + +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y) { + C4(eve, ((44 << 24) | (((y) & 131071)))); +} + +void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell) { + C4(eve, ((2 << 30) | (((x) & 511) << 21) | (((y) & 511) << 12) | (((handle) & 31) << 7) | (((cell) & 127) << 0))); +} + diff --git a/shared-module/_eve/__init__.h b/shared-module/_eve/__init__.h new file mode 100644 index 0000000000..f2fd7a9438 --- /dev/null +++ b/shared-module/_eve/__init__.h @@ -0,0 +1,91 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 James Bowman for Excamera Labs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H +#define MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H + +typedef struct _common_hal__eve_t { + mp_obj_t dest[3]; // Own 'write' method, plus argument + int vscale; // fixed-point scaling used for Vertex2f + size_t n; // Current size of command buffer + uint8_t buf[512]; // Command buffer +} common_hal__eve_t; + +void common_hal__eve_flush(common_hal__eve_t *eve); +void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf); +void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y); + +void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref); +void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim); +void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt); +void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle); +void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); +void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); +void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); +void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t); +void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Display(common_hal__eve_t *eve); +void common_hal__eve_End(common_hal__eve_t *eve); +void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width); +void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m); +void common_hal__eve_Nop(common_hal__eve_t *eve); +void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size); +void common_hal__eve_RestoreContext(common_hal__eve_t *eve); +void common_hal__eve_Return(common_hal__eve_t *eve); +void common_hal__eve_SaveContext(common_hal__eve_t *eve); +void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y); +void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask); +void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass); +void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x); +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y); +void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac); +void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell); + +#endif // MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H From c631b4d60eddea88e5f066356859252c2cc486b8 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 7 Feb 2020 16:44:48 -0800 Subject: [PATCH 462/531] Add doc strings, inline mod_eve-gen.h and remove it --- shared-bindings/_eve/__init__.c | 880 ++++++++++++++++++++++++++++- shared-bindings/_eve/mod_eve-gen.h | 382 ------------- 2 files changed, 869 insertions(+), 393 deletions(-) delete mode 100644 shared-bindings/_eve/mod_eve-gen.h diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 6f2a39db50..b398c0a5dd 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -62,12 +62,24 @@ STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); +//| .. method:: flush() +//| +//| Send any queued drawing commands directly to the hardware. +//| +//| :param int width: The width of the grid in tiles, or 1 for sprites. +//| STATIC mp_obj_t _flush(mp_obj_t self) { common_hal__eve_flush(EVEHAL(self)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); +//| .. method:: cc(b) +//| +//| Append bytes to the command FIFO. +//| +//| :param bytes b: The bytes to add +//| STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); @@ -76,20 +88,832 @@ STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); -#include "mod_eve-gen.h" +//{ + +//| .. method:: AlphaFunc(func, ref) +//| +//| Set the alpha test function +//| +//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7) +//| :param int ref: specifies the reference value for the alpha test. Range 0-255. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t func = mp_obj_get_int_truncated(a0); + uint32_t ref = mp_obj_get_int_truncated(a1); + common_hal__eve_AlphaFunc(EVEHAL(self), func, ref); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); + +//| .. method:: Begin(prim) +//| +//| Begin drawing a graphics primitive +//| +//| :param int prim: graphics primitive. +//| +//| Valid primitives are ``BITMAPS``, ``POINTS``, ``LINES``, ``LINE_STRIP``, ``EDGE_STRIP_R``, ``EDGE_STRIP_L``, ``EDGE_STRIP_A``, ``EDGE_STRIP_B`` and ``RECTS``. +//| + +STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { + uint32_t prim = mp_obj_get_int_truncated(a0); + common_hal__eve_Begin(EVEHAL(self), prim); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); + +//| .. method:: BitmapExtFormat(format) +//| +//| Set the bitmap format +//| +//| :param int format: bitmap pixel format. +//| + +STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { + uint32_t fmt = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapExtFormat(EVEHAL(self), fmt); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); + +//| .. method:: BitmapHandle(handle) +//| +//| Set the bitmap handle +//| +//| :param int handle: bitmap handle. Range 0-31. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { + uint32_t handle = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapHandle(EVEHAL(self), handle); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); + +//| .. method:: BitmapLayoutH(linestride, height) +//| +//| Set the source bitmap memory format and layout for the current handle. high bits for large bitmaps +//| +//| :param int linestride: high part of bitmap line stride, in bytes. Range 0-7 +//| :param int height: high part of bitmap height, in lines. Range 0-3 +//| + +STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t linestride = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapLayoutH(EVEHAL(self), linestride, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); + +//| .. method:: BitmapLayout(format, linestride, height) +//| +//| Set the source bitmap memory format and layout for the current handle +//| +//| :param int format: bitmap pixel format, or GLFORMAT to use BITMAP_EXT_FORMAT instead. Range 0-31 +//| :param int linestride: bitmap line stride, in bytes. Range 0-1023 +//| :param int height: bitmap height, in lines. Range 0-511 +//| + +STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { + uint32_t format = mp_obj_get_int_truncated(args[1]); + uint32_t linestride = mp_obj_get_int_truncated(args[2]); + uint32_t height = mp_obj_get_int_truncated(args[3]); + common_hal__eve_BitmapLayout(EVEHAL(args[0]), format, linestride, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); + +//| .. method:: BitmapSizeH(width, height) +//| +//| Set the screen drawing of bitmaps for the current handle. high bits for large bitmaps +//| +//| :param int width: high part of drawn bitmap width, in pixels. Range 0-3 +//| :param int height: high part of drawn bitmap height, in pixels. Range 0-3 +//| + +STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapSizeH(EVEHAL(self), width, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); + +//| .. method:: BitmapSize(filter, wrapx, wrapy, width, height) +//| +//| Set the screen drawing of bitmaps for the current handle +//| +//| :param int filter: bitmap filtering mode, one of ``NEAREST`` or ``BILINEAR``. Range 0-1 +//| :param int wrapx: bitmap :math:`x` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1 +//| :param int wrapy: bitmap :math:`y` wrap mode, one of ``REPEAT`` or ``BORDER``. Range 0-1 +//| :param int width: drawn bitmap width, in pixels. Range 0-511 +//| :param int height: drawn bitmap height, in pixels. Range 0-511 +//| + +STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { + uint32_t filter = mp_obj_get_int_truncated(args[1]); + uint32_t wrapx = mp_obj_get_int_truncated(args[2]); + uint32_t wrapy = mp_obj_get_int_truncated(args[3]); + uint32_t width = mp_obj_get_int_truncated(args[4]); + uint32_t height = mp_obj_get_int_truncated(args[5]); + common_hal__eve_BitmapSize(EVEHAL(args[0]), filter, wrapx, wrapy, width, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); + +//| .. method:: BitmapSource(addr) +//| +//| Set the source address for bitmap graphics +//| +//| :param int addr: Bitmap start address, pixel-aligned. May be in SRAM or flash. Range 0-16777215 +//| + +STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapSource(EVEHAL(self), addr); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); + +//| .. method:: BitmapSwizzle(r, g, b, a) +//| +//| Set the source for the r,g,b and a channels of a bitmap +//| +//| :param int r: red component source channel. Range 0-7 +//| :param int g: green component source channel. Range 0-7 +//| :param int b: blue component source channel. Range 0-7 +//| :param int a: alpha component source channel. Range 0-7 +//| + +STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_BitmapSwizzle(EVEHAL(args[0]), r, g, b, a); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); + +//| .. method:: BitmapTransformA(p, v) +//| +//| Set the :math:`a` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`a` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t a = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); + +//| .. method:: BitmapTransformB(p, v) +//| +//| Set the :math:`b` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`b` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t b = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); + +//| .. method:: BitmapTransformC(c) +//| +//| Set the :math:`c` component of the bitmap transform matrix +//| +//| :param int c: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t c = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); + +//| .. method:: BitmapTransformD(p, v) +//| +//| Set the :math:`d` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`d` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t d = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); + +//| .. method:: BitmapTransformE(p, v) +//| +//| Set the :math:`e` component of the bitmap transform matrix +//| +//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 +//| :param int v: The :math:`e` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t e = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); + +//| .. method:: BitmapTransformF(f) +//| +//| Set the :math:`f` component of the bitmap transform matrix +//| +//| :param int f: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t f = mp_obj_get_int_truncated(a0); + uint32_t p = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); + +//| .. method:: BlendFunc(src, dst) +//| +//| Set pixel arithmetic +//| +//| :param int src: specifies how the source blending factor is computed. One of ``ZERO``, ``ONE``, ``SRC_ALPHA``, ``DST_ALPHA``, ``ONE_MINUS_SRC_ALPHA`` or ``ONE_MINUS_DST_ALPHA``. Range 0-7. The initial value is SRC_ALPHA(2) +//| :param int dst: specifies how the destination blending factor is computed, one of the same constants as **src**. Range 0-7. The initial value is ONE_MINUS_SRC_ALPHA(4) +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t src = mp_obj_get_int_truncated(a0); + uint32_t dst = mp_obj_get_int_truncated(a1); + common_hal__eve_BlendFunc(EVEHAL(self), src, dst); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); + +//| .. method:: Call(dest) +//| +//| Execute a sequence of commands at another location in the display list +//| +//| :param int dest: display list address. Range 0-65535 +//| + +STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Call(EVEHAL(self), dest); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); + +//| .. method:: Cell(cell) +//| +//| Set the bitmap cell number for the vertex2f command +//| +//| :param int cell: bitmap cell number. Range 0-127. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { + uint32_t cell = mp_obj_get_int_truncated(a0); + common_hal__eve_Cell(EVEHAL(self), cell); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); + +//| .. method:: ClearColorA(alpha) +//| +//| Set clear value for the alpha channel +//| +//| :param int alpha: alpha value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearColorA(EVEHAL(self), alpha); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); + +//| .. method:: ClearColorRGB(red, green, blue) +//| +//| Set clear values for red, green and blue channels +//| +//| :param int red: red value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| :param int green: green value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| :param int blue: blue value used when the color buffer is cleared. Range 0-255. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ClearColorRGB(EVEHAL(args[0]), red, green, blue); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); + +//| .. method:: Clear(c, s, t) +//| +//| Clear buffers to preset values +//| +//| :param int c: clear color buffer. Range 0-1 +//| :param int s: clear stencil buffer. Range 0-1 +//| :param int t: clear tag buffer. Range 0-1 +//| + +STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { + uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; + uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; + uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; + common_hal__eve_Clear(EVEHAL(args[0]), c, s, t); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); + +//| .. method:: ClearStencil(s) +//| +//| Set clear value for the stencil buffer +//| +//| :param int s: value used when the stencil buffer is cleared. Range 0-255. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearStencil(EVEHAL(self), s); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); + +//| .. method:: ClearTag(s) +//| +//| Set clear value for the tag buffer +//| +//| :param int s: value used when the tag buffer is cleared. Range 0-255. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_ClearTag(EVEHAL(self), s); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); + +//| .. method:: ColorA(alpha) +//| +//| Set the current color alpha +//| +//| :param int alpha: alpha for the current color. Range 0-255. The initial value is 255 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { + uint32_t alpha = mp_obj_get_int_truncated(a0); + common_hal__eve_ColorA(EVEHAL(self), alpha); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); + +//| .. method:: ColorMask(r, g, b, a) +//| +//| Enable and disable writing of frame buffer color components +//| +//| :param int r: allow updates to the frame buffer red component. Range 0-1. The initial value is 1 +//| :param int g: allow updates to the frame buffer green component. Range 0-1. The initial value is 1 +//| :param int b: allow updates to the frame buffer blue component. Range 0-1. The initial value is 1 +//| :param int a: allow updates to the frame buffer alpha component. Range 0-1. The initial value is 1 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); + common_hal__eve_ColorMask(EVEHAL(args[0]), r, g, b, a); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); + +//| .. method:: ColorRGB(red, green, blue) +//| +//| Set the drawing color +//| +//| :param int red: red value for the current color. Range 0-255. The initial value is 255 +//| :param int green: green for the current color. Range 0-255. The initial value is 255 +//| :param int blue: blue for the current color. Range 0-255. The initial value is 255 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); + common_hal__eve_ColorRGB(EVEHAL(args[0]), red, green, blue); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); + +//| .. method:: Display() +//| +//| End the display list +//| + +STATIC mp_obj_t _display(mp_obj_t self) { + + common_hal__eve_Display(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); + +//| .. method:: End() +//| +//| End drawing a graphics primitive +//| +//| :meth:`Vertex2ii` and :meth:`Vertex2f` calls are ignored until the next :meth:`Begin`. +//| + +STATIC mp_obj_t _end(mp_obj_t self) { + + common_hal__eve_End(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); + +//| .. method:: Jump(dest) +//| +//| Execute commands at another location in the display list +//| +//| :param int dest: display list address. Range 0-65535 +//| + +STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { + uint32_t dest = mp_obj_get_int_truncated(a0); + common_hal__eve_Jump(EVEHAL(self), dest); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); + +//| .. method:: LineWidth(width) +//| +//| Set the width of rasterized lines +//| +//| :param int width: line width in :math:`1/16` pixel. Range 0-4095. The initial value is 16 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { + uint32_t width = mp_obj_get_int_truncated(a0); + common_hal__eve_LineWidth(EVEHAL(self), width); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); + +//| .. method:: Macro(m) +//| +//| Execute a single command from a macro register +//| +//| :param int m: macro register to read. Range 0-1 +//| + +STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { + uint32_t m = mp_obj_get_int_truncated(a0); + common_hal__eve_Macro(EVEHAL(self), m); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); + +//| .. method:: Nop() +//| +//| No operation +//| + +STATIC mp_obj_t _nop(mp_obj_t self) { + + common_hal__eve_Nop(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); + +//| .. method:: PaletteSource(addr) +//| +//| Set the base address of the palette +//| +//| :param int addr: Address in graphics SRAM, 2-byte aligned. Range 0-4194303. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { + uint32_t addr = mp_obj_get_int_truncated(a0); + common_hal__eve_PaletteSource(EVEHAL(self), addr); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); + +//| .. method:: PointSize(size) +//| +//| Set the radius of rasterized points +//| +//| :param int size: point radius in :math:`1/16` pixel. Range 0-8191. The initial value is 16 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { + uint32_t size = mp_obj_get_int_truncated(a0); + common_hal__eve_PointSize(EVEHAL(self), size); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); + +//| .. method:: RestoreContext() +//| +//| Restore the current graphics context from the context stack +//| + +STATIC mp_obj_t _restorecontext(mp_obj_t self) { + + common_hal__eve_RestoreContext(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); + +//| .. method:: Return() +//| +//| Return from a previous call command +//| + +STATIC mp_obj_t _return(mp_obj_t self) { + + common_hal__eve_Return(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); + +//| .. method:: SaveContext() +//| +//| Push the current graphics context on the context stack +//| + +STATIC mp_obj_t _savecontext(mp_obj_t self) { + + common_hal__eve_SaveContext(EVEHAL(self)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); + +//| .. method:: ScissorSize(width, height) +//| +//| Set the size of the scissor clip rectangle +//| +//| :param int width: The width of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is hsize +//| :param int height: The height of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is 2048 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t height = mp_obj_get_int_truncated(a1); + common_hal__eve_ScissorSize(EVEHAL(self), width, height); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); + +//| .. method:: ScissorXY(x, y) +//| +//| Set the top left corner of the scissor clip rectangle +//| +//| :param int x: The :math:`x` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0 +//| :param int y: The :math:`y` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t x = mp_obj_get_int_truncated(a0); + uint32_t y = mp_obj_get_int_truncated(a1); + common_hal__eve_ScissorXY(EVEHAL(self), x, y); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); + +//| .. method:: StencilFunc(func, ref, mask) +//| +//| Set function and reference value for stencil testing +//| +//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7) +//| :param int ref: specifies the reference value for the stencil test. Range 0-255. The initial value is 0 +//| :param int mask: specifies a mask that is ANDed with the reference value and the stored stencil value. Range 0-255. The initial value is 255 +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { + uint32_t func = mp_obj_get_int_truncated(args[1]); + uint32_t ref = mp_obj_get_int_truncated(args[2]); + uint32_t mask = mp_obj_get_int_truncated(args[3]); + common_hal__eve_StencilFunc(EVEHAL(args[0]), func, ref, mask); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); + +//| .. method:: StencilMask(mask) +//| +//| Control the writing of individual bits in the stencil planes +//| +//| :param int mask: the mask used to enable writing stencil bits. Range 0-255. The initial value is 255 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_StencilMask(EVEHAL(self), mask); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); + +//| .. method:: StencilOp(sfail, spass) +//| +//| Set stencil test actions +//| +//| :param int sfail: specifies the action to take when the stencil test fails, one of ``KEEP``, ``ZERO``, ``REPLACE``, ``INCR``, ``INCR_WRAP``, ``DECR``, ``DECR_WRAP``, and ``INVERT``. Range 0-7. The initial value is KEEP(1) +//| :param int spass: specifies the action to take when the stencil test passes, one of the same constants as **sfail**. Range 0-7. The initial value is KEEP(1) +//| +//| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { + uint32_t sfail = mp_obj_get_int_truncated(a0); + uint32_t spass = mp_obj_get_int_truncated(a1); + common_hal__eve_StencilOp(EVEHAL(self), sfail, spass); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); + +//| .. method:: TagMask(mask) +//| +//| Control the writing of the tag buffer +//| +//| :param int mask: allow updates to the tag buffer. Range 0-1. The initial value is 1 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { + uint32_t mask = mp_obj_get_int_truncated(a0); + common_hal__eve_TagMask(EVEHAL(self), mask); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); + +//| .. method:: Tag(s) +//| +//| Set the current tag value +//| +//| :param int s: tag value. Range 0-255. The initial value is 255 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { + uint32_t s = mp_obj_get_int_truncated(a0); + common_hal__eve_Tag(EVEHAL(self), s); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); + +//| .. method:: VertexTranslateX(x) +//| +//| Set the vertex transformation's x translation component +//| +//| :param int x: signed x-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { + uint32_t x = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateX(EVEHAL(self), x); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); + +//| .. method:: VertexTranslateY(y) +//| +//| Set the vertex transformation's y translation component +//| +//| :param int y: signed y-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + + +STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { + uint32_t y = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexTranslateY(EVEHAL(self), y); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); + +//| .. method:: VertexFormat(frac) +//| +//| Set the precision of vertex2f coordinates +//| +//| :param int frac: Number of fractional bits in X,Y coordinates, 0-4. Range 0-7. The initial value is 4 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. +//| + +STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { + uint32_t frac = mp_obj_get_int_truncated(a0); + common_hal__eve_VertexFormat(EVEHAL(self), frac); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); + +//| .. method:: Vertex2ii(x, y, handle, cell) +//| +//| :param int x: x-coordinate in pixels. Range 0-511 +//| :param int y: y-coordinate in pixels. Range 0-511 +//| :param int handle: bitmap handle. Range 0-31 +//| :param int cell: cell number. Range 0-127 +//| +//| This method is an alternative to :meth:`Vertex2f`. +//| + +STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { + uint32_t x = mp_obj_get_int_truncated(args[1]); + uint32_t y = mp_obj_get_int_truncated(args[2]); + uint32_t handle = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 0; + uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; + common_hal__eve_Vertex2ii(EVEHAL(args[0]), x, y, handle, cell); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); + +#define N_METHODS 49 +#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) +#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } + +//} // Hand-written functions { -#define ADD_X(self, x) \ - common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); - -STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { - uint32_t code = 0xffffff00 | mp_obj_get_int_truncated(n); - ADD_X(self, code); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); - +//| .. method:: Vertex2f(b) +//| +//| Draw a point. +//| +//| :param float x: pixel x-coordinate +//| :param float y: pixel y-coordinate +//| STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { mp_float_t x = mp_obj_get_float(a0); mp_float_t y = mp_obj_get_float(a1); @@ -98,6 +922,40 @@ STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); +// Append an object x to the FIFO +#define ADD_X(self, x) \ + common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); + +//| .. method:: cmd0(n) +//| +//| Append the command word n to the FIFO +//| +//| :param int n: The command code +//| +//| This method is used by the ``eve`` module to efficiently add +//| commands to the FIFO. +//| + +STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { + uint32_t code = 0xffffff00 | mp_obj_get_int_truncated(n); + ADD_X(self, code); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); + +//| .. method:: cmd(n, fmt, args) +//| +//| Append a command packet to the FIFO. +//| +//| :param int n: The command code +//| :param str fmt: The command format `struct` layout +//| :param tuple args: The command's arguments +//| +//| Supported format codes: h, H, i, I. +//| +//| This method is used by the ``eve`` module to efficiently add +//| commands to the FIFO. +//| STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; mp_obj_t num = args[1]; diff --git a/shared-bindings/_eve/mod_eve-gen.h b/shared-bindings/_eve/mod_eve-gen.h deleted file mode 100644 index c5dafb16f0..0000000000 --- a/shared-bindings/_eve/mod_eve-gen.h +++ /dev/null @@ -1,382 +0,0 @@ - -STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t func = mp_obj_get_int_truncated(a0); - uint32_t ref = mp_obj_get_int_truncated(a1); - common_hal__eve_AlphaFunc(EVEHAL(self), func, ref); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); - -STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { - uint32_t prim = mp_obj_get_int_truncated(a0); - common_hal__eve_Begin(EVEHAL(self), prim); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); - -STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { - uint32_t fmt = mp_obj_get_int_truncated(a0); - common_hal__eve_BitmapExtFormat(EVEHAL(self), fmt); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); - -STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { - uint32_t handle = mp_obj_get_int_truncated(a0); - common_hal__eve_BitmapHandle(EVEHAL(self), handle); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); - -STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t linestride = mp_obj_get_int_truncated(a0); - uint32_t height = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapLayoutH(EVEHAL(self), linestride, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); - -STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { - uint32_t format = mp_obj_get_int_truncated(args[1]); - uint32_t linestride = mp_obj_get_int_truncated(args[2]); - uint32_t height = mp_obj_get_int_truncated(args[3]); - common_hal__eve_BitmapLayout(EVEHAL(args[0]), format, linestride, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout); - -STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); - uint32_t height = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapSizeH(EVEHAL(self), width, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); - -STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { - uint32_t filter = mp_obj_get_int_truncated(args[1]); - uint32_t wrapx = mp_obj_get_int_truncated(args[2]); - uint32_t wrapy = mp_obj_get_int_truncated(args[3]); - uint32_t width = mp_obj_get_int_truncated(args[4]); - uint32_t height = mp_obj_get_int_truncated(args[5]); - common_hal__eve_BitmapSize(EVEHAL(args[0]), filter, wrapx, wrapy, width, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); - -STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - common_hal__eve_BitmapSource(EVEHAL(self), addr); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); - -STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - common_hal__eve_BitmapSwizzle(EVEHAL(args[0]), r, g, b, a); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle); - -STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t a = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); - -STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t b = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); - -STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t c = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); - -STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t d = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); - -STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t e = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); - -STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t f = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); - -STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t src = mp_obj_get_int_truncated(a0); - uint32_t dst = mp_obj_get_int_truncated(a1); - common_hal__eve_BlendFunc(EVEHAL(self), src, dst); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); - -STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - common_hal__eve_Call(EVEHAL(self), dest); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); - -STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { - uint32_t cell = mp_obj_get_int_truncated(a0); - common_hal__eve_Cell(EVEHAL(self), cell); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); - -STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - common_hal__eve_ClearColorA(EVEHAL(self), alpha); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); - -STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - common_hal__eve_ClearColorRGB(EVEHAL(args[0]), red, green, blue); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb); - -STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { - uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; - uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; - uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; - common_hal__eve_Clear(EVEHAL(args[0]), c, s, t); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); - -STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - common_hal__eve_ClearStencil(EVEHAL(self), s); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); - -STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - common_hal__eve_ClearTag(EVEHAL(self), s); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); - -STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); - common_hal__eve_ColorA(EVEHAL(self), alpha); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); - -STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); - common_hal__eve_ColorMask(EVEHAL(args[0]), r, g, b, a); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); - -STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); - common_hal__eve_ColorRGB(EVEHAL(args[0]), red, green, blue); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); - -STATIC mp_obj_t _display(mp_obj_t self) { - - common_hal__eve_Display(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); - -STATIC mp_obj_t _end(mp_obj_t self) { - - common_hal__eve_End(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); - -STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); - common_hal__eve_Jump(EVEHAL(self), dest); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); - -STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { - uint32_t width = mp_obj_get_int_truncated(a0); - common_hal__eve_LineWidth(EVEHAL(self), width); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); - -STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { - uint32_t m = mp_obj_get_int_truncated(a0); - common_hal__eve_Macro(EVEHAL(self), m); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); - -STATIC mp_obj_t _nop(mp_obj_t self) { - - common_hal__eve_Nop(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); - -STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); - common_hal__eve_PaletteSource(EVEHAL(self), addr); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); - -STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { - uint32_t size = mp_obj_get_int_truncated(a0); - common_hal__eve_PointSize(EVEHAL(self), size); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); - -STATIC mp_obj_t _restorecontext(mp_obj_t self) { - - common_hal__eve_RestoreContext(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); - -STATIC mp_obj_t _return(mp_obj_t self) { - - common_hal__eve_Return(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); - -STATIC mp_obj_t _savecontext(mp_obj_t self) { - - common_hal__eve_SaveContext(EVEHAL(self)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); - -STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); - uint32_t height = mp_obj_get_int_truncated(a1); - common_hal__eve_ScissorSize(EVEHAL(self), width, height); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); - -STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t x = mp_obj_get_int_truncated(a0); - uint32_t y = mp_obj_get_int_truncated(a1); - common_hal__eve_ScissorXY(EVEHAL(self), x, y); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); - -STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { - uint32_t func = mp_obj_get_int_truncated(args[1]); - uint32_t ref = mp_obj_get_int_truncated(args[2]); - uint32_t mask = mp_obj_get_int_truncated(args[3]); - common_hal__eve_StencilFunc(EVEHAL(args[0]), func, ref, mask); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); - -STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - common_hal__eve_StencilMask(EVEHAL(self), mask); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); - -STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t sfail = mp_obj_get_int_truncated(a0); - uint32_t spass = mp_obj_get_int_truncated(a1); - common_hal__eve_StencilOp(EVEHAL(self), sfail, spass); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); - -STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); - common_hal__eve_TagMask(EVEHAL(self), mask); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); - -STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); - common_hal__eve_Tag(EVEHAL(self), s); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); - -STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { - uint32_t x = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexTranslateX(EVEHAL(self), x); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); - -STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { - uint32_t y = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexTranslateY(EVEHAL(self), y); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); - -STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { - uint32_t frac = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexFormat(EVEHAL(self), frac); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); - -STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { - uint32_t x = mp_obj_get_int_truncated(args[1]); - uint32_t y = mp_obj_get_int_truncated(args[2]); - uint32_t handle = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 0; - uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; - common_hal__eve_Vertex2ii(EVEHAL(args[0]), x, y, handle, cell); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); -#define N_METHODS 49 -#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) -#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } From f101ff60c505f5ddcdd69cfd1f58e83c4676eb46 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 7 Feb 2020 17:10:19 -0800 Subject: [PATCH 463/531] Move _eve module declarations into shared-bindings header --- shared-bindings/_eve/__init__.c | 3 +- shared-bindings/_eve/__init__.h | 84 +++++++++++++++++++++++++++++++++ shared-module/_eve/__init__.h | 54 --------------------- 3 files changed, 86 insertions(+), 55 deletions(-) create mode 100644 shared-bindings/_eve/__init__.h diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index b398c0a5dd..d3076afbfa 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 James Bowman + * Copyright (c) 2020 James Bowman for Excamera Labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,6 +32,7 @@ #include "py/binary.h" #include "shared-module/_eve/__init__.h" +#include "shared-bindings/_eve/__init__.h" //| :mod:`_eve` --- low-level BridgeTek EVE bindings //| ================================================ diff --git a/shared-bindings/_eve/__init__.h b/shared-bindings/_eve/__init__.h new file mode 100644 index 0000000000..6287fb606a --- /dev/null +++ b/shared-bindings/_eve/__init__.h @@ -0,0 +1,84 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 James Bowman for Excamera Labs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H + +void common_hal__eve_flush(common_hal__eve_t *eve); +void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf); +void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y); + +void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref); +void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim); +void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt); +void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle); +void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height); +void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); +void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); +void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); +void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); +void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t); +void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha); +void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); +void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); +void common_hal__eve_Display(common_hal__eve_t *eve); +void common_hal__eve_End(common_hal__eve_t *eve); +void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest); +void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width); +void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m); +void common_hal__eve_Nop(common_hal__eve_t *eve); +void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr); +void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size); +void common_hal__eve_RestoreContext(common_hal__eve_t *eve); +void common_hal__eve_Return(common_hal__eve_t *eve); +void common_hal__eve_SaveContext(common_hal__eve_t *eve); +void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height); +void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y); +void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask); +void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass); +void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask); +void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s); +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x); +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y); +void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac); +void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H diff --git a/shared-module/_eve/__init__.h b/shared-module/_eve/__init__.h index f2fd7a9438..5217d860ab 100644 --- a/shared-module/_eve/__init__.h +++ b/shared-module/_eve/__init__.h @@ -34,58 +34,4 @@ typedef struct _common_hal__eve_t { uint8_t buf[512]; // Command buffer } common_hal__eve_t; -void common_hal__eve_flush(common_hal__eve_t *eve); -void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf); -void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y); - -void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref); -void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim); -void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt); -void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle); -void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height); -void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height); -void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height); -void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); -void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); -void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); -void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); -void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); -void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); -void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); -void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); -void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); -void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); -void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); -void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); -void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha); -void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); -void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t); -void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s); -void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s); -void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha); -void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); -void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue); -void common_hal__eve_Display(common_hal__eve_t *eve); -void common_hal__eve_End(common_hal__eve_t *eve); -void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest); -void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width); -void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m); -void common_hal__eve_Nop(common_hal__eve_t *eve); -void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr); -void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size); -void common_hal__eve_RestoreContext(common_hal__eve_t *eve); -void common_hal__eve_Return(common_hal__eve_t *eve); -void common_hal__eve_SaveContext(common_hal__eve_t *eve); -void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height); -void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y); -void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask); -void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask); -void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass); -void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask); -void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s); -void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x); -void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y); -void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac); -void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell); - #endif // MICROPY_INCLUDED_SHARED_MODULE__EVE___INIT___H From 84fa0c187e9801c39c669b87004542accb20f5c4 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 8 Feb 2020 15:33:25 -0800 Subject: [PATCH 464/531] adding new board - PyCubed open source and radiation tested hardware + software platform for small satellites called CubeSats. See pycubed.org for more info. See quickstart.pycubed.org for lots of circuitpython examples --- ports/atmel-samd/boards/pycubed/board.c | 55 +++++++++++++++++++ .../atmel-samd/boards/pycubed/mpconfigboard.h | 34 ++++++++++++ .../boards/pycubed/mpconfigboard.mk | 24 ++++++++ ports/atmel-samd/boards/pycubed/pins.c | 55 +++++++++++++++++++ 4 files changed, 168 insertions(+) create mode 100644 ports/atmel-samd/boards/pycubed/board.c create mode 100644 ports/atmel-samd/boards/pycubed/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/pycubed/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/pycubed/pins.c diff --git a/ports/atmel-samd/boards/pycubed/board.c b/ports/atmel-samd/boards/pycubed/board.c new file mode 100644 index 0000000000..da37252d82 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed/board.c @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#include + +#include "boards/board.h" +#include "py/mpconfig.h" +#include "shared-bindings/nvm/ByteArray.h" + +nvm_bytearray_obj_t bootcnt = { + .base = { + .type = &nvm_bytearray_type + }, + .len = ( uint32_t) 8192, + .start_address = (uint8_t*) (0x00080000 - 8192) + }; + + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + uint8_t value_out = 0; + common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out); + ++value_out; + common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1); +} \ No newline at end of file diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.h b/ports/atmel-samd/boards/pycubed/mpconfigboard.h new file mode 100644 index 0000000000..49a98e8d45 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.h @@ -0,0 +1,34 @@ + +#define MICROPY_HW_BOARD_NAME "PyCubedv04" +#define MICROPY_HW_MCU_NAME "samd51j19" +#define CIRCUITPY_MCU_FAMILY samd51 + +#define MICROPY_HW_NEOPIXEL (&pin_PA21) + +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +#define AUTORESET_DELAY_MS 500 + +#define CIRCUITPY_INTERNAL_NVM_SIZE 8192 + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define EXTERNAL_FLASH_QSPI_DUAL + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PB13) +#define DEFAULT_I2C_BUS_SDA (&pin_PB12) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA12) +#define DEFAULT_SPI_BUS_MISO (&pin_PA14) + +#define DEFAULT_UART_BUS_TX (&pin_PB02) +#define DEFAULT_UART_BUS_RX (&pin_PB03) + +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk new file mode 100644 index 0000000000..adbb4aedb9 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk @@ -0,0 +1,24 @@ +LD_FILE = boards/samd51x19-bootloader-external-flash.ld +USB_VID = 0x04D8 +USB_PID = 0xEC44 +USB_PRODUCT = "PyCubed" +USB_MANUFACTURER = "maholli" + +CHIP_VARIANT = SAMD51J19A +CHIP_FAMILY = samd51 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = W25Q80DV +LONGINT_IMPL = MPZ + +# Not needed. +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_GAMEPAD = 0 +CIRCUITPY_PS2IO = 0 + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD \ No newline at end of file diff --git a/ports/atmel-samd/boards/pycubed/pins.c b/ports/atmel-samd/boards/pycubed/pins.c new file mode 100644 index 0000000000..4c97f58a80 --- /dev/null +++ b/ports/atmel-samd/boards/pycubed/pins.c @@ -0,0 +1,55 @@ +#include "shared-bindings/board/__init__.h" +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_xSDCS), MP_ROM_PTR(&pin_PA27) }, + + { MP_ROM_QSTR(MP_QSTR_RELAY_A), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_BURN1), MP_ROM_PTR(&pin_PB31) }, + { MP_ROM_QSTR(MP_QSTR_BURN2), MP_ROM_PTR(&pin_PA15) }, + + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_L1PROG), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_AIN4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_AIN5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_CHRG), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_DAC0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_PA17), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_PA18), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_PA19), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_PA20), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_PA22), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_PB16), MP_ROM_PTR(&pin_PB16) }, + { MP_ROM_QSTR(MP_QSTR_PB17), MP_ROM_PTR(&pin_PB17) }, + { MP_ROM_QSTR(MP_QSTR_PB22), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_PB23), MP_ROM_PTR(&pin_PB23) }, + + { MP_ROM_QSTR(MP_QSTR_RF1_RST), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_RF1_CS), MP_ROM_PTR(&pin_PB30) }, + { MP_ROM_QSTR(MP_QSTR_RF1_IO0), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_RF1_IO4), MP_ROM_PTR(&pin_PB04) }, + + { MP_ROM_QSTR(MP_QSTR_RF2_RST), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_RF2_CS), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_RF2_IO1), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_RF2_BSY), MP_ROM_PTR(&pin_PB07) }, + + { MP_ROM_QSTR(MP_QSTR_EN_GPS), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB03) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB13) }, + + { MP_ROM_QSTR(MP_QSTR_WDT_WDI), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA21) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { 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_global_dict_table); \ No newline at end of file From 723a64cbdaf760c688170419899007489fb19679 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 8 Feb 2020 15:35:38 -0800 Subject: [PATCH 465/531] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc4aab5bed..a0f0510c72 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -196,6 +196,7 @@ jobs: - "pyb_nano_v2" - "pybadge" - "pybadge_airlift" + - "pycubed" - "pyboard_v11" - "pygamer" - "pygamer_advance" From b91c4e66cb1e6672b21a6dff359041d5b4e91b59 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 8 Feb 2020 16:09:47 -0800 Subject: [PATCH 466/531] adding Adafruit_CircuitPython_Register to frozen + updating SAM32 --- ports/atmel-samd/boards/sam32/mpconfigboard.h | 15 ++++----- .../atmel-samd/boards/sam32/mpconfigboard.mk | 7 ++++ ports/atmel-samd/boards/sam32/pins.c | 33 ++++++++++++------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.h b/ports/atmel-samd/boards/sam32/mpconfigboard.h index bd9f5e3983..6378e41620 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.h +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.h @@ -1,23 +1,22 @@ - -#define MICROPY_HW_BOARD_NAME "SAM32v2a" +#define MICROPY_HW_BOARD_NAME "SAM32v26" #define MICROPY_HW_MCU_NAME "samd51j20" #define CIRCUITPY_MCU_FAMILY samd51 #define MICROPY_HW_LED_STATUS (&pin_PA27) -#define MICROPY_HW_NEOPIXEL (&pin_PA15) +#define MICROPY_HW_NEOPIXEL (&pin_PA15) #define MICROPY_PORT_A (PORT_PA24 | PORT_PA25) #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define MICROPY_PORT_D (0) +#define MICROPY_PORT_D (0) -// No microcontroller.nvm -#define CIRCUITPY_INTERNAL_NVM_SIZE 0 +#define CIRCUITPY_INTERNAL_NVM_SIZE 1024 +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (128*1024) #define BOARD_HAS_CRYSTAL 1 -#define DEFAULT_I2C_BUS_SCL (&pin_PA04) -#define DEFAULT_I2C_BUS_SDA (&pin_PA07) +#define DEFAULT_I2C_BUS_SCL (&pin_PA09) +#define DEFAULT_I2C_BUS_SDA (&pin_PA08) #define DEFAULT_SPI_BUS_SCK (&pin_PB13) #define DEFAULT_SPI_BUS_MOSI (&pin_PB12) diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.mk b/ports/atmel-samd/boards/sam32/mpconfigboard.mk index 0d6be64374..1187449355 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.mk @@ -8,3 +8,10 @@ CHIP_FAMILY = samd51 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = MPZ + +# No I2S on SAMD51 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_USTACK = 1 + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel \ No newline at end of file diff --git a/ports/atmel-samd/boards/sam32/pins.c b/ports/atmel-samd/boards/sam32/pins.c index f32057d754..f0a5b2b626 100644 --- a/ports/atmel-samd/boards/sam32/pins.c +++ b/ports/atmel-samd/boards/sam32/pins.c @@ -1,10 +1,8 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_PB09) }, { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB04) }, { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB05) }, { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PB06) }, @@ -13,15 +11,14 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, - { MP_ROM_QSTR(MP_QSTR_xSDCS),MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_xSDCS),MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_DAC0), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_PA10) }, { MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_D29), MP_ROM_PTR(&pin_PA12) }, - { MP_ROM_QSTR(MP_QSTR_D30), MP_ROM_PTR(&pin_PA13) }, { MP_ROM_QSTR(MP_QSTR_D31), MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_PA17) }, @@ -35,12 +32,24 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D50), MP_ROM_PTR(&pin_PB23) }, { MP_ROM_QSTR(MP_QSTR_D59), MP_ROM_PTR(&pin_PB30) }, { MP_ROM_QSTR(MP_QSTR_D60), MP_ROM_PTR(&pin_PB31) }, - { MP_ROM_QSTR(MP_QSTR_D64), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_D61), MP_ROM_PTR(&pin_PB00) }, + + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_PB03) }, + + { MP_ROM_QSTR(MP_QSTR_TCK), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_TDI), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_TMS), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_ESP_CS),MP_ROM_PTR(&pin_PB15) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PB16) }, + { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PB17) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, { MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_PTR(&pin_PB11) }, { MP_ROM_QSTR(MP_QSTR_DTR), MP_ROM_PTR(&pin_PB10) }, From ffd15c29dcc27b61903e4fc2401b87155c095938 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sat, 8 Feb 2020 16:15:23 -0800 Subject: [PATCH 467/531] trying to add Adafruit_CircuitPython_Register again --- .gitmodules | 3 +++ frozen/Adafruit_CircuitPython_Register | 1 + 2 files changed, 4 insertions(+) create mode 160000 frozen/Adafruit_CircuitPython_Register diff --git a/.gitmodules b/.gitmodules index cb36ad4c4a..88d46f69df 100644 --- a/.gitmodules +++ b/.gitmodules @@ -111,3 +111,6 @@ [submodule "ports/mimxrt10xx/sdk"] path = ports/mimxrt10xx/sdk url = https://github.com/adafruit/MIMXRT10xx_SDK +[submodule "frozen/Adafruit_CircuitPython_Register"] + path = frozen/Adafruit_CircuitPython_Register + url = https://github.com/adafruit/Adafruit_CircuitPython_Register.git diff --git a/frozen/Adafruit_CircuitPython_Register b/frozen/Adafruit_CircuitPython_Register new file mode 160000 index 0000000000..c525eedeb0 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_Register @@ -0,0 +1 @@ +Subproject commit c525eedeb0d20c9829febfbf621eab707da71f8a From 0a54f8875127abd334eff4f9173719da812f2e7d Mon Sep 17 00:00:00 2001 From: Drew Fustini Date: Mon, 10 Feb 2020 00:12:37 +0100 Subject: [PATCH 468/531] add pin defs for buttons on the OHS2020 badge --- ports/nrf/boards/ohs2020_badge/pins.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/nrf/boards/ohs2020_badge/pins.c b/ports/nrf/boards/ohs2020_badge/pins.c index e984e3070f..c92d77a92a 100644 --- a/ports/nrf/boards/ohs2020_badge/pins.c +++ b/ports/nrf/boards/ohs2020_badge/pins.c @@ -19,6 +19,11 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_C), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_D), MP_ROM_PTR(&pin_P1_03) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 3bf4b42e2e99a7a1afac20aa4e0daf97d1d4e734 Mon Sep 17 00:00:00 2001 From: Drew Fustini Date: Mon, 10 Feb 2020 00:49:13 +0100 Subject: [PATCH 469/531] change OH20 badge pin defs to use SWn for buttons Rather than use A, B, C and D Use the buttons according to silkscreen references: SW1 SW2 SW3 SW4 --- ports/nrf/boards/ohs2020_badge/pins.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/nrf/boards/ohs2020_badge/pins.c b/ports/nrf/boards/ohs2020_badge/pins.c index c92d77a92a..2cf783cc1e 100644 --- a/ports/nrf/boards/ohs2020_badge/pins.c +++ b/ports/nrf/boards/ohs2020_badge/pins.c @@ -20,10 +20,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, - { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_P0_29) }, - { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_P0_03) }, - { MP_ROM_QSTR(MP_QSTR_BUTTON_C), MP_ROM_PTR(&pin_P0_17) }, - { MP_ROM_QSTR(MP_QSTR_BUTTON_D), MP_ROM_PTR(&pin_P1_03) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_SW1), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_SW2), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_SW3), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_SW4), MP_ROM_PTR(&pin_P1_03) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 8f9ff3d49c8f0cb766b18d050cb534cdb53de95f Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Mon, 10 Feb 2020 11:43:18 -0500 Subject: [PATCH 470/531] Add translations --- locale/ID.po | 10 +++++++++- locale/circuitpython.pot | 10 +++++++++- locale/de_DE.po | 10 +++++++++- locale/en_US.po | 10 +++++++++- locale/en_x_pirate.po | 10 +++++++++- locale/es.po | 10 +++++++++- locale/fil.po | 10 +++++++++- locale/fr.po | 10 +++++++++- locale/it_IT.po | 10 +++++++++- locale/ko.po | 10 +++++++++- locale/pl.po | 10 +++++++++- locale/pt_BR.po | 10 +++++++++- locale/zh_Latn_pinyin.po | 10 +++++++++- 13 files changed, 117 insertions(+), 13 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 36bfc4df64..ff14524d99 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1281,6 +1281,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1490,6 +1494,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "PERINGATAN: Nama file kode anda mempunyai dua ekstensi\n" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index f85bcba83f..5d87ccdda1 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1265,6 +1265,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1473,6 +1477,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index ba1915e430..884ce51cab 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -1282,6 +1282,10 @@ msgstr "Stream fehlt readinto() oder write() Methode." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1494,6 +1498,10 @@ msgstr "Länge des Wertes > max_length" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper-Funktionen unterstützen derzeit nicht mehr als 4 Argumente" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index c6a78b505b..181a6da5f4 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -1265,6 +1265,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1473,6 +1477,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 12ca1d6082..7c89108caf 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -1269,6 +1269,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1477,6 +1481,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Blimey! Yer code filename has two extensions\n" diff --git a/locale/es.po b/locale/es.po index b4e0981650..cc73595f23 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -1282,6 +1282,10 @@ msgstr "A Stream le falta el método readinto() o write()." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1491,6 +1495,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "funciones Viper actualmente no soportan más de 4 argumentos." +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n" diff --git a/locale/fil.po b/locale/fil.po index 86378ba107..af428908e3 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -1288,6 +1288,10 @@ msgstr "Stream kulang ng readinto() o write() method." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1500,6 +1504,10 @@ msgstr "" "Ang mga function ng Viper ay kasalukuyang hindi sumusuporta sa higit sa 4 na " "argumento" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "BABALA: Ang pangalan ng file ay may dalawang extension\n" diff --git a/locale/fr.po b/locale/fr.po index b522b253da..5d6ddb8d2f 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -1302,6 +1302,10 @@ msgstr "Il manque une méthode readinto() ou write() au flux." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1518,6 +1522,10 @@ msgid "Viper functions don't currently support more than 4 arguments" msgstr "" "les fonctions de Viper ne supportent pas plus de 4 arguments actuellement" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENTION: le nom de fichier de votre code a deux extensions\n" diff --git a/locale/it_IT.po b/locale/it_IT.po index e4a06b7691..568565b32d 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -1299,6 +1299,10 @@ msgstr "Metodi mancanti readinto() o write() allo stream." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1509,6 +1513,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Le funzioni Viper non supportano più di 4 argomenti al momento" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENZIONE: Il nome del sorgente ha due estensioni\n" diff --git a/locale/ko.po b/locale/ko.po index fa49366825..d839d376ea 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -1269,6 +1269,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1478,6 +1482,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 70106112ed..2f60f3f3b3 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -1270,6 +1270,10 @@ msgstr "Strumień nie ma metod readinto() lub write()." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1478,6 +1482,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Funkcje Viper nie obsługują obecnie więcej niż 4 argumentów" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "UWAGA: Nazwa pliku ma dwa rozszerzenia\n" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 755dc6d972..eef39cde34 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -1282,6 +1282,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1491,6 +1495,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "AVISO: Seu arquivo de código tem duas extensões\n" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 369ce4426c..cfb8b32845 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-29 17:27-0800\n" +"POT-Creation-Date: 2020-02-10 11:42-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -1275,6 +1275,10 @@ msgstr "Liú quēshǎo readinto() huò write() fāngfǎ." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1485,6 +1489,10 @@ msgstr "Zhí chángdù > zuìdà chángdù" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper hánshù mùqián bù zhīchí chāoguò 4 gè cānshù" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Jǐnggào: Nǐ de dàimǎ wénjiàn míng yǒu liǎng gè kuòzhǎn míng\n" From ea7f80e8a7a85c0ab31907ae9bc6e5dcfcc21b9b Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Mon, 10 Feb 2020 11:45:35 -0500 Subject: [PATCH 471/531] Revert "Add translations" This reverts commit 8f9ff3d49c8f0cb766b18d050cb534cdb53de95f. --- locale/ID.po | 10 +--------- locale/circuitpython.pot | 10 +--------- locale/de_DE.po | 10 +--------- locale/en_US.po | 10 +--------- locale/en_x_pirate.po | 10 +--------- locale/es.po | 10 +--------- locale/fil.po | 10 +--------- locale/fr.po | 10 +--------- locale/it_IT.po | 10 +--------- locale/ko.po | 10 +--------- locale/pl.po | 10 +--------- locale/pt_BR.po | 10 +--------- locale/zh_Latn_pinyin.po | 10 +--------- 13 files changed, 13 insertions(+), 117 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index ff14524d99..36bfc4df64 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1281,10 +1281,6 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1494,10 +1490,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "PERINGATAN: Nama file kode anda mempunyai dua ekstensi\n" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 5d87ccdda1..f85bcba83f 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1265,10 +1265,6 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1477,10 +1473,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 884ce51cab..ba1915e430 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -1282,10 +1282,6 @@ msgstr "Stream fehlt readinto() oder write() Methode." msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1498,10 +1494,6 @@ msgstr "Länge des Wertes > max_length" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper-Funktionen unterstützen derzeit nicht mehr als 4 Argumente" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index 181a6da5f4..c6a78b505b 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -1265,10 +1265,6 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1477,10 +1473,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 7c89108caf..12ca1d6082 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -1269,10 +1269,6 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1481,10 +1477,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Blimey! Yer code filename has two extensions\n" diff --git a/locale/es.po b/locale/es.po index cc73595f23..b4e0981650 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -1282,10 +1282,6 @@ msgstr "A Stream le falta el método readinto() o write()." msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1495,10 +1491,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "funciones Viper actualmente no soportan más de 4 argumentos." -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n" diff --git a/locale/fil.po b/locale/fil.po index af428908e3..86378ba107 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -1288,10 +1288,6 @@ msgstr "Stream kulang ng readinto() o write() method." msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1504,10 +1500,6 @@ msgstr "" "Ang mga function ng Viper ay kasalukuyang hindi sumusuporta sa higit sa 4 na " "argumento" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "BABALA: Ang pangalan ng file ay may dalawang extension\n" diff --git a/locale/fr.po b/locale/fr.po index 5d6ddb8d2f..b522b253da 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -1302,10 +1302,6 @@ msgstr "Il manque une méthode readinto() ou write() au flux." msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1522,10 +1518,6 @@ msgid "Viper functions don't currently support more than 4 arguments" msgstr "" "les fonctions de Viper ne supportent pas plus de 4 arguments actuellement" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENTION: le nom de fichier de votre code a deux extensions\n" diff --git a/locale/it_IT.po b/locale/it_IT.po index 568565b32d..e4a06b7691 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -1299,10 +1299,6 @@ msgstr "Metodi mancanti readinto() o write() allo stream." msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1513,10 +1509,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Le funzioni Viper non supportano più di 4 argomenti al momento" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENZIONE: Il nome del sorgente ha due estensioni\n" diff --git a/locale/ko.po b/locale/ko.po index d839d376ea..fa49366825 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -1269,10 +1269,6 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1482,10 +1478,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 2f60f3f3b3..70106112ed 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -1270,10 +1270,6 @@ msgstr "Strumień nie ma metod readinto() lub write()." msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1482,10 +1478,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Funkcje Viper nie obsługują obecnie więcej niż 4 argumentów" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "UWAGA: Nazwa pliku ma dwa rozszerzenia\n" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index eef39cde34..755dc6d972 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -1282,10 +1282,6 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1495,10 +1491,6 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "AVISO: Seu arquivo de código tem duas extensões\n" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index cfb8b32845..369ce4426c 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:42-0500\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -1275,10 +1275,6 @@ msgstr "Liú quēshǎo readinto() huò write() fāngfǎ." msgid "Supply at least one UART pin" msgstr "" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1489,10 +1485,6 @@ msgstr "Zhí chángdù > zuìdà chángdù" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper hánshù mùqián bù zhīchí chāoguò 4 gè cānshù" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Jǐnggào: Nǐ de dàimǎ wénjiàn míng yǒu liǎng gè kuòzhǎn míng\n" From a8f5fcc400815b763fd96c1dee4fba1c316cdadc Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Mon, 10 Feb 2020 11:46:23 -0500 Subject: [PATCH 472/531] revised translations --- locale/ID.po | 10 +++++++++- locale/circuitpython.pot | 10 +++++++++- locale/de_DE.po | 10 +++++++++- locale/en_US.po | 10 +++++++++- locale/en_x_pirate.po | 10 +++++++++- locale/es.po | 10 +++++++++- locale/fil.po | 10 +++++++++- locale/fr.po | 10 +++++++++- locale/it_IT.po | 10 +++++++++- locale/ko.po | 10 +++++++++- locale/pl.po | 10 +++++++++- locale/pt_BR.po | 10 +++++++++- locale/zh_Latn_pinyin.po | 10 +++++++++- 13 files changed, 117 insertions(+), 13 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index bcdad29942..182dd2679d 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1285,6 +1285,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1494,6 +1498,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "PERINGATAN: Nama file kode anda mempunyai dua ekstensi\n" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 3e44130688..281fb4cb43 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-07 10:02-0500\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1269,6 +1269,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1477,6 +1481,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index f2d8537f61..a5bb053abd 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -1286,6 +1286,10 @@ msgstr "Stream fehlt readinto() oder write() Methode." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1498,6 +1502,10 @@ msgstr "Länge des Wertes > max_length" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper-Funktionen unterstützen derzeit nicht mehr als 4 Argumente" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index 680c535a99..5485810a31 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -1269,6 +1269,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1477,6 +1481,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 5ff575cdf8..517d067dad 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -1273,6 +1273,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1481,6 +1485,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Blimey! Yer code filename has two extensions\n" diff --git a/locale/es.po b/locale/es.po index 873c4d3e73..76f0799249 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -1286,6 +1286,10 @@ msgstr "A Stream le falta el método readinto() o write()." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1495,6 +1499,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "funciones Viper actualmente no soportan más de 4 argumentos." +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n" diff --git a/locale/fil.po b/locale/fil.po index 63feb3316a..187c31b538 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -1292,6 +1292,10 @@ msgstr "Stream kulang ng readinto() o write() method." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1504,6 +1508,10 @@ msgstr "" "Ang mga function ng Viper ay kasalukuyang hindi sumusuporta sa higit sa 4 na " "argumento" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "BABALA: Ang pangalan ng file ay may dalawang extension\n" diff --git a/locale/fr.po b/locale/fr.po index ba1d56211a..8b66e5c0d6 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -1306,6 +1306,10 @@ msgstr "Il manque une méthode readinto() ou write() au flux." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1522,6 +1526,10 @@ msgid "Viper functions don't currently support more than 4 arguments" msgstr "" "les fonctions de Viper ne supportent pas plus de 4 arguments actuellement" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENTION: le nom de fichier de votre code a deux extensions\n" diff --git a/locale/it_IT.po b/locale/it_IT.po index 6bc116f219..3671a6ec23 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -1303,6 +1303,10 @@ msgstr "Metodi mancanti readinto() o write() allo stream." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1513,6 +1517,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Le funzioni Viper non supportano più di 4 argomenti al momento" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENZIONE: Il nome del sorgente ha due estensioni\n" diff --git a/locale/ko.po b/locale/ko.po index 64bd2e9dd4..f1f550775d 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -1273,6 +1273,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1482,6 +1486,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 77357d05d5..ee95b2e7d1 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -1274,6 +1274,10 @@ msgstr "Strumień nie ma metod readinto() lub write()." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1482,6 +1486,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Funkcje Viper nie obsługują obecnie więcej niż 4 argumentów" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "UWAGA: Nazwa pliku ma dwa rozszerzenia\n" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index e5dde29f47..b94b14fcd5 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -1286,6 +1286,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1495,6 +1499,10 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "AVISO: Seu arquivo de código tem duas extensões\n" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index dbe1605b69..938f59cf73 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-10 11:46-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -1279,6 +1279,10 @@ msgstr "Liú quēshǎo readinto() huò write() fāngfǎ." msgid "Supply at least one UART pin" msgstr "" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1489,6 +1493,10 @@ msgstr "Zhí chángdù > zuìdà chángdù" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper hánshù mùqián bù zhīchí chāoguò 4 gè cānshù" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Jǐnggào: Nǐ de dàimǎ wénjiàn míng yǒu liǎng gè kuòzhǎn míng\n" From 3f700e7e6811f3c1ee15a9620c93ae024563ef2c Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Mon, 10 Feb 2020 12:16:00 -0500 Subject: [PATCH 473/531] fix missing parameter --- ports/stm32f4/mphalport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm32f4/mphalport.c b/ports/stm32f4/mphalport.c index 47ff493e2d..a3cf501c04 100644 --- a/ports/stm32f4/mphalport.c +++ b/ports/stm32f4/mphalport.c @@ -51,7 +51,7 @@ void mp_hal_delay_ms(mp_uint_t delay) { } void mp_hal_delay_us(mp_uint_t delay) { - common_hal_mcu_delay_us(); + common_hal_mcu_delay_us(delay); } void mp_hal_disable_all_interrupts(void) { From a0ba5018494fab2ba9b07e9101db04557cca5855 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Mon, 10 Feb 2020 09:35:15 -0800 Subject: [PATCH 474/531] spelling is hard :) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a0f0510c72..ea51c574d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -196,8 +196,8 @@ jobs: - "pyb_nano_v2" - "pybadge" - "pybadge_airlift" - - "pycubed" - "pyboard_v11" + - "pycubed" - "pygamer" - "pygamer_advance" - "pyportal" From c4436910c3cea5b67dc207d1ad80f3d2c4372844 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Mon, 10 Feb 2020 12:44:23 -0500 Subject: [PATCH 475/531] create F407 specific files --- ports/stm32f4/boards/STM32F407_fs.ld | 108 ++++ ports/stm32f4/boards/startup_stm32f407xx.s | 516 ++++++++++++++++++ .../boards/stm32f4_discovery/mpconfigboard.mk | 6 +- ports/stm32f4/peripherals/stm32f4/periph.h | 6 + ports/stm32f4/peripherals/stm32f4/pins.h | 3 + .../peripherals/stm32f4/stm32f407xx/clocks.c | 64 +++ .../peripherals/stm32f4/stm32f407xx/gpio.c | 56 ++ .../peripherals/stm32f4/stm32f407xx/periph.c | 194 +++++++ .../peripherals/stm32f4/stm32f407xx/periph.h | 57 ++ .../peripherals/stm32f4/stm32f407xx/pins.c | 161 ++++++ .../peripherals/stm32f4/stm32f407xx/pins.h | 158 ++++++ ports/stm32f4/supervisor/internal_flash.h | 5 + 12 files changed, 1331 insertions(+), 3 deletions(-) create mode 100644 ports/stm32f4/boards/STM32F407_fs.ld create mode 100644 ports/stm32f4/boards/startup_stm32f407xx.s create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f407xx/clocks.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f407xx/gpio.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.h create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.c create mode 100644 ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.h diff --git a/ports/stm32f4/boards/STM32F407_fs.ld b/ports/stm32f4/boards/STM32F407_fs.ld new file mode 100644 index 0000000000..7f7c917846 --- /dev/null +++ b/ports/stm32f4/boards/STM32F407_fs.ld @@ -0,0 +1,108 @@ +/* + GNU linker script for STM32F405 via Micropython +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ + FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 960K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 2K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +ENTRY(Reset_Handler) + +/* define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + + /* This first flash block is 16K annd 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. */ + + . = ALIGN(4); + } >FLASH_ISR + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text*) /* .text* sections (code) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + /* *(.glue_7) */ /* glue arm to thumb code */ + /* *(.glue_7t) */ /* glue thumb to arm code */ + + . = ALIGN(4); + _etext = .; /* define a global symbol at end of code */ + } >FLASH_TEXT + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ + } >RAM AT> FLASH_TEXT + + /* Uninitialized data section */ + .bss : + { + . = ALIGN(4); + _sbss = .; /* define a global symbol at bss start; used by startup code */ + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end; used by startup code and GC */ + } >RAM + + /* this is to define the start of the heap, and make sure we have a minimum size */ + .heap : + { + . = ALIGN(4); + . = . + _minimum_heap_size; + . = ALIGN(4); + } >RAM + + /* this just checks there is enough RAM for the stack */ + .stack : + { + . = ALIGN(4); + . = . + _minimum_stack_size; + . = ALIGN(4); + } >RAM + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/ports/stm32f4/boards/startup_stm32f407xx.s b/ports/stm32f4/boards/startup_stm32f407xx.s new file mode 100644 index 0000000000..6b77655ca1 --- /dev/null +++ b/ports/stm32f4/boards/startup_stm32f407xx.s @@ -0,0 +1,516 @@ +/** + ****************************************************************************** + * @file startup_stm32f405xx.s + * @author MCD Application Team + * @brief STM32F405xx Devices vector table for GCC based toolchains. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ +/* bl __libc_init_array */ +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word CAN1_TX_IRQHandler /* CAN1 TX */ + .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ + .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ + .word CAN1_SCE_IRQHandler /* CAN1 SCE */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FSMC_IRQHandler /* FSMC */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word CAN2_TX_IRQHandler /* CAN2 TX */ + .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ + .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ + .word CAN2_SCE_IRQHandler /* CAN2 SCE */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + .word FPU_IRQHandler /* FPU */ + + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak CAN1_TX_IRQHandler + .thumb_set CAN1_TX_IRQHandler,Default_Handler + + .weak CAN1_RX0_IRQHandler + .thumb_set CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FSMC_IRQHandler + .thumb_set FSMC_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak CAN2_TX_IRQHandler + .thumb_set CAN2_TX_IRQHandler,Default_Handler + + .weak CAN2_RX0_IRQHandler + .thumb_set CAN2_RX0_IRQHandler,Default_Handler + + .weak CAN2_RX1_IRQHandler + .thumb_set CAN2_RX1_IRQHandler,Default_Handler + + .weak CAN2_SCE_IRQHandler + .thumb_set CAN2_SCE_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + + diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk index 9bdc624044..312a20f65a 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.mk @@ -11,8 +11,8 @@ LONGINT_IMPL = NONE # other than the camera and ethernet, which aren't supported. MCU_SERIES = m4 MCU_VARIANT = stm32f4 -MCU_SUB_VARIANT = stm32f405xx +MCU_SUB_VARIANT = stm32f407xx MCU_PACKAGE = 100 -CMSIS_MCU = STM32F405xx -LD_FILE = boards/STM32F405_fs.ld +CMSIS_MCU = STM32F407xx +LD_FILE = boards/STM32F407_fs.ld diff --git a/ports/stm32f4/peripherals/stm32f4/periph.h b/ports/stm32f4/peripherals/stm32f4/periph.h index ac98b89320..969a8e79b7 100644 --- a/ports/stm32f4/peripherals/stm32f4/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/periph.h @@ -166,4 +166,10 @@ typedef struct { #include "stm32f405xx/periph.h" #endif +#ifdef STM32F407xx +#define HAS_DAC 1 +#define HAS_TRNG 1 +#include "stm32f407xx/periph.h" +#endif + #endif // __MICROPY_INCLUDED_STM32F4_PERIPHERALS_PERIPH_H__ diff --git a/ports/stm32f4/peripherals/stm32f4/pins.h b/ports/stm32f4/peripherals/stm32f4/pins.h index e6a32b64e1..44ef4c1baf 100644 --- a/ports/stm32f4/peripherals/stm32f4/pins.h +++ b/ports/stm32f4/peripherals/stm32f4/pins.h @@ -89,5 +89,8 @@ extern const mp_obj_type_t mcu_pin_type; #ifdef STM32F405xx #include "stm32f405xx/pins.h" #endif +#ifdef STM32F407xx +#include "stm32f407xx/pins.h" +#endif #endif // __MICROPY_INCLUDED_STM32F4_PERIPHERALS_PINS_H__ diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f407xx/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/clocks.c new file mode 100644 index 0000000000..2afca64e83 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/clocks.c @@ -0,0 +1,64 @@ + +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" +#include "py/mpconfig.h" + +void stm32f4_peripherals_clocks_init(void) { + //TODO: All parameters must be moved to board level, due to relationship with HSE Osc. + + //System clock init + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = BOARD_OSC_DIV; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); +} diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f407xx/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/gpio.c new file mode 100644 index 0000000000..f9be3b4ec2 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/gpio.c @@ -0,0 +1,56 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "stm32f4xx_hal.h" +#include "stm32f4/gpio.h" +#include "common-hal/microcontroller/Pin.h" + +void stm32f4_peripherals_gpio_init(void) { + //Enable all GPIO for now + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + + //Never reset pins + never_reset_pin_number(2,13); //PC13 anti tamp + never_reset_pin_number(2,14); //PC14 OSC32_IN + never_reset_pin_number(2,15); //PC15 OSC32_OUT + never_reset_pin_number(0,13); //PA13 SWDIO + never_reset_pin_number(0,14); //PA14 SWCLK + // never_reset_pin_number(0,15); //PA15 JTDI + // never_reset_pin_number(1,3); //PB3 JTDO + // never_reset_pin_number(1,4); //PB4 JTRST + + // Port H is not included in GPIO port array + // never_reset_pin_number(5,0); //PH0 JTDO + // never_reset_pin_number(5,1); //PH1 JTRST +} + +void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { + +} + + diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.c new file mode 100644 index 0000000000..bc03f7c7be --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.c @@ -0,0 +1,194 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" +#include "py/mphal.h" +#include "stm32f4/pins.h" +#include "stm32f4/periph.h" + +// I2C + +I2C_TypeDef * mcu_i2c_banks[3] = {I2C1, I2C2, I2C3}; + +const mcu_i2c_sda_obj_t mcu_i2c_sda_list[4] = { + I2C_SDA(1, 4, &pin_PB07), + I2C_SDA(1, 4, &pin_PB09), + I2C_SDA(2, 4, &pin_PB11), + I2C_SDA(3, 4, &pin_PC09), +}; + +const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { + I2C_SCL(1, 4, &pin_PB06), + I2C_SCL(1, 4, &pin_PB08), + I2C_SCL(2, 4, &pin_PB10), + I2C_SCL(3, 4, &pin_PA08) +}; + +SPI_TypeDef * mcu_spi_banks[3] = {SPI1, SPI2, SPI3}; + +const mcu_spi_sck_obj_t mcu_spi_sck_list[7] = { + SPI(1, 5, &pin_PA05), + SPI(1, 5, &pin_PB03), + SPI(2, 5, &pin_PB10), + SPI(2, 5, &pin_PB13), + SPI(2, 5, &pin_PC07), + SPI(3, 6, &pin_PB03), + SPI(3, 6, &pin_PC10), +}; + +const mcu_spi_mosi_obj_t mcu_spi_mosi_list[6] = { + SPI(1, 5, &pin_PA07), + SPI(1, 5, &pin_PB05), + SPI(2, 5, &pin_PB15), + SPI(2, 5, &pin_PC03), + SPI(3, 6, &pin_PB05), + SPI(3, 6, &pin_PC12), +}; + +const mcu_spi_miso_obj_t mcu_spi_miso_list[6] = { + SPI(1, 5, &pin_PA06), + SPI(1, 5, &pin_PB04), + SPI(2, 5, &pin_PB14), + SPI(2, 5, &pin_PC02), + SPI(3, 6, &pin_PB04), + SPI(3, 6, &pin_PC11), +}; + +const mcu_spi_nss_obj_t mcu_spi_nss_list[6] = { + SPI(1, 5, &pin_PA04), + SPI(1, 5, &pin_PA15), + SPI(2, 5, &pin_PB09), + SPI(2, 5, &pin_PB12), + SPI(3, 6, &pin_PA04), + SPI(3, 6, &pin_PA15), +}; + +USART_TypeDef * mcu_uart_banks[MAX_UART] = {USART1, USART2, USART3, UART4, UART5, USART6}; +bool mcu_uart_has_usart[MAX_UART] = {true, true, true, false, false, true}; + +const mcu_uart_tx_obj_t mcu_uart_tx_list[12] = { + UART(4, 8, &pin_PA00), + UART(2, 7, &pin_PA02), + UART(1, 7, &pin_PA09), + UART(1, 7, &pin_PB06), + UART(3, 7, &pin_PB10), + UART(6, 8, &pin_PC06), + UART(3, 7, &pin_PC10), + UART(4, 8, &pin_PC10), + UART(5, 8, &pin_PC12), + UART(2, 7, &pin_PD05), + UART(3, 7, &pin_PD08), + UART(6, 8, &pin_PG14), +}; + +const mcu_uart_rx_obj_t mcu_uart_rx_list[12] = { + UART(4, 8, &pin_PA01), + UART(2, 7, &pin_PA03), + UART(1, 7, &pin_PA10), + UART(1, 7, &pin_PB07), + UART(3, 7, &pin_PB11), + UART(6, 8, &pin_PC07), + UART(3, 7, &pin_PC11), + UART(4, 8, &pin_PC11), + UART(5, 8, &pin_PD02), + UART(2, 7, &pin_PD06), + UART(3, 7, &pin_PD09), + UART(6, 8, &pin_PG09), +}; + +//Timers +//TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins +TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, TIM8, TIM9, TIM10, + TIM11, TIM12, TIM13, TIM14}; + +const mcu_tim_pin_obj_t mcu_tim_pin_list[56] = { + TIM(2,1,1,&pin_PA00), + TIM(5,2,1,&pin_PA00), + TIM(2,1,2,&pin_PA01), + TIM(5,2,2,&pin_PA01), + TIM(2,1,3,&pin_PA02), + TIM(5,2,3,&pin_PA02), + TIM(2,1,4,&pin_PA03), + TIM(5,2,4,&pin_PA03), + TIM(9,3,1,&pin_PA02), + TIM(9,3,2,&pin_PA03), + TIM(3,2,1,&pin_PA06), + TIM(13,9,1,&pin_PA06), + TIM(3,2,2,&pin_PA07), + TIM(14,9,1,&pin_PA07), + TIM(1,1,1,&pin_PA08), + TIM(1,1,2,&pin_PA09), + TIM(1,1,3,&pin_PA10), + TIM(1,1,4,&pin_PA11), + TIM(2,1,1,&pin_PA15), + TIM(3,2,3,&pin_PB00), + TIM(3,2,4,&pin_PB01), + TIM(2,1,2,&pin_PB03), + TIM(3,2,1,&pin_PB04), + TIM(3,2,2,&pin_PB05), + TIM(4,2,1,&pin_PB06), + TIM(4,2,2,&pin_PB07), + TIM(4,2,3,&pin_PB08), + TIM(10,2,1,&pin_PB08), + TIM(4,2,4,&pin_PB09), + TIM(11,2,1,&pin_PB09), + TIM(2,1,3,&pin_PB10), + TIM(2,1,4,&pin_PB11), + TIM(12,9,1,&pin_PB14), + TIM(12,9,2,&pin_PB15), + TIM(3,2,1,&pin_PC06), + TIM(3,2,2,&pin_PC07), + TIM(3,2,3,&pin_PC08), + TIM(3,2,4,&pin_PC09), + TIM(8,3,1,&pin_PC06), + TIM(8,3,2,&pin_PC07), + TIM(8,3,3,&pin_PC08), + TIM(8,3,4,&pin_PC09), + TIM(4,2,1,&pin_PD12), + TIM(4,2,2,&pin_PD13), + TIM(4,2,3,&pin_PD14), + TIM(4,2,4,&pin_PD15), + TIM(9,3,1,&pin_PE05), + TIM(9,3,2,&pin_PE06), + TIM(1,1,1,&pin_PE09), + TIM(1,1,2,&pin_PE11), + TIM(1,1,3,&pin_PE13), + TIM(1,1,4,&pin_PE14), + TIM(10,3,1,&pin_PF06), + TIM(11,3,1,&pin_PF07), + TIM(13,9,1,&pin_PF08), + TIM(14,9,1,&pin_PF09), + // TIM(12,9,1,&pin_PH06), //TODO: include these when pin map is expanded + // TIM(12,9,2,&pin_PH09), + // TIM(5,2,1,&pin_PH10), + // TIM(5,2,2,&pin_PH11), + // TIM(5,2,3,&pin_PH12), + // TIM(5,2,4,&pin_PI00), + // TIM(8,3,4,&pin_PI02), + // TIM(8,3,1,&pin_PI05), + // TIM(8,3,2,&pin_PI06), + // TIM(8,3,3,&pin_PI07), +}; diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.h new file mode 100644 index 0000000000..e87e798574 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/periph.h @@ -0,0 +1,57 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F405XX_PERIPH_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F405XX_PERIPH_H + +//I2C +extern I2C_TypeDef * mcu_i2c_banks[3]; + +extern const mcu_i2c_sda_obj_t mcu_i2c_sda_list[4]; +extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; + +//SPI +extern SPI_TypeDef * mcu_spi_banks[3]; + +extern const mcu_spi_sck_obj_t mcu_spi_sck_list[7]; +extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[6]; +extern const mcu_spi_miso_obj_t mcu_spi_miso_list[6]; +extern const mcu_spi_nss_obj_t mcu_spi_nss_list[6]; + +//UART +extern USART_TypeDef * mcu_uart_banks[MAX_UART]; +extern bool mcu_uart_has_usart[MAX_UART]; + +extern const mcu_uart_tx_obj_t mcu_uart_tx_list[12]; +extern const mcu_uart_rx_obj_t mcu_uart_rx_list[12]; + +//Timers +#define TIM_BANK_ARRAY_LEN 14 +#define TIM_PIN_ARRAY_LEN 56 +TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN]; +const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F405XX_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.c new file mode 100644 index 0000000000..86445fe140 --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.c @@ -0,0 +1,161 @@ + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland 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 "py/obj.h" +#include "py/mphal.h" +#include "stm32f4/pins.h" + +const mcu_pin_obj_t pin_PE02 = PIN(4, 2, NO_ADC); +const mcu_pin_obj_t pin_PE03 = PIN(4, 3, NO_ADC); +const mcu_pin_obj_t pin_PE04 = PIN(4, 4, NO_ADC); +const mcu_pin_obj_t pin_PE05 = PIN(4, 5, NO_ADC); +const mcu_pin_obj_t pin_PE06 = PIN(4, 6, NO_ADC); + +const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); //anti-tamp +const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); //OSC32_IN +const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); //OSC32_OUT + +const mcu_pin_obj_t pin_PF00 = PIN(5, 0, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PF01 = PIN(5, 1, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PF02 = PIN(5, 2, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PF03 = PIN(5, 3, ADC_INPUT(ADC_3,9)); // 144 only +const mcu_pin_obj_t pin_PF04 = PIN(5, 4, ADC_INPUT(ADC_3,14)); // 144 only +const mcu_pin_obj_t pin_PF05 = PIN(5, 5, ADC_INPUT(ADC_3,15)); // 144 only +const mcu_pin_obj_t pin_PF06 = PIN(5, 6, ADC_INPUT(ADC_3,4)); // 144 only +const mcu_pin_obj_t pin_PF07 = PIN(5, 7, ADC_INPUT(ADC_3,5)); // 144 only +const mcu_pin_obj_t pin_PF08 = PIN(5, 8, ADC_INPUT(ADC_3,6)); // 144 only +const mcu_pin_obj_t pin_PF09 = PIN(5, 9, ADC_INPUT(ADC_3,7)); // 144 only +const mcu_pin_obj_t pin_PF10 = PIN(5, 10, ADC_INPUT(ADC_3,8)); // 144 only + +const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_123,10)); +const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_123,11)); +const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_123,12)); +const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_123,13)); + +const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_123,0)); +const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_123,1)); +const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_123,2)); +const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_123,3)); +const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_12,4)); +const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_12,5)); +const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_12,6)); +const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_12,7)); + +const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_12,14)); +const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_12,15)); + +const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_12,8)); +const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_12,9)); +const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); //BOOT1 + +const mcu_pin_obj_t pin_PF11 = PIN(5, 11, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PF12 = PIN(5, 12, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PF13 = PIN(5, 13, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PF14 = PIN(5, 14, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PF15 = PIN(5, 15, NO_ADC); // 144 only + +const mcu_pin_obj_t pin_PG00 = PIN(6, 0, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG01 = PIN(6, 1, NO_ADC); // 144 only + +const mcu_pin_obj_t pin_PE07 = PIN(4, 7, NO_ADC); +const mcu_pin_obj_t pin_PE08 = PIN(4, 8, NO_ADC); +const mcu_pin_obj_t pin_PE09 = PIN(4, 9, NO_ADC); +const mcu_pin_obj_t pin_PE10 = PIN(4, 10, NO_ADC); +const mcu_pin_obj_t pin_PE11 = PIN(4, 11, NO_ADC); +const mcu_pin_obj_t pin_PE12 = PIN(4, 12, NO_ADC); +const mcu_pin_obj_t pin_PE13 = PIN(4, 13, NO_ADC); +const mcu_pin_obj_t pin_PE14 = PIN(4, 14, NO_ADC); +const mcu_pin_obj_t pin_PE15 = PIN(4, 15, NO_ADC); + +const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); +const mcu_pin_obj_t pin_PB11 = PIN(1, 11, NO_ADC); +const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); +const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); +const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); +const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); + +const mcu_pin_obj_t pin_PD08 = PIN(3, 8, NO_ADC); +const mcu_pin_obj_t pin_PD09 = PIN(3, 9, NO_ADC); +const mcu_pin_obj_t pin_PD10 = PIN(3, 10, NO_ADC); +const mcu_pin_obj_t pin_PD11 = PIN(3, 11, NO_ADC); +const mcu_pin_obj_t pin_PD12 = PIN(3, 12, NO_ADC); +const mcu_pin_obj_t pin_PD13 = PIN(3, 13, NO_ADC); +const mcu_pin_obj_t pin_PD14 = PIN(3, 14, NO_ADC); +const mcu_pin_obj_t pin_PD15 = PIN(3, 15, NO_ADC); + +const mcu_pin_obj_t pin_PG02 = PIN(6, 2, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG03 = PIN(6, 3, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG04 = PIN(6, 4, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG05 = PIN(6, 5, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG06 = PIN(6, 6, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG07 = PIN(6, 7, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG08 = PIN(6, 8, NO_ADC); // 144 only + +const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); +const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); +const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); +const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); + +const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); +const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); +const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); +const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); +const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); +const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); +const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); +const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); + +const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); +const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); +const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); + +const mcu_pin_obj_t pin_PD00 = PIN(3, 0, NO_ADC); +const mcu_pin_obj_t pin_PD01 = PIN(3, 1, NO_ADC); +const mcu_pin_obj_t pin_PD02 = PIN(3, 2, NO_ADC); +const mcu_pin_obj_t pin_PD03 = PIN(3, 3, NO_ADC); +const mcu_pin_obj_t pin_PD04 = PIN(3, 4, NO_ADC); +const mcu_pin_obj_t pin_PD05 = PIN(3, 5, NO_ADC); +const mcu_pin_obj_t pin_PD06 = PIN(3, 6, NO_ADC); +const mcu_pin_obj_t pin_PD07 = PIN(3, 7, NO_ADC); + +const mcu_pin_obj_t pin_PG09 = PIN(6, 9, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG10 = PIN(6, 10, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG11 = PIN(6, 11, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG12 = PIN(6, 12, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG13 = PIN(6, 13, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG14 = PIN(6, 14, NO_ADC); // 144 only +const mcu_pin_obj_t pin_PG15 = PIN(6, 15, NO_ADC); // 144 only + +const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); +const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); +const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); +const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); +const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); +const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); +const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); + +const mcu_pin_obj_t pin_PE00 = PIN(4, 0, NO_ADC); +const mcu_pin_obj_t pin_PE01 = PIN(4, 1, NO_ADC); diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.h new file mode 100644 index 0000000000..180f5c316f --- /dev/null +++ b/ports/stm32f4/peripherals/stm32f4/stm32f407xx/pins.h @@ -0,0 +1,158 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F412ZG_PINS_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F412ZG_PINS_H + +//Pins in datasheet order: DocID028087 Rev 7 page 50. LQFP100 only +//pg 50 +extern const mcu_pin_obj_t pin_PE02; +extern const mcu_pin_obj_t pin_PE03; +extern const mcu_pin_obj_t pin_PE04; +extern const mcu_pin_obj_t pin_PE05; +extern const mcu_pin_obj_t pin_PE06; +extern const mcu_pin_obj_t pin_PC13; +extern const mcu_pin_obj_t pin_PC14; +//pg 51 +extern const mcu_pin_obj_t pin_PC15; +extern const mcu_pin_obj_t pin_PF00; // 144 only +extern const mcu_pin_obj_t pin_PF01; // 144 only +extern const mcu_pin_obj_t pin_PF02; // 144 only +extern const mcu_pin_obj_t pin_PF03; // 144 only +extern const mcu_pin_obj_t pin_PF04; // 144 only +extern const mcu_pin_obj_t pin_PF05; // 144 only +extern const mcu_pin_obj_t pin_PF06; // 144 only +extern const mcu_pin_obj_t pin_PF07; // 144 only +extern const mcu_pin_obj_t pin_PF08; // 144 only +extern const mcu_pin_obj_t pin_PF09; // 144 only +extern const mcu_pin_obj_t pin_PF10; // 144 only +//pg 52 +extern const mcu_pin_obj_t pin_PC00; +extern const mcu_pin_obj_t pin_PC01; +extern const mcu_pin_obj_t pin_PC02; +extern const mcu_pin_obj_t pin_PC03; +extern const mcu_pin_obj_t pin_PA00; +extern const mcu_pin_obj_t pin_PA01; +extern const mcu_pin_obj_t pin_PA02; +//pg 53 +extern const mcu_pin_obj_t pin_PA03; +extern const mcu_pin_obj_t pin_PA04; +extern const mcu_pin_obj_t pin_PA05; +extern const mcu_pin_obj_t pin_PA06; +extern const mcu_pin_obj_t pin_PA07; +extern const mcu_pin_obj_t pin_PC04; +//pg 54 +extern const mcu_pin_obj_t pin_PC05; +extern const mcu_pin_obj_t pin_PB00; +extern const mcu_pin_obj_t pin_PB01; +extern const mcu_pin_obj_t pin_PB02; +extern const mcu_pin_obj_t pin_PF11; // 144 only +extern const mcu_pin_obj_t pin_PF12; // 144 only +extern const mcu_pin_obj_t pin_PF13; // 144 only +extern const mcu_pin_obj_t pin_PF14; // 144 only +extern const mcu_pin_obj_t pin_PF15; // 144 only +extern const mcu_pin_obj_t pin_PG00; // 144 only +extern const mcu_pin_obj_t pin_PG01; // 144 only +//pg 55 +extern const mcu_pin_obj_t pin_PE07; +extern const mcu_pin_obj_t pin_PE08; +extern const mcu_pin_obj_t pin_PE09; +extern const mcu_pin_obj_t pin_PE10; +extern const mcu_pin_obj_t pin_PE11; +extern const mcu_pin_obj_t pin_PE12; +extern const mcu_pin_obj_t pin_PE13; +extern const mcu_pin_obj_t pin_PE14; +//pg 56 +extern const mcu_pin_obj_t pin_PE15; +extern const mcu_pin_obj_t pin_PB10; +extern const mcu_pin_obj_t pin_PB11; // 144 only +extern const mcu_pin_obj_t pin_PB12; +extern const mcu_pin_obj_t pin_PB13; +//pg 57 +extern const mcu_pin_obj_t pin_PB14; +extern const mcu_pin_obj_t pin_PB15; +extern const mcu_pin_obj_t pin_PD08; +extern const mcu_pin_obj_t pin_PD09; +extern const mcu_pin_obj_t pin_PD10; +extern const mcu_pin_obj_t pin_PD11; +extern const mcu_pin_obj_t pin_PD12; +//pg 58 +extern const mcu_pin_obj_t pin_PD13; +extern const mcu_pin_obj_t pin_PD14; +extern const mcu_pin_obj_t pin_PD15; +extern const mcu_pin_obj_t pin_PG02; // 144 only +extern const mcu_pin_obj_t pin_PG03; // 144 only +extern const mcu_pin_obj_t pin_PG04; // 144 only +extern const mcu_pin_obj_t pin_PG05; // 144 only +extern const mcu_pin_obj_t pin_PG06; // 144 only +extern const mcu_pin_obj_t pin_PG07; // 144 only +extern const mcu_pin_obj_t pin_PG08; // 144 only +//pg 59 +extern const mcu_pin_obj_t pin_PC06; +extern const mcu_pin_obj_t pin_PC07; +extern const mcu_pin_obj_t pin_PC08; +extern const mcu_pin_obj_t pin_PC09; +extern const mcu_pin_obj_t pin_PA08; +extern const mcu_pin_obj_t pin_PA09; +extern const mcu_pin_obj_t pin_PA10; +//pg 60 +extern const mcu_pin_obj_t pin_PA11; +extern const mcu_pin_obj_t pin_PA12; +extern const mcu_pin_obj_t pin_PA13; +extern const mcu_pin_obj_t pin_PA14; +extern const mcu_pin_obj_t pin_PA15; +extern const mcu_pin_obj_t pin_PC10; +extern const mcu_pin_obj_t pin_PC11; +//pg 61 +extern const mcu_pin_obj_t pin_PC12; +extern const mcu_pin_obj_t pin_PD00; +extern const mcu_pin_obj_t pin_PD01; +extern const mcu_pin_obj_t pin_PD02; +extern const mcu_pin_obj_t pin_PD03; +extern const mcu_pin_obj_t pin_PD04; +extern const mcu_pin_obj_t pin_PD05; +extern const mcu_pin_obj_t pin_PD06; +extern const mcu_pin_obj_t pin_PD07; +//pg 62 +extern const mcu_pin_obj_t pin_PG09; // 144 only +extern const mcu_pin_obj_t pin_PG10; // 144 only +extern const mcu_pin_obj_t pin_PG11; // 144 only +extern const mcu_pin_obj_t pin_PG12; // 144 only +extern const mcu_pin_obj_t pin_PG13; // 144 only +extern const mcu_pin_obj_t pin_PG14; // 144 only +extern const mcu_pin_obj_t pin_PG15; // 144 only +extern const mcu_pin_obj_t pin_PB03; +extern const mcu_pin_obj_t pin_PB04; +//pg 63 +extern const mcu_pin_obj_t pin_PB05; +extern const mcu_pin_obj_t pin_PB06; +extern const mcu_pin_obj_t pin_PB07; +extern const mcu_pin_obj_t pin_PB08; +extern const mcu_pin_obj_t pin_PB09; +extern const mcu_pin_obj_t pin_PE00; +extern const mcu_pin_obj_t pin_PE01; + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F412ZG_PINS_H diff --git a/ports/stm32f4/supervisor/internal_flash.h b/ports/stm32f4/supervisor/internal_flash.h index 8991fb8aa0..9f16a799d8 100644 --- a/ports/stm32f4/supervisor/internal_flash.h +++ b/ports/stm32f4/supervisor/internal_flash.h @@ -52,6 +52,11 @@ #define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB #endif +#ifdef STM32F407xx +#define STM32_FLASH_SIZE 0x100000 //1MB +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB +#endif + #define STM32_FLASH_OFFSET 0x8000000 //All STM32 chips map to this flash location #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 From 842fe54c83d9a2144cec592a3f8fcc519ab33d01 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 10 Feb 2020 18:35:25 -0800 Subject: [PATCH 476/531] remove no-longer-needed exclude --- conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conf.py b/conf.py index 4ea4ba4e80..3b29986c06 100644 --- a/conf.py +++ b/conf.py @@ -156,7 +156,6 @@ exclude_patterns = ["**/build*", "ports/zephyr", "py", "shared-bindings/util.*", - "shared-bindings/_eve/mod_eve-gen.h", "shared-module", "supervisor", "tests", From 1f44029c560bef1fc3ce140ebe10512ed378561c Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 10 Feb 2020 18:57:04 -0800 Subject: [PATCH 477/531] Remove unused code --- shared-bindings/_eve/__init__.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index d3076afbfa..8ea9d033f2 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -900,8 +900,6 @@ STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); -#define N_METHODS 49 -#define METHOD_SETUP do { stem_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_AlphaFunc), MP_OBJ_FROM_PTR(&alphafunc_obj) }; stem_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Begin), MP_OBJ_FROM_PTR(&begin_obj) }; stem_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapExtFormat), MP_OBJ_FROM_PTR(&bitmapextformat_obj) }; stem_locals_dict_table[3] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapHandle), MP_OBJ_FROM_PTR(&bitmaphandle_obj) }; stem_locals_dict_table[4] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayoutH), MP_OBJ_FROM_PTR(&bitmaplayouth_obj) }; stem_locals_dict_table[5] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapLayout), MP_OBJ_FROM_PTR(&bitmaplayout_obj) }; stem_locals_dict_table[6] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSizeH), MP_OBJ_FROM_PTR(&bitmapsizeh_obj) }; stem_locals_dict_table[7] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSize), MP_OBJ_FROM_PTR(&bitmapsize_obj) }; stem_locals_dict_table[8] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSource), MP_OBJ_FROM_PTR(&bitmapsource_obj) }; stem_locals_dict_table[9] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapSwizzle), MP_OBJ_FROM_PTR(&bitmapswizzle_obj) }; stem_locals_dict_table[10] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformA), MP_OBJ_FROM_PTR(&bitmaptransforma_obj) }; stem_locals_dict_table[11] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformB), MP_OBJ_FROM_PTR(&bitmaptransformb_obj) }; stem_locals_dict_table[12] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformC), MP_OBJ_FROM_PTR(&bitmaptransformc_obj) }; stem_locals_dict_table[13] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformD), MP_OBJ_FROM_PTR(&bitmaptransformd_obj) }; stem_locals_dict_table[14] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformE), MP_OBJ_FROM_PTR(&bitmaptransforme_obj) }; stem_locals_dict_table[15] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BitmapTransformF), MP_OBJ_FROM_PTR(&bitmaptransformf_obj) }; stem_locals_dict_table[16] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_BlendFunc), MP_OBJ_FROM_PTR(&blendfunc_obj) }; stem_locals_dict_table[17] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Call), MP_OBJ_FROM_PTR(&call_obj) }; stem_locals_dict_table[18] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Cell), MP_OBJ_FROM_PTR(&cell_obj) }; stem_locals_dict_table[19] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorA), MP_OBJ_FROM_PTR(&clearcolora_obj) }; stem_locals_dict_table[20] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearColorRGB), MP_OBJ_FROM_PTR(&clearcolorrgb_obj) }; stem_locals_dict_table[21] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Clear), MP_OBJ_FROM_PTR(&clear_obj) }; stem_locals_dict_table[22] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearStencil), MP_OBJ_FROM_PTR(&clearstencil_obj) }; stem_locals_dict_table[23] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ClearTag), MP_OBJ_FROM_PTR(&cleartag_obj) }; stem_locals_dict_table[24] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorA), MP_OBJ_FROM_PTR(&colora_obj) }; stem_locals_dict_table[25] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorMask), MP_OBJ_FROM_PTR(&colormask_obj) }; stem_locals_dict_table[26] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ColorRGB), MP_OBJ_FROM_PTR(&colorrgb_obj) }; stem_locals_dict_table[27] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Display), MP_OBJ_FROM_PTR(&display_obj) }; stem_locals_dict_table[28] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_End), MP_OBJ_FROM_PTR(&end_obj) }; stem_locals_dict_table[29] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Jump), MP_OBJ_FROM_PTR(&jump_obj) }; stem_locals_dict_table[30] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_LineWidth), MP_OBJ_FROM_PTR(&linewidth_obj) }; stem_locals_dict_table[31] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Macro), MP_OBJ_FROM_PTR(¯o_obj) }; stem_locals_dict_table[32] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Nop), MP_OBJ_FROM_PTR(&nop_obj) }; stem_locals_dict_table[33] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PaletteSource), MP_OBJ_FROM_PTR(&palettesource_obj) }; stem_locals_dict_table[34] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_PointSize), MP_OBJ_FROM_PTR(&pointsize_obj) }; stem_locals_dict_table[35] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_RestoreContext), MP_OBJ_FROM_PTR(&restorecontext_obj) }; stem_locals_dict_table[36] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Return), MP_OBJ_FROM_PTR(&return_obj) }; stem_locals_dict_table[37] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_SaveContext), MP_OBJ_FROM_PTR(&savecontext_obj) }; stem_locals_dict_table[38] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorSize), MP_OBJ_FROM_PTR(&scissorsize_obj) }; stem_locals_dict_table[39] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_ScissorXY), MP_OBJ_FROM_PTR(&scissorxy_obj) }; stem_locals_dict_table[40] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilFunc), MP_OBJ_FROM_PTR(&stencilfunc_obj) }; stem_locals_dict_table[41] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilMask), MP_OBJ_FROM_PTR(&stencilmask_obj) }; stem_locals_dict_table[42] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_StencilOp), MP_OBJ_FROM_PTR(&stencilop_obj) }; stem_locals_dict_table[43] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_TagMask), MP_OBJ_FROM_PTR(&tagmask_obj) }; stem_locals_dict_table[44] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Tag), MP_OBJ_FROM_PTR(&tag_obj) }; stem_locals_dict_table[45] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateX), MP_OBJ_FROM_PTR(&vertextranslatex_obj) }; stem_locals_dict_table[46] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexTranslateY), MP_OBJ_FROM_PTR(&vertextranslatey_obj) }; stem_locals_dict_table[47] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_VertexFormat), MP_OBJ_FROM_PTR(&vertexformat_obj) }; stem_locals_dict_table[48] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_Vertex2ii), MP_OBJ_FROM_PTR(&vertex2ii_obj) }; } while (0) #define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } //} @@ -1023,12 +1021,6 @@ STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(_EVE_locals_dict, _EVE_locals_dict_table); -STATIC void _EVE_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - (void)self_in; - (void)kind; - mp_printf(print, "<_EVE>"); -} - STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); @@ -1040,11 +1032,8 @@ STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp STATIC const mp_obj_type_t _EVE_type = { { &mp_type_type }, - // Save on qstr's, reuse same as for module .name = MP_QSTR__EVE, - .print = _EVE_print, .make_new = _EVE_make_new, - // .attr = _EVE_attr, .locals_dict = (void*)&_EVE_locals_dict, }; From a87dee2f66732690bde509e7d1221cce4c1fb466 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Mon, 10 Feb 2020 19:34:38 -0800 Subject: [PATCH 478/531] Correct the BitmapTransform operations. Correct argument order better argument naming fix copypaste bug on C and F arguments --- shared-bindings/_eve/__init__.c | 58 +++++++++++++++------------ shared-bindings/_eve/__init__.h | 12 +++--- shared-module/_eve/__init__.c | 71 +++++++++++++++++++++++++++------ 3 files changed, 97 insertions(+), 44 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 8ea9d033f2..97b4e8c479 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -268,13 +268,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizz //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`a` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 //| +//| The initial value is **p** = 0, **v** = 256. This represents the value 1.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t a = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformA(EVEHAL(self), a, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformA(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); @@ -286,33 +288,34 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`b` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 //| +//| The initial value is **p** = 0, **v** = 0. This represents the value 0.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t b = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformB(EVEHAL(self), b, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformB(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); -//| .. method:: BitmapTransformC(c) +//| .. method:: BitmapTransformC(v) //| //| Set the :math:`c` component of the bitmap transform matrix //| -//| :param int c: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| :param int v: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 //| //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| -STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t c = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformC(EVEHAL(self), c, p); +STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0) { + uint32_t v = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapTransformC(EVEHAL(self), v); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc); //| .. method:: BitmapTransformD(p, v) //| @@ -321,13 +324,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformc_obj, _bitmaptransformc); //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`d` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 0 //| +//| The initial value is **p** = 0, **v** = 0. This represents the value 0.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t d = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformD(EVEHAL(self), d, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformD(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); @@ -339,33 +344,34 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); //| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0 //| :param int v: The :math:`e` component of the bitmap transform matrix, in signed 8.8 or 1.15 bit fixed-point form. Range 0-131071. The initial value is 256 //| +//| The initial value is **p** = 0, **v** = 256. This represents the value 1.0. +//| //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t e = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformE(EVEHAL(self), e, p); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); + common_hal__eve_BitmapTransformE(EVEHAL(self), p, v); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); -//| .. method:: BitmapTransformF(f) +//| .. method:: BitmapTransformF(v) //| //| Set the :math:`f` component of the bitmap transform matrix //| -//| :param int f: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 +//| :param int v: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0 //| //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| -STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t f = mp_obj_get_int_truncated(a0); - uint32_t p = mp_obj_get_int_truncated(a1); - common_hal__eve_BitmapTransformF(EVEHAL(self), f, p); +STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0) { + uint32_t v = mp_obj_get_int_truncated(a0); + common_hal__eve_BitmapTransformF(EVEHAL(self), v); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformf_obj, _bitmaptransformf); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformf_obj, _bitmaptransformf); //| .. method:: BlendFunc(src, dst) //| diff --git a/shared-bindings/_eve/__init__.h b/shared-bindings/_eve/__init__.h index 6287fb606a..759a629bbd 100644 --- a/shared-bindings/_eve/__init__.h +++ b/shared-bindings/_eve/__init__.h @@ -41,12 +41,12 @@ void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_ void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height); void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr); void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a); -void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p); -void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p); -void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p); -void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p); -void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p); -void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p); +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t v); +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t p, uint32_t v); +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t v); void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst); void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest); void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell); diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c index ca6fd4031b..2c93eb69f7 100644 --- a/shared-module/_eve/__init__.c +++ b/shared-module/_eve/__init__.c @@ -80,190 +80,237 @@ void common_hal__eve_AlphaFunc(common_hal__eve_t *eve, uint32_t func, uint32_t r C4(eve, ((9 << 24) | ((func & 7) << 8) | ((ref & 255)))); } + void common_hal__eve_Begin(common_hal__eve_t *eve, uint32_t prim) { C4(eve, ((31 << 24) | ((prim & 15)))); } + void common_hal__eve_BitmapExtFormat(common_hal__eve_t *eve, uint32_t fmt) { C4(eve, ((46 << 24) | (fmt & 65535))); } + void common_hal__eve_BitmapHandle(common_hal__eve_t *eve, uint32_t handle) { C4(eve, ((5 << 24) | ((handle & 31)))); } + void common_hal__eve_BitmapLayoutH(common_hal__eve_t *eve, uint32_t linestride, uint32_t height) { C4(eve, ((40 << 24) | (((linestride) & 3) << 2) | (((height) & 3)))); } + void common_hal__eve_BitmapLayout(common_hal__eve_t *eve, uint32_t format, uint32_t linestride, uint32_t height) { C4(eve, ((7 << 24) | ((format & 31) << 19) | ((linestride & 1023) << 9) | ((height & 511)))); } + void common_hal__eve_BitmapSizeH(common_hal__eve_t *eve, uint32_t width, uint32_t height) { C4(eve, ((41 << 24) | (((width) & 3) << 2) | (((height) & 3)))); } + void common_hal__eve_BitmapSize(common_hal__eve_t *eve, uint32_t filter, uint32_t wrapx, uint32_t wrapy, uint32_t width, uint32_t height) { C4(eve, ((8 << 24) | ((filter & 1) << 20) | ((wrapx & 1) << 19) | ((wrapy & 1) << 18) | ((width & 511) << 9) | ((height & 511)))); } + void common_hal__eve_BitmapSource(common_hal__eve_t *eve, uint32_t addr) { C4(eve, ((1 << 24) | ((addr & 0xffffff)))); } + void common_hal__eve_BitmapSwizzle(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { C4(eve, ((47 << 24) | ((r & 7) << 9) | ((g & 7) << 6) | ((b & 7) << 3) | ((a & 7)))); } -void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t a, uint32_t p) { - C4(eve, ((21 << 24) | ((p & 1) << 17) | ((a & 131071)))); + +void common_hal__eve_BitmapTransformA(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((21 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t b, uint32_t p) { - C4(eve, ((22 << 24) | ((p & 1) << 17) | ((b & 131071)))); + +void common_hal__eve_BitmapTransformB(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((22 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t c, uint32_t p) { - C4(eve, ((23 << 24) | ((p & 1) << 17) | ((c & 16777215)))); + +void common_hal__eve_BitmapTransformC(common_hal__eve_t *eve, uint32_t v) { + C4(eve, ((23 << 24) | ((v & 16777215)))); } -void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t d, uint32_t p) { - C4(eve, ((24 << 24) | ((p & 1) << 17) | ((d & 131071)))); + +void common_hal__eve_BitmapTransformD(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((24 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t e, uint32_t p) { - C4(eve, ((25 << 24) | ((p & 1) << 17) | ((e & 131071)))); + +void common_hal__eve_BitmapTransformE(common_hal__eve_t *eve, uint32_t p, uint32_t v) { + C4(eve, ((25 << 24) | ((p & 1) << 17) | ((v & 131071)))); } -void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t f, uint32_t p) { - C4(eve, ((26 << 24) | ((p & 1) << 17) | ((f & 16777215)))); + +void common_hal__eve_BitmapTransformF(common_hal__eve_t *eve, uint32_t v) { + C4(eve, ((26 << 24) | ((v & 16777215)))); } + void common_hal__eve_BlendFunc(common_hal__eve_t *eve, uint32_t src, uint32_t dst) { C4(eve, ((11 << 24) | ((src & 7) << 3) | ((dst & 7)))); } + void common_hal__eve_Call(common_hal__eve_t *eve, uint32_t dest) { C4(eve, ((29 << 24) | ((dest & 65535)))); } + void common_hal__eve_Cell(common_hal__eve_t *eve, uint32_t cell) { C4(eve, ((6 << 24) | ((cell & 127)))); } + void common_hal__eve_ClearColorA(common_hal__eve_t *eve, uint32_t alpha) { C4(eve, ((15 << 24) | ((alpha & 255)))); } + void common_hal__eve_ClearColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { C4(eve, ((2 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); } + void common_hal__eve_Clear(common_hal__eve_t *eve, uint32_t c, uint32_t s, uint32_t t) { C4(eve, ((38 << 24) | ((c & 1) << 2) | ((s & 1) << 1) | ((t & 1)))); } + void common_hal__eve_ClearStencil(common_hal__eve_t *eve, uint32_t s) { C4(eve, ((17 << 24) | ((s & 255)))); } + void common_hal__eve_ClearTag(common_hal__eve_t *eve, uint32_t s) { C4(eve, ((18 << 24) | ((s & 255)))); } + void common_hal__eve_ColorA(common_hal__eve_t *eve, uint32_t alpha) { C4(eve, ((16 << 24) | ((alpha & 255)))); } + void common_hal__eve_ColorMask(common_hal__eve_t *eve, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { C4(eve, ((32 << 24) | ((r & 1) << 3) | ((g & 1) << 2) | ((b & 1) << 1) | ((a & 1)))); } + void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t green, uint32_t blue) { C4(eve, ((4 << 24) | ((red & 255) << 16) | ((green & 255) << 8) | ((blue & 255)))); } + void common_hal__eve_Display(common_hal__eve_t *eve) { C4(eve, ((0 << 24))); } + void common_hal__eve_End(common_hal__eve_t *eve) { C4(eve, ((33 << 24))); } + void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest) { C4(eve, ((30 << 24) | ((dest & 65535)))); } + void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width) { C4(eve, ((14 << 24) | ((width & 4095)))); } + void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m) { C4(eve, ((37 << 24) | ((m & 1)))); } + void common_hal__eve_Nop(common_hal__eve_t *eve) { C4(eve, ((45 << 24))); } + void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr) { C4(eve, ((42 << 24) | (((addr) & 4194303)))); } + void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size) { C4(eve, ((13 << 24) | ((size & 8191)))); } + void common_hal__eve_RestoreContext(common_hal__eve_t *eve) { C4(eve, ((35 << 24))); } + void common_hal__eve_Return(common_hal__eve_t *eve) { C4(eve, ((36 << 24))); } + void common_hal__eve_SaveContext(common_hal__eve_t *eve) { C4(eve, ((34 << 24))); } + void common_hal__eve_ScissorSize(common_hal__eve_t *eve, uint32_t width, uint32_t height) { C4(eve, ((28 << 24) | ((width & 4095) << 12) | ((height & 4095)))); } + void common_hal__eve_ScissorXY(common_hal__eve_t *eve, uint32_t x, uint32_t y) { C4(eve, ((27 << 24) | ((x & 2047) << 11) | ((y & 2047)))); } + void common_hal__eve_StencilFunc(common_hal__eve_t *eve, uint32_t func, uint32_t ref, uint32_t mask) { C4(eve, ((10 << 24) | ((func & 7) << 16) | ((ref & 255) << 8) | ((mask & 255)))); } + void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask) { C4(eve, ((19 << 24) | ((mask & 255)))); } + void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass) { C4(eve, ((12 << 24) | ((sfail & 7) << 3) | ((spass & 7)))); } + void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask) { C4(eve, ((20 << 24) | ((mask & 1)))); } + void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s) { C4(eve, ((3 << 24) | ((s & 255)))); } + void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x) { C4(eve, ((43 << 24) | (((x) & 131071)))); } + void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y) { C4(eve, ((44 << 24) | (((y) & 131071)))); } + void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell) { C4(eve, ((2 << 30) | (((x) & 511) << 21) | (((y) & 511) << 12) | (((handle) & 31) << 7) | (((cell) & 127) << 0))); } From f3e4fbd7bacf609292fdf49e3fa7f70b97e81bac Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Tue, 11 Feb 2020 23:01:08 +0000 Subject: [PATCH 479/531] Add directly loadable binary target --- ports/mimxrt10xx/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index 66a540a402..9303089f96 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -220,7 +220,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o)) SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) -all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex +all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex $(BUILD)/firmware-bootable.bin $(BUILD)/firmware.elf: $(OBJ) $(LD_FILES) $(STEPECHO) "LINK $@" @@ -237,6 +237,10 @@ $(BUILD)/firmware.uf2: $(BUILD)/firmware.bin $(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 $< $@ +$(BUILD)/firmware-bootable.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 $< $@ + include $(TOP)/py/mkrules.mk # Print out the value of a make variable. From 2e029d55fc0396a33fcf8ac73124f571aea34eee Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 11 Feb 2020 19:19:31 -0500 Subject: [PATCH 480/531] nrf: add SPIM3 support --- locale/circuitpython.pot | 2 +- ports/nrf/boards/common.template.ld | 8 +++- ports/nrf/common-hal/busio/SPI.c | 72 ++++++++++++++++++++++------- ports/nrf/common-hal/busio/SPI.h | 2 +- ports/nrf/nrfx_config.h | 18 ++++---- shared-bindings/busio/SPI.c | 7 +++ 6 files changed, 79 insertions(+), 30 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 3e44130688..1a378e3319 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-07 10:02-0500\n" +"POT-Creation-Date: 2020-02-11 19:18-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index 607a1dc938..427b6b35b3 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -22,7 +22,9 @@ MEMORY /* SoftDevice 6.1.0 with 5 connections and various increases takes just under 64kiB. /* To measure the minimum required amount of memory for given configuration, set this number high enough to work and then check the mutation of the value done by sd_ble_enable. */ - RAM (xrw) : ORIGIN = 0x20000000 + 64K, LENGTH = 256K - 64K + SPIM3_RAM (rw) : ORIGIN = 0x20000000 + 64K, LENGTH = 8K + RAM (xrw) : ORIGIN = 0x20000000 + 64K + 8K, LENGTH = 256K - 64K -8K + } /* produce a link error if there is not this amount of RAM available */ @@ -37,6 +39,10 @@ _estack = ORIGIN(RAM) + LENGTH(RAM); _ram_end = ORIGIN(RAM) + LENGTH(RAM); _heap_end = 0x20020000; /* tunable */ +/* nrf52840 SPIM3 needs its own area to work around hardware problems. Nothing else may use this space. */ +_spim3_ram = ORIGIN(SPIM3_RAM); +_spim3_ram_end = ORIGIN(SPIM3_RAM) + LENGTH(RAM); + /* define output sections */ SECTIONS { diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index 8e1d73bf0e..fe943a2215 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -22,6 +22,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "shared-bindings/busio/SPI.h" #include "py/mperrno.h" #include "py/runtime.h" @@ -29,33 +31,34 @@ #include "nrfx_spim.h" #include "nrf_gpio.h" +// These are in order from ighest available frequency to lowest (32MHz first, then 8MHz). STATIC spim_peripheral_t spim_peripherals[] = { #if NRFX_CHECK(NRFX_SPIM3_ENABLED) // SPIM3 exists only on nRF52840 and supports 32MHz max. All other SPIM's are only 8MHz max. // Allocate SPIM3 first. { .spim = NRFX_SPIM_INSTANCE(3), - .max_frequency_MHz = 32, + .max_frequency = 32000000, .max_xfer_size = SPIM3_EASYDMA_MAXCNT_SIZE, }, #endif #if NRFX_CHECK(NRFX_SPIM2_ENABLED) // SPIM2 is not shared with a TWIM, so allocate before the shared ones. { .spim = NRFX_SPIM_INSTANCE(2), - .max_frequency_MHz = 8, + .max_frequency = 8000000, .max_xfer_size = SPIM2_EASYDMA_MAXCNT_SIZE, }, #endif #if NRFX_CHECK(NRFX_SPIM1_ENABLED) // SPIM1 and TWIM1 share an address. { .spim = NRFX_SPIM_INSTANCE(1), - .max_frequency_MHz = 8, + .max_frequency = 8000000, .max_xfer_size = SPIM1_EASYDMA_MAXCNT_SIZE, }, #endif #if NRFX_CHECK(NRFX_SPIM0_ENABLED) // SPIM0 and TWIM0 share an address. { .spim = NRFX_SPIM_INSTANCE(0), - .max_frequency_MHz = 8, + .max_frequency = 8000000, .max_xfer_size = SPIM0_EASYDMA_MAXCNT_SIZE, }, #endif @@ -63,6 +66,11 @@ STATIC spim_peripheral_t spim_peripherals[] = { STATIC bool never_reset[MP_ARRAY_SIZE(spim_peripherals)]; +// Separate RAM area for SPIM3 transmit buffer to avoid SPIM3 hardware errata. +// https://infocenter.nordicsemi.com/index.jsp?topic=%2Ferrata_nRF52840_Rev2%2FERR%2FnRF52840%2FRev2%2Flatest%2Fanomaly_840_198.html +extern uint32_t _spim3_ram; +STATIC uint8_t *spim3_transmit_buffer = (uint8_t *) &_spim3_ram; + void spi_reset(void) { for (size_t i = 0 ; i < MP_ARRAY_SIZE(spim_peripherals); i++) { if (never_reset[i]) { @@ -122,7 +130,7 @@ static nrf_spim_frequency_t baudrate_to_spim_frequency(const uint32_t baudrate) } void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi, const mcu_pin_obj_t * miso) { - // Find a free instance. + // Find a free instance, with most desirable (highest freq and not shared) allocated first. self->spim_peripheral = NULL; for (size_t i = 0 ; i < MP_ARRAY_SIZE(spim_peripherals); i++) { if ((spim_peripherals[i].spim.p_reg->ENABLE & SPIM_ENABLE_ENABLE_Msk) == 0) { @@ -137,7 +145,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG(NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED); - config.frequency = NRF_SPIM_FREQ_8M; + + config.frequency = baudrate_to_spim_frequency(self->spim_peripheral->max_frequency); config.sck_pin = clock->number; self->clock_pin_number = clock->number; @@ -189,8 +198,7 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, uint32_t baudrate, ui // Set desired frequency, rounding down, and don't go above available frequency for this SPIM. nrf_spim_frequency_set(self->spim_peripheral->spim.p_reg, - baudrate_to_spim_frequency(MIN(baudrate, - self->spim_peripheral->max_frequency_MHz * 1000000))); + baudrate_to_spim_frequency(MIN(baudrate, self->spim_peripheral->max_frequency))); nrf_spim_mode_t mode = NRF_SPIM_MODE_0; if (polarity) { @@ -224,21 +232,36 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { } bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { - if (len == 0) + if (len == 0) { return true; + } + + const bool is_spim3 = self->spim_peripheral->spim.p_reg == NRF_SPIM3; const uint32_t max_xfer_size = self->spim_peripheral->max_xfer_size; const uint32_t parts = len / max_xfer_size; const uint32_t remainder = len % max_xfer_size; for (uint32_t i = 0; i < parts; ++i) { - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TX(data + i * max_xfer_size, max_xfer_size); + uint8_t *start = (uint8_t *) (data + i * max_xfer_size); + if (is_spim3) { + // If SPIM3, copy into unused RAM block, and do DMA from there. + memcpy(spim3_transmit_buffer, start, max_xfer_size); + start = spim3_transmit_buffer; + } + const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TX(start, max_xfer_size); if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) return false; } if (remainder > 0) { - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TX(data + parts * max_xfer_size, remainder); + uint8_t *start = (uint8_t *) (data + parts * max_xfer_size); + if (is_spim3) { + // If SPIM3, copy into unused RAM block, and do DMA from there. + memcpy(spim3_transmit_buffer, start, remainder); + start = spim3_transmit_buffer; + } + const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TX(start, remainder); if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) return false; } @@ -247,8 +270,9 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size } bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { - if (len == 0) + if (len == 0) { return true; + } const uint32_t max_xfer_size = self->spim_peripheral->max_xfer_size; const uint32_t parts = len / max_xfer_size; @@ -270,23 +294,37 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, } bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) { - if (len == 0) + if (len == 0) { return true; + } + const bool is_spim3 = self->spim_peripheral->spim.p_reg == NRF_SPIM3; const uint32_t max_xfer_size = self->spim_peripheral->max_xfer_size; const uint32_t parts = len / max_xfer_size; const uint32_t remainder = len % max_xfer_size; for (uint32_t i = 0; i < parts; ++i) { - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_SINGLE_XFER(data_out + i * max_xfer_size, max_xfer_size, + uint8_t *out_start = (uint8_t *) (data_out + i * max_xfer_size); + if (is_spim3) { + // If SPIM3, copy into unused RAM block, and do DMA from there. + memcpy(spim3_transmit_buffer, out_start, max_xfer_size); + out_start = spim3_transmit_buffer; + } + const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_SINGLE_XFER(out_start, max_xfer_size, data_in + i * max_xfer_size, max_xfer_size); if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) return false; } if (remainder > 0) { - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_SINGLE_XFER(data_out + parts * max_xfer_size, remainder, + uint8_t *out_start = (uint8_t *) (data_out + parts * max_xfer_size); + if (is_spim3) { + // If SPIM3, copy into unused RAM block, and do DMA from there. + memcpy(spim3_transmit_buffer, out_start, remainder); + out_start = spim3_transmit_buffer; + } + const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_SINGLE_XFER(out_start, remainder, data_in + parts * max_xfer_size, remainder); if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) return false; @@ -325,9 +363,9 @@ uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t* self) { } uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t* self) { - return 0; + return (self->spim_peripheral->spim.p_reg->CONFIG & SPIM_CONFIG_CPHA_Msk) >> SPIM_CONFIG_CPHA_Pos; } uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) { - return 0; + return (self->spim_peripheral->spim.p_reg->CONFIG & SPIM_CONFIG_CPOL_Msk) >> SPIM_CONFIG_CPOL_Pos; } diff --git a/ports/nrf/common-hal/busio/SPI.h b/ports/nrf/common-hal/busio/SPI.h index 1b0de8acfd..738a1de788 100644 --- a/ports/nrf/common-hal/busio/SPI.h +++ b/ports/nrf/common-hal/busio/SPI.h @@ -32,7 +32,7 @@ typedef struct { nrfx_spim_t spim; - uint8_t max_frequency_MHz; + uint32_t max_frequency; uint8_t max_xfer_size; } spim_peripheral_t; diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index 82f6514dfa..e37c609340 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -26,10 +26,9 @@ // CIRCUITPY_NRF_NUM_I2C is 1 or 2 to choose how many I2C (TWIM) peripherals // to provide. -// This can go away once we have SPIM3 working: then we can have two -// I2C and two SPI. +// With SPIM3 working we can have two I2C and two SPI. #ifndef CIRCUITPY_NRF_NUM_I2C -#define CIRCUITPY_NRF_NUM_I2C 1 +#define CIRCUITPY_NRF_NUM_I2C 2 #endif #if CIRCUITPY_NRF_NUM_I2C != 1 && CIRCUITPY_NRF_NUM_I2C != 2 @@ -42,13 +41,12 @@ #define NRFX_SPIM1_ENABLED 1 #endif #define NRFX_SPIM2_ENABLED 1 -// DON'T ENABLE SPIM3 DUE TO ANOMALY WORKAROUND FAILURE (SEE ABOVE). -// #ifdef NRF52840_XXAA -// #define NRFX_SPIM_EXTENDED_ENABLED 1 -// #define NRFX_SPIM3_ENABLED 1 -// #else -// #define NRFX_SPIM3_ENABLED 0 -// #endif +#ifdef NRF52840_XXAA + #define NRFX_SPIM_EXTENDED_ENABLED 1 + #define NRFX_SPIM3_ENABLED 1 +#else + #define NRFX_SPIM3_ENABLED 0 +#endif #define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 7 diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index d1791bef3b..2ae312a359 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -56,6 +56,13 @@ //| .. class:: SPI(clock, MOSI=None, MISO=None) //| //| Construct an SPI object on the given pins. + +//| ..note:: The SPI peripherals allocated in order of desirability, if possible, +//| such as highest speed and not shared use first. For instance, on the nRF52840, +//| there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, +//| some of which may also be used for I2C. The 32MHz SPI peripheral is returned +//| first, then the exclusive 8MHz SPI peripheral, and finally the shared 8MHz +//| peripherals. //| //| .. seealso:: Using this class directly requires careful lock management. //| Instead, use :class:`~adafruit_bus_device.spi_device.SPIDevice` to From f73b58a2c67187635c5c9d8d7113f289acf78031 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 11 Feb 2020 19:57:48 -0500 Subject: [PATCH 481/531] fix doc indentation --- shared-bindings/busio/SPI.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 2ae312a359..07b93c0227 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -57,7 +57,7 @@ //| //| Construct an SPI object on the given pins. -//| ..note:: The SPI peripherals allocated in order of desirability, if possible, +//| ..note:: The SPI peripherals allocated in order of desirability, if possible, //| such as highest speed and not shared use first. For instance, on the nRF52840, //| there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, //| some of which may also be used for I2C. The 32MHz SPI peripheral is returned From c57ccd5eb4d40ec5262aacb5eb1e16fd6157a652 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 11 Feb 2020 20:03:47 -0500 Subject: [PATCH 482/531] doc typo --- shared-bindings/busio/SPI.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 07b93c0227..828ffb8d00 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -56,7 +56,7 @@ //| .. class:: SPI(clock, MOSI=None, MISO=None) //| //| Construct an SPI object on the given pins. - +//| //| ..note:: The SPI peripherals allocated in order of desirability, if possible, //| such as highest speed and not shared use first. For instance, on the nRF52840, //| there is a single 32MHz SPI peripheral, and multiple 8MHz peripherals, From a4d197a6efeb8af9fc59be95689b2c703c5f9cdb Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 11 Feb 2020 17:05:43 -0800 Subject: [PATCH 483/531] Update gc tracking instructions and gdb commands. --- tools/gc_activity.md | 2 +- tools/gc_activity_between_collects.py | 141 ++++++++++++++++++++++++++ tools/output_gc_until_repl.txt | 15 ++- 3 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 tools/gc_activity_between_collects.py diff --git a/tools/gc_activity.md b/tools/gc_activity.md index d1a4c28031..686d9b6b7b 100644 --- a/tools/gc_activity.md +++ b/tools/gc_activity.md @@ -13,7 +13,7 @@ correct port. GDB is usually :3333 and JLink is :2331. Now, run gdb from your port directory: ``` -arm-none-eabi-gdb -x ../tools/output_gc_until_repl.txt build-metro_m0_express/firmware.elf +arm-none-eabi-gdb -x ../../tools/output_gc_until_repl.txt build-metro_m0_express/firmware.elf ``` This will take a little time while it breaks, backtraces and continues for every diff --git a/tools/gc_activity_between_collects.py b/tools/gc_activity_between_collects.py new file mode 100644 index 0000000000..c02c479f9a --- /dev/null +++ b/tools/gc_activity_between_collects.py @@ -0,0 +1,141 @@ +import sys +import json + +# Map start block to current allocation info. +current_heap = {} +allocation_history = [] +root = {} + +def change_root(trace, size): + level = root + for frame in reversed(trace): + file_location = frame[1] + if file_location not in level: + level[file_location] = {"blocks": 0, + "file": file_location, + "function": frame[2], + "subcalls": {}} + level[file_location]["blocks"] += size + level = level[file_location]["subcalls"] + +total_actions = 0 +non_single_block_streak = 0 +max_nsbs = 0 +last_action = None +last_total_actions = 0 +count = 0 +actions = {} +last_ticks_ms = 0 +ticks_ms = 0 +block_sizes = {} +allocation_sources = {} +with open(sys.argv[1], "r") as f: + for line in f: + if not line.strip(): + break + for line in f: + action = None + if line.startswith("Breakpoint 2"): + break + next(f) # throw away breakpoint code line + # print(next(f)) # first frame + block = 0 + size = 0 + trace = [] + for line in f: + # print(line.strip()) + if line[0] == "#": + frame = line.strip().split() + if frame[1].startswith("0x"): + trace.append((frame[1], frame[-1], frame[3])) + else: + trace.append(("0x0", frame[-1], frame[1])) + elif line[0] == "$": + #print(line.strip().split()[-1]) + block = int(line.strip().split()[-1][2:], 16) + next_line = next(f) + size = int(next_line.strip().split()[-1][2:], 16) + # next_line = next(f) + # ticks_ms = int(next_line.strip().split()[-1][2:], 16) + if not line.strip(): + break + + action = "unknown" + if block not in current_heap: + current_heap[block] = {"start_block": block, "size": size, "start_trace": trace, "start_time": total_actions} + action = "alloc" + if size == 1: + max_nsbs = max(max_nsbs, non_single_block_streak) + non_single_block_streak = 0 + else: + non_single_block_streak += 1 + #change_root(trace, size) + if size not in block_sizes: + block_sizes[size] = 0 + source = trace[-1][-1] + if source not in allocation_sources: + print(trace) + allocation_sources[source] = 0 + allocation_sources[source] += 1 + block_sizes[size] += 1 + else: + alloc = current_heap[block] + alloc["end_trace"] = trace + alloc["end_time"] = total_actions + change_root(alloc["start_trace"], -1 * alloc["size"]) + if size > 0: + action = "realloc" + current_heap[block] = {"start_block": block, "size": size, "start_trace": trace, "start_time": total_actions} + #change_root(trace, size) + else: + action = "free" + if trace[0][2] == "gc_sweep": + action = "sweep" + non_single_block_streak = 0 + if (trace[3][2] == "py_gc_collect" or (trace[3][2] == "gc_deinit" and count > 1)) and last_action != "sweep": + print(ticks_ms - last_ticks_ms, total_actions - last_total_actions, "gc.collect", max_nsbs) + print(actions) + print(block_sizes) + print(allocation_sources) + actions = {} + block_sizes = {} + allocation_sources = {} + if count % 2 == 0: + print() + count += 1 + last_total_actions = total_actions + last_ticks_ms = ticks_ms + max_nsbs = 0 + del current_heap[block] + alloc["end_cause"] = action + allocation_history.append(alloc) + if action not in actions: + actions[action] = 0 + actions[action] += 1 + last_action = action + #print(total_actions, non_single_block_streak, action, block, size) + total_actions += 1 +print(actions) +print(max_nsbs) +print() + +for alloc in current_heap.values(): + alloc["end_trace"] = "" + alloc["end_time"] = total_actions + allocation_history.append(alloc) + +def print_frame(frame, indent=0): + for key in sorted(frame): + if not frame[key]["blocks"] or key.startswith("../py/malloc.c") or key.startswith("../py/gc.c"): + continue + print(" " * (indent - 1), key, frame[key]["function"], frame[key]["blocks"], "blocks") + print_frame(frame[key]["subcalls"], indent + 2) + +# print_frame(root) +# total_blocks = 0 +# for key in sorted(root): +# total_blocks += root[key]["blocks"] +# print(total_blocks, "total blocks") + +# with open("allocation_history.json", "w") as f: +# json.dump(allocation_history, f) diff --git a/tools/output_gc_until_repl.txt b/tools/output_gc_until_repl.txt index 81711deeb8..1c124de801 100644 --- a/tools/output_gc_until_repl.txt +++ b/tools/output_gc_until_repl.txt @@ -10,16 +10,23 @@ set logging on set remote hardware-breakpoint-limit 4 # gc log -break gc.c:103 +break gc.c:106 commands -backtrace p/x start_block p/x length -append binary memory ram.bin &_srelocate &_estack +p/x ticks_ms +# backtrace output redirect is currently broken in gdb so we use up instead. +# https://sourceware.org/bugzilla/show_bug.cgi?id=23439 +# backtrace +up +up +up +up +# append binary memory ram.bin &_srelocate &_estack continue end -break main.c:179 +break main.c:251 continue From 36e6cc8febf7f744f61772d29eed68d9ebb57200 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 11 Feb 2020 17:06:24 -0800 Subject: [PATCH 484/531] Track first free atb for multiple block sizes. This speeds up cases where no single block allocations happen while Python code is allocating other block sizes. --- py/gc.c | 81 +++++++++++++++++++++++++++++++-------------------- py/mpconfig.h | 8 +++++ py/mpstate.h | 2 +- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/py/gc.c b/py/gc.c index fef67f61bb..271bc94624 100755 --- a/py/gc.c +++ b/py/gc.c @@ -150,9 +150,13 @@ void gc_init(void *start, void *end) { #endif // Set first free ATB index to the start of the heap. - MP_STATE_MEM(gc_first_free_atb_index) = 0; + for (size_t i = 0; i < MICROPY_ATB_INDICES; i++) { + MP_STATE_MEM(gc_first_free_atb_index)[i] = 0; + } + // Set last free ATB index to the end of the heap. MP_STATE_MEM(gc_last_free_atb_index) = MP_STATE_MEM(gc_alloc_table_byte_len) - 1; + // Set the lowest long lived ptr to the end of the heap to start. This will be lowered as long // lived objects are allocated. MP_STATE_MEM(gc_lowest_long_lived_ptr) = (void*) PTR_FROM_BLOCK(MP_STATE_MEM(gc_alloc_table_byte_len * BLOCKS_PER_ATB)); @@ -387,7 +391,9 @@ void gc_collect_root(void **ptrs, size_t len) { void gc_collect_end(void) { gc_deal_with_stack_overflow(); gc_sweep(); - MP_STATE_MEM(gc_first_free_atb_index) = 0; + for (size_t i = 0; i < MICROPY_ATB_INDICES; i++) { + MP_STATE_MEM(gc_first_free_atb_index)[i] = 0; + } MP_STATE_MEM(gc_last_free_atb_index) = MP_STATE_MEM(gc_alloc_table_byte_len) - 1; MP_STATE_MEM(gc_lock_depth)--; GC_EXIT(); @@ -513,14 +519,16 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived) { size_t crossover_block = BLOCK_FROM_PTR(MP_STATE_MEM(gc_lowest_long_lived_ptr)); while (keep_looking) { int8_t direction = 1; - size_t start = MP_STATE_MEM(gc_first_free_atb_index); + size_t bucket = MIN(n_blocks, MICROPY_ATB_INDICES) - 1; + size_t first_free = MP_STATE_MEM(gc_first_free_atb_index)[bucket]; + size_t start = first_free; if (long_lived) { direction = -1; start = MP_STATE_MEM(gc_last_free_atb_index); } n_free = 0; // look for a run of n_blocks available blocks - for (size_t i = start; keep_looking && MP_STATE_MEM(gc_first_free_atb_index) <= i && i <= MP_STATE_MEM(gc_last_free_atb_index); i += direction) { + for (size_t i = start; keep_looking && first_free <= i && i <= MP_STATE_MEM(gc_last_free_atb_index); i += direction) { byte a = MP_STATE_MEM(gc_alloc_table_start)[i]; // Four ATB states are packed into a single byte. int j = 0; @@ -565,22 +573,24 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived) { // Found free space ending at found_block inclusive. // Also, set last free ATB index to block after last block we found, for start of - // next scan. To reduce fragmentation, we only do this if we were looking - // for a single free block, which guarantees that there are no free blocks - // before this one. Also, whenever we free or shrink a block we must check - // if this index needs adjusting (see gc_realloc and gc_free). + // next scan. Also, whenever we free or shrink a block we must check if this index needs + // adjusting (see gc_realloc and gc_free). if (!long_lived) { end_block = found_block; start_block = found_block - n_free + 1; - if (n_blocks == 1) { - MP_STATE_MEM(gc_first_free_atb_index) = (found_block + 1) / BLOCKS_PER_ATB; + if (n_blocks < MICROPY_ATB_INDICES) { + size_t next_free_atb = (found_block + n_blocks) / BLOCKS_PER_ATB; + // Update all atb indices for larger blocks too. + for (size_t i = n_blocks - 1; i < MICROPY_ATB_INDICES; i++) { + MP_STATE_MEM(gc_first_free_atb_index)[i] = next_free_atb; + } } } else { start_block = found_block; end_block = found_block + n_free - 1; - if (n_blocks == 1) { - MP_STATE_MEM(gc_last_free_atb_index) = (found_block - 1) / BLOCKS_PER_ATB; - } + // Always update the bounds of the long lived area because we assume it is contiguous. (It + // can still be reset by a sweep.) + MP_STATE_MEM(gc_last_free_atb_index) = (found_block - 1) / BLOCKS_PER_ATB; } #ifdef LOG_HEAP_ACTIVITY @@ -676,30 +686,37 @@ void gc_free(void *ptr) { } // get the GC block number corresponding to this pointer assert(VERIFY_PTR(ptr)); - size_t block = BLOCK_FROM_PTR(ptr); - assert(ATB_GET_KIND(block) == AT_HEAD); + size_t start_block = BLOCK_FROM_PTR(ptr); + assert(ATB_GET_KIND(start_block) == AT_HEAD); #if MICROPY_ENABLE_FINALISER - FTB_CLEAR(block); + FTB_CLEAR(start_block); #endif - // set the last_free pointer to this block if it's earlier in the heap - if (block / BLOCKS_PER_ATB < MP_STATE_MEM(gc_first_free_atb_index)) { - MP_STATE_MEM(gc_first_free_atb_index) = block / BLOCKS_PER_ATB; - } - if (block / BLOCKS_PER_ATB > MP_STATE_MEM(gc_last_free_atb_index)) { - MP_STATE_MEM(gc_last_free_atb_index) = block / BLOCKS_PER_ATB; - } - // free head and all of its tail blocks - #ifdef LOG_HEAP_ACTIVITY - gc_log_change(block, 0); - #endif + #ifdef LOG_HEAP_ACTIVITY + gc_log_change(start_block, 0); + #endif + size_t block = start_block; do { ATB_ANY_TO_FREE(block); block += 1; } while (ATB_GET_KIND(block) == AT_TAIL); + // Update the first free pointer for our size only. Not much calls gc_free directly so there + // is decent chance we'll want to allocate this size again. By only updating the specific + // size we don't risk something smaller fitting in. + size_t n_blocks = block - start_block; + size_t bucket = MIN(n_blocks, MICROPY_ATB_INDICES) - 1; + size_t new_free_atb = start_block / BLOCKS_PER_ATB; + if (new_free_atb < MP_STATE_MEM(gc_first_free_atb_index)[bucket]) { + MP_STATE_MEM(gc_first_free_atb_index)[bucket] = new_free_atb; + } + // set the last_free pointer to this block if it's earlier in the heap + if (new_free_atb > MP_STATE_MEM(gc_last_free_atb_index)) { + MP_STATE_MEM(gc_last_free_atb_index) = new_free_atb; + } + GC_EXIT(); #if EXTENSIVE_HEAP_PROFILING @@ -870,11 +887,13 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) { } // set the last_free pointer to end of this block if it's earlier in the heap - if ((block + new_blocks) / BLOCKS_PER_ATB < MP_STATE_MEM(gc_first_free_atb_index)) { - MP_STATE_MEM(gc_first_free_atb_index) = (block + new_blocks) / BLOCKS_PER_ATB; + size_t new_free_atb = (block + new_blocks) / BLOCKS_PER_ATB; + size_t bucket = MIN(n_blocks - new_blocks, MICROPY_ATB_INDICES) - 1; + if (new_free_atb < MP_STATE_MEM(gc_first_free_atb_index)[bucket]) { + MP_STATE_MEM(gc_first_free_atb_index)[bucket] = new_free_atb; } - if ((block + new_blocks) / BLOCKS_PER_ATB > MP_STATE_MEM(gc_last_free_atb_index)) { - MP_STATE_MEM(gc_last_free_atb_index) = (block + new_blocks) / BLOCKS_PER_ATB; + if (new_free_atb > MP_STATE_MEM(gc_last_free_atb_index)) { + MP_STATE_MEM(gc_last_free_atb_index) = new_free_atb; } GC_EXIT(); diff --git a/py/mpconfig.h b/py/mpconfig.h index a0d211bfaa..1512c7d3a3 100755 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -244,6 +244,14 @@ #define alloca(x) m_malloc(x) #endif +// Number of atb indices to cache. Allocations of fewer blocks will be faster +// because the search will be accelerated by the index cache. This only applies +// to short lived allocations because we assume the long lived allocations are +// contiguous. +#ifndef MICROPY_ATB_INDICES +#define MICROPY_ATB_INDICES (8) +#endif + /*****************************************************************************/ /* MicroPython emitters */ diff --git a/py/mpstate.h b/py/mpstate.h index a3d7e5dccb..a5815776a4 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -92,7 +92,7 @@ typedef struct _mp_state_mem_t { size_t gc_alloc_threshold; #endif - size_t gc_first_free_atb_index; + size_t gc_first_free_atb_index[MICROPY_ATB_INDICES]; size_t gc_last_free_atb_index; #if MICROPY_PY_GC_COLLECT_RETVAL From 07708f15185d96930621493c3e2886cc2e948622 Mon Sep 17 00:00:00 2001 From: Gadi Rotenberg Date: Sun, 9 Feb 2020 13:25:16 +0200 Subject: [PATCH 485/531] Added fix to allow remount when usb enabled but msc is ejected --- shared-module/storage/__init__.c | 4 +--- supervisor/shared/usb/usb_msc_flash.c | 10 +++++++++- supervisor/usb.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index 215e1356a3..c3d4b50c8e 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -149,9 +149,7 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa } #ifdef USB_AVAILABLE - // TODO(dhalbert): is this is a good enough check? It checks for - // CDC enabled. There is no "MSC enabled" check. - if (usb_enabled()) { + if (!usb_msc_ejected()) { mp_raise_RuntimeError(translate("Cannot remount '/' when USB is active.")); } #endif diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index 0376cfc1df..c0279f9e5f 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -39,7 +39,7 @@ #define MSC_FLASH_BLOCK_SIZE 512 -static bool ejected[1]; +static bool ejected[1] = {true}; void usb_msc_mount(void) { // Reset the ejection tracking every time we're plugged into USB. This allows for us to battery @@ -53,6 +53,14 @@ void usb_msc_umount(void) { } +bool usb_msc_ejected(void) { + bool all_ejected = true; + for (uint8_t i = 0; i < sizeof(ejected); i++) { + all_ejected &= ejected[i]; + } + return all_ejected; +} + // The root FS is always at the end of the list. static fs_user_mount_t* get_vfs(int lun) { // TODO(tannewt): Return the mount which matches the lun where 0 is the end diff --git a/supervisor/usb.h b/supervisor/usb.h index 0cc361619d..29280c725b 100644 --- a/supervisor/usb.h +++ b/supervisor/usb.h @@ -44,5 +44,6 @@ void usb_init(void); // Propagate plug/unplug events to the MSC logic. void usb_msc_mount(void); void usb_msc_umount(void); +bool usb_msc_ejected(void); #endif // MICROPY_INCLUDED_SUPERVISOR_USB_H From d0870ce484e2f340b4816bfc3636ce4679d983ea Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Wed, 12 Feb 2020 09:03:11 +0000 Subject: [PATCH 486/531] Update main .bin output file to be bootable artefact --- ports/mimxrt10xx/Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index 9303089f96..80d1da1aac 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -220,7 +220,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o)) SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) -all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex $(BUILD)/firmware-bootable.bin +all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex $(BUILD)/firmware.elf: $(OBJ) $(LD_FILES) $(STEPECHO) "LINK $@" @@ -228,19 +228,17 @@ $(BUILD)/firmware.elf: $(OBJ) $(LD_FILES) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" - $(Q)$(OBJCOPY) -O binary -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@ + $(Q)$(OBJCOPY) -O binary -j .flash_config -j .ivt -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@ -$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin +$(BUILD)/firmware.uf2: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" - $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $^ + $(Q)$(OBJCOPY) -O binary -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@-binpart + $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $@-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 $< $@ -$(BUILD)/firmware-bootable.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 $< $@ - include $(TOP)/py/mkrules.mk # Print out the value of a make variable. From bfca65d86feed89bf64bc758368e2f871fdf8de2 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Wed, 12 Feb 2020 11:09:48 +0000 Subject: [PATCH 487/531] Allow drive name to be set per target, with fallback to pre-existing behaviour --- supervisor/shared/filesystem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index 3b799619f4..f6b94e38b5 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -104,7 +104,11 @@ void filesystem_init(bool create_allowed, bool force_create) { } // set label +#ifdef CIRCUITPY_DRIVE_LABEL + f_setlabel(&vfs_fat->fatfs, CIRCUITPY_DRIVE_LABEL); +#else f_setlabel(&vfs_fat->fatfs, "CIRCUITPY"); +#endif // inhibit file indexing on MacOS f_mkdir(&vfs_fat->fatfs, "/.fseventsd"); From 42ceb97f2ce12ee5363e7b6ad50a17bf7aabf9ae Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 12 Feb 2020 12:12:06 -0500 Subject: [PATCH 488/531] translation update --- locale/circuitpython.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 281fb4cb43..baf5bf5ae3 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-12 12:11-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From a7aa74efa32015919be1e8aefe92ea5112552275 Mon Sep 17 00:00:00 2001 From: hexthat Date: Thu, 6 Feb 2020 21:52:22 -0800 Subject: [PATCH 489/531] added translations just added missing translations --- locale/zh_Latn_pinyin.po | 174 +++++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 82 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 938f59cf73..d44da9c733 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-05 15:55-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -31,12 +31,17 @@ msgid "" "Please file an issue with the contents of your CIRCUITPY drive at \n" "https://github.com/adafruit/circuitpython/issues\n" msgstr "" +"\n" +"Qǐng tōngguò https://github.com/adafruit/circuitpython/issues\n" +"tíjiāo yǒuguān nín de CIRCUITPY qūdòngqì nèiróng de wèntí \n" #: supervisor/shared/safe_mode.c msgid "" "\n" "To exit, please reset the board without " msgstr "" +"\n" +"Qǐng zài méiyǒu _ de qíngkuàng xià chóng zhì bǎn zǐ yǐ tuìchū " #: py/obj.c msgid " File \"%q\"" @@ -138,6 +143,7 @@ msgstr "'%s' zhěngshù 0x%x bù shìyòng yú yǎn mǎ 0x%x" #: py/proto.c msgid "'%s' object does not support '%q'" msgstr "" +"'%s' duì xiàng bù zhīchí '%q'" #: py/obj.c #, c-format @@ -282,11 +288,11 @@ msgstr "Suǒyǒu jìshí qì shǐyòng" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." -msgstr "" +msgstr "Mùqián zhèngzài guǎngbò" #: ports/cxd56/common-hal/analogio/AnalogIn.c msgid "AnalogIn not supported on given pin" -msgstr "" +msgstr "Gěi dìng de yǐn jiǎo bù zhīchí AnalogIn" #: ports/cxd56/common-hal/analogio/AnalogOut.c #: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c @@ -317,7 +323,7 @@ msgstr "Shùzǔ zhí yīnggāi shì dāngè zì jié." #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "" +msgstr "MicroPython VM zài wèi yùnxíng shí chángshì fēnpèi duī." #: main.c msgid "Auto-reload is off.\n" @@ -362,7 +368,7 @@ msgstr "Liàngdù wúfǎ tiáozhěng" #: shared-bindings/_bleio/UUID.c #, c-format msgid "Buffer + offset too small %d %d %d" -msgstr "" +msgstr "Huǎnchōng qū hé piān yí liàng tài xiǎo %d %d %d" #: shared-module/usb_hid/Device.c #, c-format @@ -388,7 +394,7 @@ msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Buffer too large and unable to allocate" -msgstr "" +msgstr "huǎn chōng qū tài dà , wú fǎ fēn pèi" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c @@ -410,7 +416,7 @@ msgstr "Zài fǎngwèn běn jī wùjiàn zhīqián diàoyòng super().__init__() #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" -msgstr "" +msgstr "Wúfǎ jiāng CCCD shèzhì wéi běndì tèzhēng" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -428,7 +434,7 @@ msgstr "Wúfǎ huòqǔ wēndù" #: shared-bindings/_bleio/Adapter.c msgid "Cannot have scan responses for extended, connectable advertisements." -msgstr "" +msgstr "Nín wúfǎ sǎomiáo kuòzhǎn de, kě liánjiē de guǎnggào." #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" @@ -470,7 +476,7 @@ msgstr "Wúfǎ míngquè de huòdé biāoliàng de dàxiǎo" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Cannot vary frequency on a timer that is already in use" -msgstr "" +msgstr "Wúfǎ gēnggǎi yǐ zài shǐyòng de jìshí qì shàng de pínlǜ" #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." @@ -482,13 +488,15 @@ msgstr "Wèi tígōng zìfú huǎncún xiě rù" #: supervisor/shared/safe_mode.c msgid "CircuitPython core code crashed hard. Whoops!\n" -msgstr "" +msgstr "CircuitPython de héxīn chūxiàn gùzhàng. Āiyā!\n" #: supervisor/shared/safe_mode.c msgid "" "CircuitPython is in safe mode because you pressed the reset button during " "boot. Press again to exit safe mode.\n" msgstr "" +"CircuitPython chǔyú ānquán móshì, yīnwèi zài yǐndǎo guòchéng zhōng " +"àn xiàle chóng zhì ànniǔ. Zài àn yīcì tuìchū ānquán móshì.\n" #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." @@ -516,6 +524,7 @@ msgid "" "Connection has been disconnected and can no longer be used. Create a new " "connection." msgstr "" +"Liánjiē yǐ duàn kāi, wúfǎ zài shǐyòng. Chuàngjiàn yīgè xīn de liánjiē." #: py/persistentcode.c msgid "Corrupt .mpy file" @@ -531,35 +540,35 @@ msgstr "Wúfǎ chūshǐhuà UART" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Could not initialize channel" -msgstr "" +msgstr "Wúfǎ chūshǐhuà píndào" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Could not initialize timer" -msgstr "" +msgstr "Wúfǎ chūshǐhuà jìshí qì" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Could not re-init channel" -msgstr "" +msgstr "Wúfǎ chóngxīn chūshǐhuà píndào" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Could not re-init timer" -msgstr "" +msgstr "Wúfǎ chóngxīn qǐdòng jìshí qì" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Could not restart PWM" -msgstr "" +msgstr "Wúfǎ chóngqǐ PWM" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Could not start PWM" -msgstr "" +msgstr "Wúfǎ qǐdòng PWM" #: ports/stm32f4/common-hal/busio/UART.c msgid "Could not start interrupt, RX busy" -msgstr "" +msgstr "Wúfǎ qǐdòng zhōngduàn,RX máng" #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate decoder" -msgstr "" +msgstr "Zhǎo bù dào jiěmǎ qì" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3Decoder.c @@ -568,7 +577,7 @@ msgstr "Wúfǎ fēnpèi dì yī gè huǎnchōng qū" #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" -msgstr "" +msgstr "Wúfǎ fēnpèi shūrù huǎnchōng qū" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3Decoder.c @@ -577,15 +586,15 @@ msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū" #: supervisor/shared/safe_mode.c msgid "Crash into the HardFault_Handler." -msgstr "" +msgstr "Zhuìhuǐ. Shūrù HardFault_Handler." #: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "DAC Channel Init Error" -msgstr "" +msgstr "DAC tōngdào chūshǐhuà cuòwù" #: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "DAC Device Init Error" -msgstr "" +msgstr "DAC shèbèi chūshǐhuà cuòwù" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "DAC already in use" @@ -614,7 +623,7 @@ msgstr "Zhèngzài shǐyòng de shèbèi" #: ports/cxd56/common-hal/digitalio/DigitalInOut.c msgid "DigitalInOut not supported on given pin" -msgstr "" +msgstr "Gěi dìng de yǐn jiǎo bù zhīchí DigitalInOut" #: shared-bindings/displayio/Display.c msgid "Display must have a 16 bit colorspace." @@ -671,7 +680,7 @@ msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." -msgstr "" +msgstr "Bù zhīchí dài yǒu sǎomiáo xiǎngyìng de kuòzhǎn guǎngbò." #: shared-bindings/ps2io/Ps2.c msgid "Failed sending command." @@ -696,7 +705,7 @@ msgstr "Fēnpèi RX huǎnchōng qū%d zì jié shībài" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" -msgstr "" +msgstr "Liánjiē shībài: Nèibù cuòwù" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: timeout" @@ -704,7 +713,7 @@ msgstr "Liánjiē shībài: Chāoshí" #: shared-module/audiomp3/MP3Decoder.c msgid "Failed to parse MP3 file" -msgstr "" +msgstr "Wúfǎ jiěxī MP3 wénjiàn" #: ports/nrf/sd_mutex.c #, c-format @@ -713,7 +722,7 @@ msgstr "Wúfǎ shìfàng mutex, err 0x%04x" #: supervisor/shared/safe_mode.c msgid "Failed to write internal flash." -msgstr "" +msgstr "Wúfǎ xiě rù nèibù shǎncún." #: py/moduerrno.c msgid "File exists" @@ -725,7 +734,7 @@ msgstr "Pínlǜ bǔhuò gāo yú nénglì. Bǔhuò zàntíng." #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Frequency must match existing PWMOut using this timer" -msgstr "" +msgstr "Pínlǜ bìxū yǔ shǐyòng cǐ jìshí qì de xiàn yǒu PWMOut xiāng pǐpèi" #: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c #: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c @@ -743,11 +752,11 @@ msgstr "Fēnzǔ yǐ mǎn" #: ports/stm32f4/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/SPI.c msgid "Hardware busy, try alternative pins" -msgstr "" +msgstr "Yìngjiàn máng, qǐng chángshì qítā zhēnjiǎo" #: ports/stm32f4/common-hal/busio/UART.c msgid "Hardware in use, try alternative pins" -msgstr "" +msgstr "Shǐyòng de yìngjiàn, qǐng chángshì qítā yǐn jiǎo" #: extmod/vfs_posix_file.c py/objstringio.c msgid "I/O operation on closed file" @@ -755,7 +764,7 @@ msgstr "Wénjiàn shàng de I/ O cāozuò" #: ports/stm32f4/common-hal/busio/I2C.c msgid "I2C Init Error" -msgstr "" +msgstr "I2C chūshǐhuà cuòwù" #: extmod/machine_i2c.c msgid "I2C operation not supported" @@ -787,7 +796,7 @@ msgstr "Jiāmì bùzú" #: ports/stm32f4/common-hal/busio/UART.c msgid "Internal define error" -msgstr "" +msgstr "Nèibù dìngyì cuòwù" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -796,7 +805,7 @@ msgstr "Wúxiào de %q yǐn jiǎo" #: ports/stm32f4/common-hal/analogio/AnalogIn.c msgid "Invalid ADC Unit value" -msgstr "" +msgstr "Wúxiào de ADC dānwèi zhí" #: shared-module/displayio/OnDiskBitmap.c msgid "Invalid BMP file" @@ -804,11 +813,11 @@ msgstr "Wúxiào de BMP wénjiàn" #: ports/stm32f4/common-hal/analogio/AnalogOut.c msgid "Invalid DAC pin supplied" -msgstr "" +msgstr "Tí gōng liǎo wúxiào de DAC yǐn jiǎo" #: ports/mimxrt10xx/common-hal/busio/I2C.c ports/stm32f4/common-hal/busio/I2C.c msgid "Invalid I2C pin selection" -msgstr "" +msgstr "Wúxiào de I2C yǐn jiǎo xuǎnzé" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c #: ports/cxd56/common-hal/pulseio/PWMOut.c @@ -818,12 +827,12 @@ msgstr "Wúxiào de PWM pínlǜ" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm32f4/common-hal/busio/SPI.c msgid "Invalid SPI pin selection" -msgstr "" +msgstr "Wúxiào de SPI yǐn jiǎo xuǎnzé" #: ports/mimxrt10xx/common-hal/busio/UART.c #: ports/stm32f4/common-hal/busio/UART.c msgid "Invalid UART pin selection" -msgstr "" +msgstr "Wúxiào de UART yǐn jiǎo xuǎnzé" #: py/moduerrno.c msgid "Invalid argument" @@ -839,7 +848,7 @@ msgstr "Wúxiào de huǎnchōng qū dàxiǎo" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Invalid byteorder string" -msgstr "" +msgstr "Wúxiào de zì jié shùnxù zìfú chuàn" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" @@ -863,11 +872,11 @@ msgstr "Géshì kuài dàxiǎo wúxiào" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "Invalid frequency supplied" -msgstr "" +msgstr "Tígōng de pínlǜ wúxiào" #: supervisor/shared/safe_mode.c msgid "Invalid memory access." -msgstr "" +msgstr "Wúxiào de nèicún fǎngwèn." #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" @@ -931,7 +940,7 @@ msgstr "Wúxiào de làng làngcháo wénjiàn" #: ports/stm32f4/common-hal/busio/UART.c msgid "Invalid word/bit length" -msgstr "" +msgstr "Wúxiào de zì/wèi chángdù" #: py/compile.c msgid "LHS of keyword arg must be an id" @@ -968,11 +977,11 @@ msgstr "Jìngxiàng shí de zuìdà X zhí wèi%d" #: supervisor/shared/safe_mode.c msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" +msgstr "MicroPython NLR tiào zhuǎn shībài. Kěnéng shì nèicún sǔnhuài." #: supervisor/shared/safe_mode.c msgid "MicroPython fatal error." -msgstr "" +msgstr "MicroPython zhìmìng cuòwù." #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" @@ -980,7 +989,7 @@ msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi #: ports/stm32f4/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" -msgstr "" +msgstr "Quēshǎo MISO huò MOSI yǐn jiǎo" #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." @@ -988,11 +997,11 @@ msgstr "Bìxū shì %q zi lèi." #: ports/stm32f4/common-hal/busio/SPI.c msgid "Must provide MISO or MOSI pin" -msgstr "" +msgstr "Bìxū tígōng MISO huò MOSI yǐn jiǎo" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "Negative step not supported" -msgstr "" +msgstr "Bù zhīchí fù bù" #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" @@ -1010,11 +1019,11 @@ msgstr "Wèi zhǎodào DMA píndào" #: ports/stm32f4/common-hal/busio/SPI.c msgid "No MISO Pin" -msgstr "" +msgstr "Méiyǒu MISO yǐn jiǎo" #: ports/stm32f4/common-hal/busio/SPI.c msgid "No MOSI Pin" -msgstr "" +msgstr "Méiyǒu MOSI yǐn jiǎo" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c @@ -1055,7 +1064,7 @@ msgstr "Méiyǒu zài yǐn jiǎo shàng de yìngjiàn zhīchí" #: ports/stm32f4/common-hal/pulseio/PWMOut.c msgid "No more timers available on this pin." -msgstr "" +msgstr "Gāi yǐn jiǎo shàng méiyǒu kěyòng de dìngshí qì." #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" @@ -1071,7 +1080,7 @@ msgstr "Méiyǒu cǐ lèi wénjiàn/mùlù" #: supervisor/shared/safe_mode.c msgid "Nordic Soft Device failure assertion." -msgstr "" +msgstr "Nordic ruǎn shèbèi gùzhàng shēngmíng." #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c @@ -1111,6 +1120,8 @@ msgid "" "Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: " "%d bpp given" msgstr "" +"Jǐn zhīchí dān sè, suǒyǐn wéi 4bpp huò 8bpp yǐjí 16bpp huò gèng gāo de BMP: " +"Gěi chū %d bpp" #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." @@ -1129,7 +1140,7 @@ msgstr "Dāng biànliàng_pínlǜ shì False zài jiànzhú shí PWM pínlǜ bù #: ports/stm32f4/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" -msgstr "" +msgstr "Shàng bù zhīchí ParallelBus" #: py/moduerrno.c msgid "Permission denied" @@ -1153,7 +1164,7 @@ msgstr "Cóng kōng de Ps2 huǎnchōng qū dànchū" #: shared-bindings/_bleio/Adapter.c msgid "Prefix buffer must be on the heap" -msgstr "" +msgstr "Qiánzhuì huǎnchōng qū bìxū zài duī shàng" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload." @@ -1165,19 +1176,19 @@ msgstr "Fāngxiàng shūchū shí Pull méiyǒu shǐyòng." #: ports/stm32f4/common-hal/pulseio/PulseIn.c msgid "PulseIn not yet supported" -msgstr "" +msgstr "Shàng bù zhīchí PulseIn" #: ports/stm32f4/common-hal/pulseio/PulseOut.c msgid "PulseOut not yet supported" -msgstr "" +msgstr "Shàng bù zhīchí PulseOut" #: ports/stm32f4/common-hal/os/__init__.c msgid "RNG DeInit Error" -msgstr "" +msgstr "RNG qǔxiāo chūshǐhuà cuòwù" #: ports/stm32f4/common-hal/os/__init__.c msgid "RNG Init Error" -msgstr "" +msgstr "RNG chūshǐhuà cuòwù" #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c @@ -1190,7 +1201,7 @@ msgstr "Cǐ bǎn bù zhīchí RTC" #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" -msgstr "" +msgstr Suíjī shù shēngchéng cuòwù"" #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" @@ -1230,11 +1241,11 @@ msgstr "SDA huò SCL xūyào lādòng" #: ports/stm32f4/common-hal/busio/SPI.c msgid "SPI Init Error" -msgstr "" +msgstr "SPI chūshǐhuà cuòwù" #: ports/stm32f4/common-hal/busio/SPI.c msgid "SPI Re-initialization error" -msgstr "" +msgstr "SPI chóngxīn chūshǐhuà cuòwù" #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" @@ -1247,7 +1258,7 @@ msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." -msgstr "" +msgstr "Zhèngzài jìn háng sǎomiáo. Shǐyòng stop_scan tíngzhǐ." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -1277,17 +1288,15 @@ msgstr "Liú quēshǎo readinto() huò write() fāngfǎ." #: ports/stm32f4/common-hal/busio/UART.c msgid "Supply at least one UART pin" -msgstr "" - -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Temperature read timed out" -msgstr "" +msgstr "Dìngyì zhìshǎo yīgè UART yǐn jiǎo" #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" "Please increase the stack size if you know how, or if not:" msgstr "" +"Yóuyú duīzhàn tài xiǎo,CircuitPython duī yǐ sǔnhuài.\n" +"Rúguǒ nín zhīdào rúhé zēngjiā duīzhàn dàxiǎo, fǒuzé:" #: supervisor/shared/safe_mode.c msgid "" @@ -1303,6 +1312,9 @@ msgid "" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" +"wēi kòng zhì qì de gōng lǜ jiàng dī. Quèbǎo nín de diànyuán wèi zhěnggè\n" +"diànlù tígōng zúgòu de diànyuán, bìng àn xià fùwèi (Dànchū " +"CIRCUITPY zhīhòu).\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1360,23 +1372,23 @@ msgstr "Xūyào Tuple huò struct_time cānshù" #: ports/stm32f4/common-hal/busio/UART.c msgid "UART Buffer allocation error" -msgstr "" +msgstr "UART huǎnchōng qū fēnpèi cuòwù" #: ports/stm32f4/common-hal/busio/UART.c msgid "UART De-init error" -msgstr "" +msgstr "UART qǔxiāo chūshǐhuà cuòwù" #: ports/stm32f4/common-hal/busio/UART.c msgid "UART Init Error" -msgstr "" +msgstr "UART chūshǐhuà cuòwù" #: ports/stm32f4/common-hal/busio/UART.c msgid "UART Re-init error" -msgstr "" +msgstr "UART chóngxīn chūshǐhuà cuòwù" #: ports/stm32f4/common-hal/busio/UART.c msgid "UART write error" -msgstr "" +msgstr "UART xiě cuòwù" #: shared-module/usb_hid/Device.c msgid "USB Busy" @@ -1432,21 +1444,21 @@ msgstr "Yìwài de nrfx uuid lèixíng" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown gatt error: 0x%04x" -msgstr "" +msgstr "Wèizhī de gatt cuòwù: 0x%04x" #: supervisor/shared/safe_mode.c msgid "Unknown reason." -msgstr "" +msgstr "Yuányīn bùmíng." #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown security error: 0x%04x" -msgstr "" +msgstr "Wèizhī de ānquán cuòwù: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown soft device error: %04x" -msgstr "" +msgstr "Wèizhī de ruǎn shèbèi cuòwù: %04x" #: shared-bindings/_pixelbuf/PixelBuf.c #, c-format @@ -1458,6 +1470,8 @@ msgid "" "Unspecified issue. Can be that the pairing prompt on the other device was " "declined or ignored." msgstr "" +"Wèi zhǐdìng de wèntí. Kěnéng shì qítā shèbèi shàng de pèiduì tíshì bèi " +"jùjué huò hūlüè." #: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" @@ -1493,10 +1507,6 @@ msgstr "Zhí chángdù > zuìdà chángdù" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper hánshù mùqián bù zhīchí chāoguò 4 gè cānshù" -#: ports/stm32f4/common-hal/microcontroller/Processor.c -msgid "Voltage read timed out" -msgstr "" - #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Jǐnggào: Nǐ de dàimǎ wénjiàn míng yǒu liǎng gè kuòzhǎn míng\n" @@ -1518,11 +1528,11 @@ msgstr "" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" -msgstr "" +msgstr "Tèzhēng bù zhīchí xiě rù" #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" -msgstr "" +msgstr "Nín chǔyú ānquán móshì: Chū hū yìliào de shìqíng fāshēngle.\n" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -1654,7 +1664,7 @@ msgstr "zì jié dàimǎ wèi zhíxíng" #: shared-bindings/_pixelbuf/PixelBuf.c msgid "byteorder is not a string" -msgstr "" +msgstr "byteorder bùshì zìfú chuàn" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -1852,7 +1862,7 @@ msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a buffer, tuple, list, or int" -msgstr "" +msgstr "Yánsè huǎnchōng qū bìxū shì huǎnchōng qū, yuán zǔ, lièbiǎo huò zhěngshù" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" From 7831c475b9f38d8db8e2b8b62bc110f99185b8cb Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 12 Feb 2020 14:30:29 -0500 Subject: [PATCH 490/531] change flag styling --- ports/stm32f4/boards/espruino_pico/mpconfigboard.h | 4 ++-- ports/stm32f4/boards/espruino_wifi/mpconfigboard.h | 4 ++-- .../feather_stm32f405_express/mpconfigboard.h | 2 +- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 8 ++++---- ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h | 6 +++--- ports/stm32f4/boards/pyboard_v11/mpconfigboard.h | 1 - .../boards/stm32f411ce_blackpill/mpconfigboard.h | 8 ++++---- .../boards/stm32f411ve_discovery/mpconfigboard.h | 2 +- ports/stm32f4/mpconfigport.h | 14 ++++++++++++++ .../stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c | 2 +- ports/stm32f4/supervisor/usb.c | 2 +- ports/stm32f4/system_stm32f4xx.c | 2 +- shared-module/displayio/__init__.c | 2 +- 13 files changed, 35 insertions(+), 22 deletions(-) diff --git a/ports/stm32f4/boards/espruino_pico/mpconfigboard.h b/ports/stm32f4/boards/espruino_pico/mpconfigboard.h index aa179c7931..d4430380c6 100644 --- a/ports/stm32f4/boards/espruino_pico/mpconfigboard.h +++ b/ports/stm32f4/boards/espruino_pico/mpconfigboard.h @@ -32,8 +32,8 @@ #define FLASH_SIZE (0x60000) #define FLASH_PAGE_SIZE (0x4000) -#define AUTORESET_DELAY_MS 500 +#define AUTORESET_DELAY_MS (500) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) -#define BOARD_OSC_DIV 8 +#define BOARD_OSC_DIV (8) diff --git a/ports/stm32f4/boards/espruino_wifi/mpconfigboard.h b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.h index 611a41d93b..abdc9e8fac 100644 --- a/ports/stm32f4/boards/espruino_wifi/mpconfigboard.h +++ b/ports/stm32f4/boards/espruino_wifi/mpconfigboard.h @@ -32,5 +32,5 @@ #define FLASH_SIZE (0x80000) //512K #define FLASH_PAGE_SIZE (0x4000) //16K -#define BOARD_OSC_DIV 8 -#define BOARD_OVERWRITE_SWD +#define BOARD_OSC_DIV (8) +#define BOARD_OVERWRITE_SWD (1) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h index ad9bba7b0a..4670b9893e 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h @@ -42,7 +42,7 @@ // Bootloader only #ifdef UF2_BOOTLOADER_ENABLED - #define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader + #define BOARD_VTOR_DEFER (1) //Leave VTOR relocation to bootloader #endif #define DEFAULT_I2C_BUS_SCL (&pin_PB06) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index c849e03b6c..70ae866fe3 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -35,10 +35,10 @@ #define AUTORESET_DELAY_MS 500 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) -#define BOARD_OSC_DIV 12 -#define BOARD_NO_VBUS_SENSE -#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader -#define BOARD_USE_INTERNAL_SPI +#define BOARD_OSC_DIV (12) +#define BOARD_NO_VBUS_SENSE (1) +#define BOARD_VTOR_DEFER (1) //Leave VTOR relocation to bootloader +#define BOARD_USE_INTERNAL_SPI (1) // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) diff --git a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h index 7980ca93d6..965e7d5ff4 100644 --- a/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h +++ b/ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h @@ -32,7 +32,7 @@ #define FLASH_SIZE (0x80000) #define FLASH_PAGE_SIZE (0x4000) -#define BOARD_OSC_DIV 8 +#define BOARD_OSC_DIV (8) // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) @@ -40,8 +40,8 @@ #define SPI_FLASH_SCK_PIN (&pin_PB13) #define SPI_FLASH_CS_PIN (&pin_PB12) -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 +#define CIRCUITPY_AUTORELOAD_DELAY_MS (500) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) -#define AUTORESET_DELAY_MS 500 +#define AUTORESET_DELAY_MS (500) diff --git a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h index 7093442d09..b48a775ae9 100644 --- a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h +++ b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h @@ -32,6 +32,5 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) - #define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SDA (&pin_PB07) diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h index 05e2a384a1..2ae1a29268 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -32,8 +32,8 @@ #define FLASH_SIZE (0x80000) #define FLASH_PAGE_SIZE (0x4000) -#define BOARD_OSC_DIV 25 -#define BOARD_NO_VBUS_SENSE +#define BOARD_OSC_DIV (25) +#define BOARD_NO_VBUS_SENSE (1) // On-board flash // #define SPI_FLASH_MOSI_PIN (&pin_PA07) @@ -41,8 +41,8 @@ // #define SPI_FLASH_SCK_PIN (&pin_PA05) // #define SPI_FLASH_CS_PIN (&pin_PA04) -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 +#define CIRCUITPY_AUTORELOAD_DELAY_MS (500) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) -#define AUTORESET_DELAY_MS 500 +#define AUTORESET_DELAY_MS (500) diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h index 7a53354078..49ef80cdd7 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h @@ -32,4 +32,4 @@ #define FLASH_SIZE (0x80000) //512K #define FLASH_PAGE_SIZE (0x4000) //16K -#define BOARD_OSC_DIV 8 +#define BOARD_OSC_DIV (8) diff --git a/ports/stm32f4/mpconfigport.h b/ports/stm32f4/mpconfigport.h index 7737bda8d4..931a56ed21 100644 --- a/ports/stm32f4/mpconfigport.h +++ b/ports/stm32f4/mpconfigport.h @@ -37,6 +37,20 @@ // 24kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 +//Board flags: +#ifndef BOARD_OVERWRITE_SWD +#define BOARD_OVERWRITE_SWD (0) +#endif +#ifndef BOARD_VTOR_DEFER +#define BOARD_VTOR_DEFER (0) +#endif +#ifndef BOARD_NO_VBUS_SENSE +#define BOARD_NO_VBUS_SENSE (0) +#endif +#ifndef BOARD_USE_INTERNAL_SPI +#define BOARD_USE_INTERNAL_SPI (0) +#endif + #include "py/circuitpy_mpconfig.h" #define MAX_UART 10 //how many UART are implemented diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c index 77888c4657..aee0bd5eb8 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c @@ -42,7 +42,7 @@ void stm32f4_peripherals_gpio_init(void) { never_reset_pin_number(2,14); //PC14 OSC32_IN never_reset_pin_number(2,15); //PC15 OSC32_OUT - #if !defined(BOARD_OVERWRITE_SWD) + #if !(BOARD_OVERWRITE_SWD) never_reset_pin_number(0,13); //PA13 SWDIO never_reset_pin_number(0,14); //PA14 SWCLK #endif diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index afafe26a90..358c2de5b3 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -38,7 +38,7 @@ STATIC void init_usb_vbus_sense(void) { -#ifdef BOARD_NO_VBUS_SENSE +#if (BOARD_NO_VBUS_SENSE) // Disable VBUS sensing #ifdef USB_OTG_GCCFG_VBDEN USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; diff --git a/ports/stm32f4/system_stm32f4xx.c b/ports/stm32f4/system_stm32f4xx.c index bce420056d..caa4f9cafb 100644 --- a/ports/stm32f4/system_stm32f4xx.c +++ b/ports/stm32f4/system_stm32f4xx.c @@ -218,7 +218,7 @@ void SystemInit(void) #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ /* Configure the Vector Table location add offset address ------------------*/ -#if !defined(BOARD_VTOR_DEFER) //only set VTOR if the bootloader hasn't already +#if !(BOARD_VTOR_DEFER) //only set VTOR if the bootloader hasn't already #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ #else diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index efa61265e6..daf7a20460 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -103,7 +103,7 @@ void reset_displays(void) { continue; } #endif - #ifdef BOARD_USE_INTERNAL_SPI + #if (BOARD_USE_INTERNAL_SPI) if (original_spi == (mp_obj_t)(&supervisor_flash_spi_bus)) { continue; } From dd57d83926840eae097e346463fff55ceea70ca2 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 12 Feb 2020 11:32:36 -0800 Subject: [PATCH 491/531] Fix quotes and rerun make translate. --- locale/circuitpython.pot | 2 +- locale/zh_Latn_pinyin.po | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index baf5bf5ae3..e067213560 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-12 12:11-0500\n" +"POT-Creation-Date: 2020-02-12 11:31-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index d44da9c733..dcb78828c6 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 15:55-0800\n" +"POT-Creation-Date: 2020-02-12 11:31-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -142,8 +142,7 @@ msgstr "'%s' zhěngshù 0x%x bù shìyòng yú yǎn mǎ 0x%x" #: py/proto.c msgid "'%s' object does not support '%q'" -msgstr "" -"'%s' duì xiàng bù zhīchí '%q'" +msgstr "'%s' duì xiàng bù zhīchí '%q'" #: py/obj.c #, c-format @@ -495,8 +494,8 @@ msgid "" "CircuitPython is in safe mode because you pressed the reset button during " "boot. Press again to exit safe mode.\n" msgstr "" -"CircuitPython chǔyú ānquán móshì, yīnwèi zài yǐndǎo guòchéng zhōng " -"àn xiàle chóng zhì ànniǔ. Zài àn yīcì tuìchū ānquán móshì.\n" +"CircuitPython chǔyú ānquán móshì, yīnwèi zài yǐndǎo guòchéng zhōng àn xiàle " +"chóng zhì ànniǔ. Zài àn yīcì tuìchū ānquán móshì.\n" #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." @@ -523,8 +522,7 @@ msgstr "Mìnglìng bìxū shì 0 dào 255 zhī jiān de int" msgid "" "Connection has been disconnected and can no longer be used. Create a new " "connection." -msgstr "" -"Liánjiē yǐ duàn kāi, wúfǎ zài shǐyòng. Chuàngjiàn yīgè xīn de liánjiē." +msgstr "Liánjiē yǐ duàn kāi, wúfǎ zài shǐyòng. Chuàngjiàn yīgè xīn de liánjiē." #: py/persistentcode.c msgid "Corrupt .mpy file" @@ -1201,7 +1199,7 @@ msgstr "Cǐ bǎn bù zhīchí RTC" #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" -msgstr Suíjī shù shēngchéng cuòwù"" +msgstr "Suíjī shù shēngchéng cuòwù" #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" @@ -1290,6 +1288,10 @@ msgstr "Liú quēshǎo readinto() huò write() fāngfǎ." msgid "Supply at least one UART pin" msgstr "Dìngyì zhìshǎo yīgè UART yǐn jiǎo" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" @@ -1313,8 +1315,8 @@ msgid "" "CIRCUITPY).\n" msgstr "" "wēi kòng zhì qì de gōng lǜ jiàng dī. Quèbǎo nín de diànyuán wèi zhěnggè\n" -"diànlù tígōng zúgòu de diànyuán, bìng àn xià fùwèi (Dànchū " -"CIRCUITPY zhīhòu).\n" +"diànlù tígōng zúgòu de diànyuán, bìng àn xià fùwèi (Dànchū CIRCUITPY " +"zhīhòu).\n" #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -1470,8 +1472,8 @@ msgid "" "Unspecified issue. Can be that the pairing prompt on the other device was " "declined or ignored." msgstr "" -"Wèi zhǐdìng de wèntí. Kěnéng shì qítā shèbèi shàng de pèiduì tíshì bèi " -"jùjué huò hūlüè." +"Wèi zhǐdìng de wèntí. Kěnéng shì qítā shèbèi shàng de pèiduì tíshì bèi jùjué " +"huò hūlüè." #: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c msgid "Unsupported baudrate" @@ -1507,6 +1509,10 @@ msgstr "Zhí chángdù > zuìdà chángdù" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper hánshù mùqián bù zhīchí chāoguò 4 gè cānshù" +#: ports/stm32f4/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + #: main.c msgid "WARNING: Your code filename has two extensions\n" msgstr "Jǐnggào: Nǐ de dàimǎ wénjiàn míng yǒu liǎng gè kuòzhǎn míng\n" @@ -1862,7 +1868,8 @@ msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a buffer, tuple, list, or int" -msgstr "Yánsè huǎnchōng qū bìxū shì huǎnchōng qū, yuán zǔ, lièbiǎo huò zhěngshù" +msgstr "" +"Yánsè huǎnchōng qū bìxū shì huǎnchōng qū, yuán zǔ, lièbiǎo huò zhěngshù" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" From b248486c3b9e2eca9b9fd3c43e4f3dc7fdaa0779 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 12 Feb 2020 14:32:50 -0500 Subject: [PATCH 492/531] cleanup flag changes --- ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h | 2 +- ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h | 2 +- ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h index 1ae951874f..6600fcf671 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h +++ b/ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h @@ -34,7 +34,7 @@ #define MICROPY_HW_NEOPIXEL (&pin_PC00) -#define BOARD_OSC_DIV 12 +#define BOARD_OSC_DIV (12) // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB05) diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h index b6d28cb127..f34b830fb2 100644 --- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h @@ -32,7 +32,7 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) -#define BOARD_OSC_DIV 8 +#define BOARD_OSC_DIV (8) #define DEFAULT_I2C_BUS_SCL (&pin_PB10) #define DEFAULT_I2C_BUS_SDA (&pin_PB09) diff --git a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h index c51fa2e044..fcd7aa09cd 100644 --- a/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f4_discovery/mpconfigboard.h @@ -32,4 +32,4 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) -#define BOARD_OSC_DIV 8 +#define BOARD_OSC_DIV (8) From 6d91ed21563bd72938d7e5e6aa5d23265429d56f Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 12 Feb 2020 14:38:27 -0500 Subject: [PATCH 493/531] move defaults to avoid conflict --- ports/stm32f4/mpconfigport.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/mpconfigport.h b/ports/stm32f4/mpconfigport.h index 931a56ed21..2e1af47ece 100644 --- a/ports/stm32f4/mpconfigport.h +++ b/ports/stm32f4/mpconfigport.h @@ -37,6 +37,8 @@ // 24kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 +#include "py/circuitpy_mpconfig.h" + //Board flags: #ifndef BOARD_OVERWRITE_SWD #define BOARD_OVERWRITE_SWD (0) @@ -51,8 +53,6 @@ #define BOARD_USE_INTERNAL_SPI (0) #endif -#include "py/circuitpy_mpconfig.h" - #define MAX_UART 10 //how many UART are implemented #define MICROPY_PORT_ROOT_POINTERS \ From e00b3269febff0d7e1224d76d8301d8c95850536 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 12 Feb 2020 15:04:19 -0500 Subject: [PATCH 494/531] use properly-sized SPI transactions --- ports/nrf/boards/common.template.ld | 4 +- ports/nrf/common-hal/busio/SPI.c | 114 ++++++++++------------------ ports/nrf/common-hal/busio/SPI.h | 2 +- ports/nrf/ld_defines.c | 3 + ports/nrf/mpconfigport.h | 7 ++ 5 files changed, 51 insertions(+), 79 deletions(-) diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index 427b6b35b3..2fca167079 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -22,8 +22,8 @@ MEMORY /* SoftDevice 6.1.0 with 5 connections and various increases takes just under 64kiB. /* To measure the minimum required amount of memory for given configuration, set this number high enough to work and then check the mutation of the value done by sd_ble_enable. */ - SPIM3_RAM (rw) : ORIGIN = 0x20000000 + 64K, LENGTH = 8K - RAM (xrw) : ORIGIN = 0x20000000 + 64K + 8K, LENGTH = 256K - 64K -8K + SPIM3_RAM (rw) : ORIGIN = 0x20000000 + ${SOFTDEVICE_RAM_SIZE}, LENGTH = ${SPIM3_BUFFER_SIZE} + RAM (xrw) : ORIGIN = 0x20000000 + ${SOFTDEVICE_RAM_SIZE} + ${SPIM3_BUFFER_SIZE}, LENGTH = 256K - ${SOFTDEVICE_RAM_SIZE} -${SPIM3_BUFFER_SIZE} } diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index fe943a2215..43aced1a5f 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -31,35 +31,35 @@ #include "nrfx_spim.h" #include "nrf_gpio.h" -// These are in order from ighest available frequency to lowest (32MHz first, then 8MHz). +// These are in order from highest available frequency to lowest (32MHz first, then 8MHz). STATIC spim_peripheral_t spim_peripherals[] = { #if NRFX_CHECK(NRFX_SPIM3_ENABLED) // SPIM3 exists only on nRF52840 and supports 32MHz max. All other SPIM's are only 8MHz max. // Allocate SPIM3 first. { .spim = NRFX_SPIM_INSTANCE(3), .max_frequency = 32000000, - .max_xfer_size = SPIM3_EASYDMA_MAXCNT_SIZE, + .max_xfer_size = MIN(SPIM3_BUFFER_SIZE, (1UL << SPIM3_EASYDMA_MAXCNT_SIZE) - 1) }, #endif #if NRFX_CHECK(NRFX_SPIM2_ENABLED) // SPIM2 is not shared with a TWIM, so allocate before the shared ones. { .spim = NRFX_SPIM_INSTANCE(2), .max_frequency = 8000000, - .max_xfer_size = SPIM2_EASYDMA_MAXCNT_SIZE, + .max_xfer_size = (1UL << SPIM2_EASYDMA_MAXCNT_SIZE) - 1 }, #endif #if NRFX_CHECK(NRFX_SPIM1_ENABLED) // SPIM1 and TWIM1 share an address. { .spim = NRFX_SPIM_INSTANCE(1), .max_frequency = 8000000, - .max_xfer_size = SPIM1_EASYDMA_MAXCNT_SIZE, + .max_xfer_size = (1UL << SPIM1_EASYDMA_MAXCNT_SIZE) - 1 }, #endif #if NRFX_CHECK(NRFX_SPIM0_ENABLED) // SPIM0 and TWIM0 share an address. { .spim = NRFX_SPIM_INSTANCE(0), .max_frequency = 8000000, - .max_xfer_size = SPIM0_EASYDMA_MAXCNT_SIZE, + .max_xfer_size = (1UL << SPIM0_EASYDMA_MAXCNT_SIZE) - 1 }, #endif }; @@ -232,104 +232,66 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { } bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { - if (len == 0) { - return true; - } - const bool is_spim3 = self->spim_peripheral->spim.p_reg == NRF_SPIM3; + uint8_t *next_chunk = (uint8_t *) data; - const uint32_t max_xfer_size = self->spim_peripheral->max_xfer_size; - const uint32_t parts = len / max_xfer_size; - const uint32_t remainder = len % max_xfer_size; - - for (uint32_t i = 0; i < parts; ++i) { - uint8_t *start = (uint8_t *) (data + i * max_xfer_size); + while (len > 0) { + size_t chunk_size = MIN(len, self->spim_peripheral->max_xfer_size); + uint8_t *chunk = next_chunk; if (is_spim3) { // If SPIM3, copy into unused RAM block, and do DMA from there. - memcpy(spim3_transmit_buffer, start, max_xfer_size); - start = spim3_transmit_buffer; + memcpy(spim3_transmit_buffer, chunk, chunk_size); + chunk = spim3_transmit_buffer; } - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TX(start, max_xfer_size); - if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) + const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TX(chunk, chunk_size); + if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) { return false; - } - - if (remainder > 0) { - uint8_t *start = (uint8_t *) (data + parts * max_xfer_size); - if (is_spim3) { - // If SPIM3, copy into unused RAM block, and do DMA from there. - memcpy(spim3_transmit_buffer, start, remainder); - start = spim3_transmit_buffer; } - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TX(start, remainder); - if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) - return false; + next_chunk += chunk_size; + len -= chunk_size; } - return true; } bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { - if (len == 0) { - return true; - } + uint8_t *next_chunk = data; - const uint32_t max_xfer_size = self->spim_peripheral->max_xfer_size; - const uint32_t parts = len / max_xfer_size; - const uint32_t remainder = len % max_xfer_size; - - for (uint32_t i = 0; i < parts; ++i) { - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_RX(data + i * max_xfer_size, max_xfer_size); - if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) + while (len > 0) { + size_t chunk_size = MIN(len, self->spim_peripheral->max_xfer_size); + const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_RX(next_chunk, chunk_size); + if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) { return false; + } + next_chunk += chunk_size; + len -= chunk_size; } - - if (remainder > 0) { - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_RX(data + parts * max_xfer_size, remainder); - if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) - return false; - } - return true; } bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) { - if (len == 0) { - return true; - } - const bool is_spim3 = self->spim_peripheral->spim.p_reg == NRF_SPIM3; + uint8_t *next_chunk_out = data_out; + uint8_t *next_chunk_in = data_in; - const uint32_t max_xfer_size = self->spim_peripheral->max_xfer_size; - const uint32_t parts = len / max_xfer_size; - const uint32_t remainder = len % max_xfer_size; - - for (uint32_t i = 0; i < parts; ++i) { - uint8_t *out_start = (uint8_t *) (data_out + i * max_xfer_size); + while (len > 0) { + uint8_t *chunk_out = next_chunk_out; + size_t chunk_size = MIN(len, self->spim_peripheral->max_xfer_size); if (is_spim3) { // If SPIM3, copy into unused RAM block, and do DMA from there. - memcpy(spim3_transmit_buffer, out_start, max_xfer_size); - out_start = spim3_transmit_buffer; + memcpy(spim3_transmit_buffer, chunk_out, chunk_size); + chunk_out = spim3_transmit_buffer; } - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_SINGLE_XFER(out_start, max_xfer_size, - data_in + i * max_xfer_size, max_xfer_size); - if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) + const nrfx_spim_xfer_desc_t xfer = + NRFX_SPIM_SINGLE_XFER(next_chunk_out, chunk_size, + next_chunk_in, chunk_size); + if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) { return false; - } - - if (remainder > 0) { - uint8_t *out_start = (uint8_t *) (data_out + parts * max_xfer_size); - if (is_spim3) { - // If SPIM3, copy into unused RAM block, and do DMA from there. - memcpy(spim3_transmit_buffer, out_start, remainder); - out_start = spim3_transmit_buffer; } - const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_SINGLE_XFER(out_start, remainder, - data_in + parts * max_xfer_size, remainder); - if (nrfx_spim_xfer(&self->spim_peripheral->spim, &xfer, 0) != NRFX_SUCCESS) - return false; - } + next_chunk_out += chunk_size; + next_chunk_in += chunk_size; + len -= chunk_size; + } return true; } diff --git a/ports/nrf/common-hal/busio/SPI.h b/ports/nrf/common-hal/busio/SPI.h index 738a1de788..ef3ac9531e 100644 --- a/ports/nrf/common-hal/busio/SPI.h +++ b/ports/nrf/common-hal/busio/SPI.h @@ -33,7 +33,7 @@ typedef struct { nrfx_spim_t spim; uint32_t max_frequency; - uint8_t max_xfer_size; + uint32_t max_xfer_size; } spim_peripheral_t; typedef struct { diff --git a/ports/nrf/ld_defines.c b/ports/nrf/ld_defines.c index 0ec6dfdb5d..ebe9c4929e 100644 --- a/ports/nrf/ld_defines.c +++ b/ports/nrf/ld_defines.c @@ -37,3 +37,6 @@ /*BOOTLOADER_SETTINGS_START_ADDR=*/ BOOTLOADER_SETTINGS_START_ADDR; /*BOOTLOADER_SETTINGS_SIZE=*/ BOOTLOADER_SETTINGS_SIZE; + +/*SOFTDEVICE_RAM_SIZE=*/ SOFTDEVICE_RAM_SIZE; +/*SPIM3_BUFFER_SIZE=*/ SPIM3_BUFFER_SIZE; diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index b6635965de..db082ab51c 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -34,9 +34,16 @@ #include "nrf_sdm.h" // for SD_FLASH_SIZE #include "peripherals/nrf/nvm.h" // for FLASH_PAGE_SIZE +// Max RAM used by SoftDevice. Can be changed when SoftDevice parameters are changed. +// See common.template.ld. +#define SOFTDEVICE_RAM_SIZE (64*1024) + #ifdef NRF52840 #define MICROPY_PY_SYS_PLATFORM "nRF52840" #define FLASH_SIZE (0x100000) // 1MiB +// Special RAM area for SPIM3 transmit buffer, to work around hardware bug. +// See common.template.ld. +#define SPIM3_BUFFER_SIZE (8192) #endif #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) From fd2982f5c951b7a61ab82e6a103c7a060affd50c Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 12 Feb 2020 15:12:05 -0500 Subject: [PATCH 495/531] revert cross-board flag strategy --- ports/stm32f4/boards/meowbit_v121/mpconfigboard.h | 2 +- shared-module/displayio/__init__.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h index 70ae866fe3..babf54a3a9 100644 --- a/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm32f4/boards/meowbit_v121/mpconfigboard.h @@ -38,7 +38,7 @@ #define BOARD_OSC_DIV (12) #define BOARD_NO_VBUS_SENSE (1) #define BOARD_VTOR_DEFER (1) //Leave VTOR relocation to bootloader -#define BOARD_USE_INTERNAL_SPI (1) +#define BOARD_USE_INTERNAL_SPI // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index daf7a20460..efa61265e6 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -103,7 +103,7 @@ void reset_displays(void) { continue; } #endif - #if (BOARD_USE_INTERNAL_SPI) + #ifdef BOARD_USE_INTERNAL_SPI if (original_spi == (mp_obj_t)(&supervisor_flash_spi_bus)) { continue; } From afc1c88046540427f6a2bcd19b02b13e04871bdc Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 12 Feb 2020 15:56:24 -0500 Subject: [PATCH 496/531] remove bad define --- ports/stm32f4/mpconfigport.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/ports/stm32f4/mpconfigport.h b/ports/stm32f4/mpconfigport.h index 2e1af47ece..283984ea90 100644 --- a/ports/stm32f4/mpconfigport.h +++ b/ports/stm32f4/mpconfigport.h @@ -49,9 +49,6 @@ #ifndef BOARD_NO_VBUS_SENSE #define BOARD_NO_VBUS_SENSE (0) #endif -#ifndef BOARD_USE_INTERNAL_SPI -#define BOARD_USE_INTERNAL_SPI (0) -#endif #define MAX_UART 10 //how many UART are implemented From 4de2a1eb6224dbb218c80f652bf0ed36f2ac29f4 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Wed, 12 Feb 2020 22:36:34 +0000 Subject: [PATCH 497/531] Fix alignment warning --- .../mimxrt10xx/common-hal/microcontroller/Processor.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index 23493f7660..6b0a151854 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -58,8 +58,17 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk)); // Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info) + // into 8 bit wide destination, avoiding punning. for (int i = 0; i < 4; ++i) - ((uint32_t*) raw_id)[i] = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); + { + uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); + + for (int j = 0; j < 4; j++) + { + raw_id[i*4+j] = wr&0xff; + wr>>=8; + } + } OCOTP_Deinit(OCOTP); } From b02937d1a7ed0221778adc4719256344a4be2d0d Mon Sep 17 00:00:00 2001 From: James Bowman Date: Thu, 13 Feb 2020 07:28:21 -0800 Subject: [PATCH 498/531] Split ROMDECLS for readability --- shared-bindings/_eve/__init__.c | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 97b4e8c479..9bc790f5d1 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -906,7 +906,56 @@ STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); -#define ROM_DECLS { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } +#define ROM_DECLS \ + { MP_ROM_QSTR(MP_QSTR_AlphaFunc), MP_ROM_PTR(&alphafunc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Begin), MP_ROM_PTR(&begin_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapExtFormat), MP_ROM_PTR(&bitmapextformat_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapHandle), MP_ROM_PTR(&bitmaphandle_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapLayoutH), MP_ROM_PTR(&bitmaplayouth_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapLayout), MP_ROM_PTR(&bitmaplayout_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSizeH), MP_ROM_PTR(&bitmapsizeh_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSize), MP_ROM_PTR(&bitmapsize_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSource), MP_ROM_PTR(&bitmapsource_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapSwizzle), MP_ROM_PTR(&bitmapswizzle_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformA), MP_ROM_PTR(&bitmaptransforma_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformB), MP_ROM_PTR(&bitmaptransformb_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformC), MP_ROM_PTR(&bitmaptransformc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformD), MP_ROM_PTR(&bitmaptransformd_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformE), MP_ROM_PTR(&bitmaptransforme_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BitmapTransformF), MP_ROM_PTR(&bitmaptransformf_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_BlendFunc), MP_ROM_PTR(&blendfunc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Call), MP_ROM_PTR(&call_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Cell), MP_ROM_PTR(&cell_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearColorA), MP_ROM_PTR(&clearcolora_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearColorRGB), MP_ROM_PTR(&clearcolorrgb_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Clear), MP_ROM_PTR(&clear_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearStencil), MP_ROM_PTR(&clearstencil_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ClearTag), MP_ROM_PTR(&cleartag_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ColorA), MP_ROM_PTR(&colora_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ColorMask), MP_ROM_PTR(&colormask_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ColorRGB), MP_ROM_PTR(&colorrgb_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&display_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_End), MP_ROM_PTR(&end_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Jump), MP_ROM_PTR(&jump_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_LineWidth), MP_ROM_PTR(&linewidth_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Macro), MP_ROM_PTR(¯o_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Nop), MP_ROM_PTR(&nop_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_PaletteSource), MP_ROM_PTR(&palettesource_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_PointSize), MP_ROM_PTR(&pointsize_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_RestoreContext), MP_ROM_PTR(&restorecontext_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Return), MP_ROM_PTR(&return_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_SaveContext), MP_ROM_PTR(&savecontext_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ScissorSize), MP_ROM_PTR(&scissorsize_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_ScissorXY), MP_ROM_PTR(&scissorxy_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_StencilFunc), MP_ROM_PTR(&stencilfunc_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_StencilMask), MP_ROM_PTR(&stencilmask_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_StencilOp), MP_ROM_PTR(&stencilop_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_TagMask), MP_ROM_PTR(&tagmask_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Tag), MP_ROM_PTR(&tag_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_VertexTranslateX), MP_ROM_PTR(&vertextranslatex_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_VertexTranslateY), MP_ROM_PTR(&vertextranslatey_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, \ + { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } //} From dc97b0d844011876db286d1388c7ac0dd006f143 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 13 Feb 2020 17:41:05 -0500 Subject: [PATCH 499/531] correct chec^Cfor flash erase boundaries --- ports/atmel-samd/mpconfigport.h | 30 ++++++++++++++++++------------ ports/nrf/mpconfigport.h | 31 +++++++++++++++++-------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 28a844ffc0..04ad98c22a 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -109,6 +109,9 @@ #define CIRCUITPY_DEFAULT_STACK_SIZE 4096 #endif +// Smallest unit of flash that can be erased. +#define FLASH_ERASE_SIZE NVMCTRL_ROW_SIZE + #endif // SAMD21 //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -123,6 +126,9 @@ #define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024) #endif +// Smallest unit of flash that can be erased. +#define FLASH_ERASE_SIZE NVMCTRL_BLOCK_SIZE + // If CIRCUITPY is internal, use half of flash for it. #if INTERNAL_FLASH_FILESYSTEM #ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE @@ -187,25 +193,25 @@ #error BOOTLOADER_START_ADDR must be on a flash page boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash erase (row or block) boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_INTERNAL_CONFIG_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_CONFIG_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be on a flash erase (row or block) boundary. #endif -#if CIRCUITPY_INTERNAL_CONFIG_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_CONFIG_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash erase (row or block) boundary. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif #if CIRCUITPY_FIRMWARE_SIZE < 0 diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index db082ab51c..473169e946 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -104,6 +104,9 @@ #define ISR_START_ADDR (SD_FLASH_START_ADDR + SD_FLASH_SIZE) #define ISR_SIZE (0x1000) // 4kiB +// Smallest unit of flash that can be erased. +#define FLASH_ERASE_SIZE FLASH_PAGE_SIZE + #define CIRCUITPY_FIRMWARE_START_ADDR (ISR_START_ADDR + ISR_SIZE) // Define these regions starting down from the bootloader: @@ -129,29 +132,29 @@ // The firmware space is the space left over between the fixed lower and upper regions. #define CIRCUITPY_FIRMWARE_SIZE (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR) -#if BOOTLOADER_START_ADDR % FLASH_PAGE_SIZE != 0 -#error BOOTLOADER_START_ADDR must be on a flash page boundary. +#if BOOTLOADER_START_ADDR % FLASH_ERASE_SIZE != 0 +#error BOOTLOADER_START_ADDR must be on a flash erase boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash erase boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_BLE_CONFIG_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_BLE_CONFIG_SIZE must be on a flash page boundary. +#if CIRCUITPY_BLE_CONFIG_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_BLE_CONFIG_SIZE must be on a flash erase boundary. #endif -#if CIRCUITPY_BLE_CONFIG_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_BLE_CONFIG_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_BLE_CONFIG_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_BLE_CONFIG_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash erase boundary. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif #if CIRCUITPY_FIRMWARE_SIZE < 0 From 33774e790c8ee9e3c14934a364738e384418c13d Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 14 Feb 2020 10:23:23 -0800 Subject: [PATCH 500/531] Updated OnDiskBitmap RTD example for 5.x --- shared-bindings/displayio/OnDiskBitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index f7e2bf693f..57179947ed 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -62,7 +62,7 @@ //| face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter()) //| splash.append(face) //| # Wait for the image to load. -//| board.DISPLAY.wait_for_frame() +//| board.DISPLAY.refresh(target_frames_per_second=60) //| //| # Fade up the backlight //| for i in range(100): From c592bd612ad8231f61681aa40cd51b6bbfcb307f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 14 Feb 2020 15:12:20 -0500 Subject: [PATCH 501/531] Implement to_bytes(..., signed=True) --- py/objint.c | 35 +++++++++++++++++++++---------- tests/basics/int_bytes.py | 12 ++++++++++- tests/basics/int_bytes_intbig.py | 8 ++++++- tests/basics/int_longint_bytes.py | 1 + 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/py/objint.c b/py/objint.c index 9e11871f10..b78c9f25b1 100644 --- a/py/objint.c +++ b/py/objint.c @@ -490,15 +490,24 @@ STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj)); -STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) { - // TODO: Support signed param (assumes signed=False) - (void)n_args; +STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_length, ARG_byteorder, ARG_signed }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_length, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_byteorder, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_signed, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + }; + 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); - mp_int_t len = mp_obj_get_int(args[1]); + mp_int_t len = args[ARG_length].u_int; if (len < 0) { mp_raise_ValueError(NULL); } - bool big_endian = args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little); + + mp_obj_t self = pos_args[0]; + bool big_endian = args[ARG_byteorder].u_obj != MP_OBJ_NEW_QSTR(MP_QSTR_little); + bool signed_ = args[ARG_signed].u_bool; vstr_t vstr; vstr_init_len(&vstr, len); @@ -506,22 +515,26 @@ STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) { memset(data, 0, len); #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE - if (!MP_OBJ_IS_SMALL_INT(args[0])) { - mp_obj_int_buffer_overflow_check(args[0], len, false); - mp_obj_int_to_bytes_impl(args[0], big_endian, len, data); + if (!MP_OBJ_IS_SMALL_INT(self)) { + mp_obj_int_buffer_overflow_check(self, len, signed_); + mp_obj_int_to_bytes_impl(self, big_endian, len, data); } else #endif { - mp_int_t val = MP_OBJ_SMALL_INT_VALUE(args[0]); + mp_int_t val = MP_OBJ_SMALL_INT_VALUE(self); // Small int checking is separate, to be fast. - mp_small_int_buffer_overflow_check(val, len, false); + mp_small_int_buffer_overflow_check(val, len, signed_); size_t l = MIN((size_t)len, sizeof(val)); + if (val < 0) { + // Sign extend negative numbers. + memset(data, -1, len); + } mp_binary_set_int(l, big_endian, data + (big_endian ? (len - l) : 0), val); } return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(int_to_bytes_obj, 3, int_to_bytes); STATIC const mp_rom_map_elem_t int_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) }, diff --git a/tests/basics/int_bytes.py b/tests/basics/int_bytes.py index aaf4400815..d42afac1fd 100644 --- a/tests/basics/int_bytes.py +++ b/tests/basics/int_bytes.py @@ -1,8 +1,11 @@ print((10).to_bytes(1, "little")) +print((-10).to_bytes(1, "little", signed=True)) # Test fitting in length that's not a power of two. print((0x10000).to_bytes(3, 'little')) print((111111).to_bytes(4, "little")) +print((-111111).to_bytes(4, "little", signed=True)) print((100).to_bytes(10, "little")) +print((-100).to_bytes(10, "little", signed=True)) # check that extra zero bytes don't change the internal int value print(int.from_bytes(bytes(20), "little") == 0) @@ -10,7 +13,9 @@ print(int.from_bytes(b"\x01" + bytes(20), "little") == 1) # big-endian conversion print((10).to_bytes(1, "big")) +print((-10).to_bytes(1, "big", signed=True)) print((100).to_bytes(10, "big")) +print((-100).to_bytes(10, "big", signed=True)) print(int.from_bytes(b"\0\0\0\0\0\0\0\0\0\x01", "big")) print(int.from_bytes(b"\x01\0", "big")) @@ -26,8 +31,13 @@ try: except OverflowError: print("OverflowError") -# negative numbers should raise an error +# negative numbers should raise an error if signed=False try: (-256).to_bytes(2, "little") except OverflowError: print("OverflowError") + +try: + (-256).to_bytes(2, "little", signed=False) +except OverflowError: + print("OverflowError") diff --git a/tests/basics/int_bytes_intbig.py b/tests/basics/int_bytes_intbig.py index b19c8ae53e..a9f0699024 100644 --- a/tests/basics/int_bytes_intbig.py +++ b/tests/basics/int_bytes_intbig.py @@ -2,7 +2,9 @@ import skip_if skip_if.no_bigint() print((2**64).to_bytes(9, "little")) +print((-2**64).to_bytes(9, "little", signed=True)) print((2**64).to_bytes(9, "big")) +print((-2**64).to_bytes(9, "big", signed=True)) b = bytes(range(20)) @@ -22,8 +24,12 @@ try: except OverflowError: print("OverflowError") -# negative numbers should raise an error +# negative numbers should raise an error if signed=False try: (-2**64).to_bytes(9, "little") except OverflowError: print("OverflowError") +try: + (-2**64).to_bytes(9, "little", signed=False) +except OverflowError: + print("OverflowError") diff --git a/tests/basics/int_longint_bytes.py b/tests/basics/int_longint_bytes.py index 42e445f539..90cbff2f87 100644 --- a/tests/basics/int_longint_bytes.py +++ b/tests/basics/int_longint_bytes.py @@ -3,6 +3,7 @@ import skip_if skip_if.no_bigint() print((2**64).to_bytes(9, "little")) +print((-2**64).to_bytes(9, "little", signed=True)) print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little")) print(int.from_bytes(b"\x01\0\0\0\0\0\0\0", "little")) print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little")) From d13f04f9534813ab1c1d975350961bfc0f5b7f67 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Fri, 14 Feb 2020 23:02:02 +0000 Subject: [PATCH 502/531] Updated formatting --- .../common-hal/microcontroller/Processor.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index 6b0a151854..fdec73f479 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -59,16 +59,12 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { // Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info) // into 8 bit wide destination, avoiding punning. - for (int i = 0; i < 4; ++i) - { - uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); - - for (int j = 0; j < 4; j++) - { - raw_id[i*4+j] = wr&0xff; - wr>>=8; - } - } - + for (int i = 0; i < 4; ++i) { + uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); + for (int j = 0; j < 4; j++) { + raw_id[i*4+j] = wr&0xff; + wr>>=8; + } + } OCOTP_Deinit(OCOTP); } From e0753c4ad2a20b2feede6fa8732fc60895cd6097 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 14 Feb 2020 16:31:31 -0500 Subject: [PATCH 503/531] avoid os.stat() int overflow on smallint-only builds --- extmod/vfs_fat.c | 29 ++++++++++++++++++----------- shared-bindings/os/__init__.c | 5 +++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 60f4393f43..9cb4d98426 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -345,14 +345,21 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) { } else { mode |= MP_S_IFREG; } - mp_uint_t seconds = timeutils_seconds_since_epoch( - 1980 + ((fno.fdate >> 9) & 0x7f), - (fno.fdate >> 5) & 0x0f, - fno.fdate & 0x1f, - (fno.ftime >> 11) & 0x1f, - (fno.ftime >> 5) & 0x3f, - 2 * (fno.ftime & 0x1f) - ); +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE + // On non-longint builds, the number of seconds since 1970 (epoch) is too + // large to fit in a smallint, so just return 31-DEC-1999 (0). + mp_obj_t seconds = MP_OBJ_NEW_SMALL_INT(946684800); +#else + mp_obj_t seconds = mp_obj_new_int_from_uint( + timeutils_seconds_since_epoch( + 1980 + ((fno.fdate >> 9) & 0x7f), + (fno.fdate >> 5) & 0x0f, + fno.fdate & 0x1f, + (fno.ftime >> 11) & 0x1f, + (fno.ftime >> 5) & 0x3f, + 2 * (fno.ftime & 0x1f) + )); +#endif t->items[0] = MP_OBJ_NEW_SMALL_INT(mode); // st_mode t->items[1] = MP_OBJ_NEW_SMALL_INT(0); // st_ino t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // st_dev @@ -360,9 +367,9 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) { t->items[4] = MP_OBJ_NEW_SMALL_INT(0); // st_uid t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // st_gid t->items[6] = mp_obj_new_int_from_uint(fno.fsize); // st_size - t->items[7] = mp_obj_new_int_from_uint(seconds); // st_atime - t->items[8] = mp_obj_new_int_from_uint(seconds); // st_mtime - t->items[9] = mp_obj_new_int_from_uint(seconds); // st_ctime + t->items[7] = seconds; // st_atime + t->items[8] = seconds; // st_mtime + t->items[9] = seconds; // st_ctime return MP_OBJ_FROM_PTR(t); } diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index c2b63bbcee..f3b745aefe 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -143,6 +143,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir); //| //| Get the status of a file or directory. //| +//| .. note:: On builds without long integers, the number of seconds +//| for contemporary dates will not fit in a small integer. +//| So the time fields return 946684800, +//| which is the number of seconds corresponding to 1999-12-31. +//| mp_obj_t os_stat(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); return common_hal_os_stat(path); From 77ad9aff3cd91d1f81f81ab7369fc5996277cdcd Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Sun, 16 Feb 2020 00:40:04 +0000 Subject: [PATCH 504/531] Formatting updates --- ports/mimxrt10xx/common-hal/microcontroller/Processor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index fdec73f479..0c8131ef40 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -62,8 +62,8 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { for (int i = 0; i < 4; ++i) { uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); for (int j = 0; j < 4; j++) { - raw_id[i*4+j] = wr&0xff; - wr>>=8; + raw_id[i*4+j] = wr & 0xff; + wr >>= 8; } } OCOTP_Deinit(OCOTP); From 93760042fa9793d79e4490dc665593b608d5b334 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Sun, 16 Feb 2020 11:43:19 -0800 Subject: [PATCH 505/531] no current need for NVM --- ports/atmel-samd/boards/sam32/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.h b/ports/atmel-samd/boards/sam32/mpconfigboard.h index 6378e41620..364d380d1d 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.h +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.h @@ -10,7 +10,7 @@ #define MICROPY_PORT_C (0) #define MICROPY_PORT_D (0) -#define CIRCUITPY_INTERNAL_NVM_SIZE 1024 +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (128*1024) #define BOARD_HAS_CRYSTAL 1 From aca53aa1a2c21ff46b609cfc270134ee6ee024f2 Mon Sep 17 00:00:00 2001 From: DavePutz Date: Tue, 18 Feb 2020 10:38:50 -0600 Subject: [PATCH 506/531] Update readline.c for REPL Unicode issue 1905 --- lib/mp-readline/readline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mp-readline/readline.c b/lib/mp-readline/readline.c index 9d254d8cfe..0edaebbfae 100644 --- a/lib/mp-readline/readline.c +++ b/lib/mp-readline/readline.c @@ -206,7 +206,7 @@ int readline_process_char(int c) { redraw_step_forward = compl_len; } #endif - } else if (32 <= c && c <= 126) { + } else if (32 <= c ) { // printable character vstr_ins_char(rl.line, rl.cursor_pos, c); // set redraw parameters From 2b79d8ffe90f89a32c791fbd8192f9104c2ea1b7 Mon Sep 17 00:00:00 2001 From: Max Holliday Date: Tue, 18 Feb 2020 14:16:54 -0800 Subject: [PATCH 507/531] adding PWM to board.c for external WDT --- ports/atmel-samd/boards/pycubed/board.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/atmel-samd/boards/pycubed/board.c b/ports/atmel-samd/boards/pycubed/board.c index da37252d82..31b0812094 100644 --- a/ports/atmel-samd/boards/pycubed/board.c +++ b/ports/atmel-samd/boards/pycubed/board.c @@ -30,6 +30,9 @@ #include "boards/board.h" #include "py/mpconfig.h" #include "shared-bindings/nvm/ByteArray.h" +#include "common-hal/microcontroller/Pin.h" +#include "hal/include/hal_gpio.h" +#include "shared-bindings/pulseio/PWMOut.h" nvm_bytearray_obj_t bootcnt = { .base = { @@ -41,6 +44,9 @@ nvm_bytearray_obj_t bootcnt = { void board_init(void) { + pulseio_pwmout_obj_t pwm; + common_hal_pulseio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false); + common_hal_pulseio_pwmout_never_reset(&pwm); } bool board_requests_safe_mode(void) { From 84ad3d8393db46eacfe3432d6476f1c5c48077e3 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Sun, 16 Feb 2020 00:23:43 +0000 Subject: [PATCH 508/531] Addition of RTS/CTS/RS485 UART functionality --- ports/mimxrt10xx/common-hal/busio/UART.c | 62 +++++++++++--- .../mimxrt10xx/MIMXRT1021/periph.c | 80 ++++++++++++++----- .../mimxrt10xx/MIMXRT1021/periph.h | 2 + shared-bindings/busio/UART.c | 13 ++- shared-bindings/busio/UART.h | 7 +- shared-module/board/__init__.c | 17 +++- 6 files changed, 145 insertions(+), 36 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index a4819798bc..2842b2cd95 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -53,8 +53,8 @@ static void config_periph_pin(const mcu_periph_obj_t *periph) { 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_PUS(1) + | IOMUXC_SW_PAD_CTL_PAD_PUE(1) | IOMUXC_SW_PAD_CTL_PAD_PKE(1) | IOMUXC_SW_PAD_CTL_PAD_ODE(0) | IOMUXC_SW_PAD_CTL_PAD_SPEED(1) @@ -72,9 +72,10 @@ void LPUART_UserCallback(LPUART_Type *base, lpuart_handle_t *handle, status_t st } void common_hal_busio_uart_construct(busio_uart_obj_t *self, - const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, - uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, - uint16_t receiver_buffer_size) { + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, bool rs485_mode, + uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, + mp_float_t timeout, uint16_t receiver_buffer_size) { // TODO: Allow none rx or tx @@ -111,12 +112,48 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if(self->rx_pin == NULL || self->tx_pin == NULL) { mp_raise_RuntimeError(translate("Invalid UART pin selection")); - } else { - self->uart = mcu_uart_banks[self->tx_pin->bank_idx - 1]; } + // Now check for RTS/CTS pin(s) + const uint32_t rts_count = sizeof(mcu_uart_rts_list) / sizeof(mcu_periph_obj_t); + const uint32_t cts_count = sizeof(mcu_uart_cts_list) / sizeof(mcu_periph_obj_t); + + if (rts != mp_const_none) { + for (uint32_t i=0; i < rts_count; ++i) + { + if (mcu_uart_rts_list[i].bank_idx == self->rx_pin->bank_idx) { + if (mcu_uart_rts_list[i].pin == rts) { + self->rts_pin = &mcu_uart_rts_list[i]; + break; + } + } + } + if (self->rts_pin == NULL) + mp_raise_ValueError(translate("Selected RTS pin not valid")); + } + + if (cts != mp_const_none) { + for (uint32_t i=0; i < cts_count; ++i) + { + if (mcu_uart_cts_list[i].bank_idx == self->rx_pin->bank_idx) { + if (mcu_uart_cts_list[i].pin == cts) { + self->cts_pin = &mcu_uart_cts_list[i]; + break; + } + } + } + if (self->cts_pin == NULL) + mp_raise_ValueError(translate("Selected CTS pin not valid")); + } + + self->uart = mcu_uart_banks[self->tx_pin->bank_idx - 1]; + config_periph_pin(self->rx_pin); config_periph_pin(self->tx_pin); + if (self->rts_pin) + config_periph_pin(self->rts_pin); + if (self->cts_pin) + config_periph_pin(self->cts_pin); lpuart_config_t config = { 0 }; LPUART_GetDefaultConfig(&config); @@ -125,10 +162,13 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, config.baudRate_Bps = self->baudrate; config.enableTx = self->tx_pin != NULL; config.enableRx = self->rx_pin != NULL; - + config.enableRxRTS = self->rts_pin != NULL; + config.enableTxCTS = self->cts_pin != NULL; + LPUART_Init(self->uart, &config, UART_CLOCK_FREQ); - claim_pin(self->tx_pin->pin); + if (self->tx_pin != NULL) + claim_pin(self->tx_pin->pin); if (self->rx_pin != NULL) { ringbuf_alloc(&self->rbuf, receiver_buffer_size, true); @@ -203,7 +243,9 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t LPUART_TransferAbortReceive(self->uart, &self->handle); } - return len - self->handle.rxDataSize; + // The only place we can reliably tell how many bytes have been received is from the current + // wp in the handle (because the abort nukes rxDataSize, and reading it before abort is a race.) + return self->handle.rxData-data; } // Write characters. diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c index 39e4f0131d..0417f29cc2 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c @@ -109,53 +109,93 @@ LPUART_Type *mcu_uart_banks[] = { LPUART1, LPUART2, LPUART3, LPUART4, LPUART5, L const mcu_periph_obj_t mcu_uart_rx_list[16] = { PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_07), - PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_23), - PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_09), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 0, &pin_GPIO_AD_B1_09), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_23), PERIPH_PIN(3, 2, kIOMUXC_LPUART3_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_07), PERIPH_PIN(3, 2, kIOMUXC_LPUART3_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_15), PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_03), - PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_33), - PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 2, &pin_GPIO_AD_B1_11), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_11), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_RX_SELECT_INPUT, 2, &pin_GPIO_EMC_33), - PERIPH_PIN(5, 2, kIOMUXC_LPUART5_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_39), - PERIPH_PIN(5, 2, kIOMUXC_LPUART5_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_11), + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_RX_SELECT_INPUT, 0, &pin_GPIO_AD_B0_11), + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_39), PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_13), PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_01), - PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_35), - PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 1, &pin_GPIO_SD_B0_05), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B0_05), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_35), - PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_27), - PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_03), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_03), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_27), }; const mcu_periph_obj_t mcu_uart_tx_list[16] = { PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_06), - PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_22), - PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_08), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 0, &pin_GPIO_AD_B1_08), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_22), PERIPH_PIN(3, 2, kIOMUXC_LPUART3_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_06), PERIPH_PIN(3, 2, kIOMUXC_LPUART3_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_14), PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_02), - PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_32), - PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 2, &pin_GPIO_AD_B1_10), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_10), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_TX_SELECT_INPUT, 2, &pin_GPIO_EMC_32), - PERIPH_PIN(5, 2, kIOMUXC_LPUART5_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_38), - PERIPH_PIN(5, 2, kIOMUXC_LPUART5_TX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_10), + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_TX_SELECT_INPUT, 0, &pin_GPIO_AD_B0_10), + PERIPH_PIN(5, 2, kIOMUXC_LPUART5_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_38), PERIPH_PIN(6, 2, kIOMUXC_LPUART6_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_12), PERIPH_PIN(6, 2, kIOMUXC_LPUART6_TX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_00), - PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_34), - PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 1, &pin_GPIO_SD_B0_04), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 0, &pin_GPIO_SD_B0_04), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_34), - PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 0, &pin_GPIO_EMC_26), - PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 1, &pin_GPIO_SD_B1_02), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_02), + PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 1, &pin_GPIO_EMC_26), +}; + +const mcu_periph_obj_t mcu_uart_rts_list[10] = { + PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_09), + + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_21), + PERIPH_PIN(2, 2, 0, 1, &pin_GPIO_AD_B1_07), + + PERIPH_PIN(3, 2, 0, 1, &pin_GPIO_AD_B0_13), + + PERIPH_PIN(4, 2, 0, 0, &pin_GPIO_EMC_01), + PERIPH_PIN(4, 2, 0, 1, &pin_GPIO_EMC_31), + + PERIPH_PIN(5, 2, 0, 0, &pin_GPIO_EMC_37), + + PERIPH_PIN(6, 2, 0, 0, &pin_GPIO_EMC_15), + + PERIPH_PIN(7, 2, 0, 1, &pin_GPIO_SD_B0_03), + + PERIPH_PIN(8, 2, 0, 0, &pin_GPIO_EMC_25), +}; + +const mcu_periph_obj_t mcu_uart_cts_list[10] = { + PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_08), + + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_CTS_B_SELECT_INPUT, 0, &pin_GPIO_AD_B1_06), + PERIPH_PIN(2, 2, kIOMUXC_LPUART2_CTS_B_SELECT_INPUT, 1, &pin_GPIO_EMC_20), + + PERIPH_PIN(3, 2, 0, 1, &pin_GPIO_AD_B0_12), + + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_CTS_B_SELECT_INPUT, 0, &pin_GPIO_EMC_00), + PERIPH_PIN(4, 2, kIOMUXC_LPUART4_CTS_B_SELECT_INPUT, 0, &pin_GPIO_EMC_30), + + PERIPH_PIN(5, 2, 0, 0, &pin_GPIO_EMC_36), + + PERIPH_PIN(6, 2, 0, 0, &pin_GPIO_EMC_14), + + PERIPH_PIN(7, 2, 0, 0, &pin_GPIO_SD_B0_02), + + PERIPH_PIN(8, 2, 0, 0, &pin_GPIO_EMC_24), }; const mcu_pwm_obj_t mcu_pwm_list[39] = { diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h index 1d720f6336..ba88ef4c61 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h @@ -37,6 +37,8 @@ extern const mcu_periph_obj_t mcu_spi_miso_list[8]; extern const mcu_periph_obj_t mcu_uart_rx_list[16]; extern const mcu_periph_obj_t mcu_uart_tx_list[16]; +extern const mcu_periph_obj_t mcu_uart_rts_list[10]; +extern const mcu_periph_obj_t mcu_uart_cts_list[10]; extern const mcu_pwm_obj_t mcu_pwm_list[39]; diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 1fc81e78e2..529d2d3cef 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -82,7 +82,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co // https://github.com/adafruit/circuitpython/issues/1056) busio_uart_obj_t *self = m_new_ll_obj(busio_uart_obj_t); self->base.type = &busio_uart_type; - enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_receiver_buffer_size}; + enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_receiver_buffer_size, ARG_rts, ARG_cts, ARG_rs485}; static const mp_arg_t allowed_args[] = { { MP_QSTR_tx, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_rx, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -92,6 +92,9 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co { MP_QSTR_stop, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} }, { MP_QSTR_receiver_buffer_size, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, + { MP_QSTR_rts, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_cts, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_rs485, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false } }, }; 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); @@ -124,7 +127,13 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); validate_timeout(timeout); - common_hal_busio_uart_construct(self, tx, rx, + const mcu_pin_obj_t* rts = MP_OBJ_TO_PTR(args[ARG_rts].u_obj); + + const mcu_pin_obj_t* cts = MP_OBJ_TO_PTR(args[ARG_cts].u_obj); + + bool rs485 = args[ARG_rs485].u_bool; + + common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485, args[ARG_baudrate].u_int, bits, parity, stop, timeout, args[ARG_receiver_buffer_size].u_int); return (mp_obj_t)self; diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h index cfd2c800c3..1d748ecc70 100644 --- a/shared-bindings/busio/UART.h +++ b/shared-bindings/busio/UART.h @@ -40,9 +40,10 @@ typedef enum { // Construct an underlying UART object. extern void common_hal_busio_uart_construct(busio_uart_obj_t *self, - const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, - uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, - uint16_t receiver_buffer_size); + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, bool rs485_mode, + uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, + mp_float_t timeout, uint16_t receiver_buffer_size); extern void common_hal_busio_uart_deinit(busio_uart_obj_t *self); extern bool common_hal_busio_uart_deinited(busio_uart_obj_t *self); diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 914bc43137..05567d7ab2 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -100,8 +100,23 @@ mp_obj_t common_hal_board_create_uart(void) { const mcu_pin_obj_t* rx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RX); const mcu_pin_obj_t* tx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_TX); +#ifdef DEFAULT_UART_BUS_RTS + const mcu_pin_obj_t* rts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RTS); +#else + const mcu_pin_obj_t* rts = mp_const_none; +#endif +#ifdef DEFAULT_UART_BUS_CTS + const mcu_pin_obj_t* cts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_CTS); +#else + const mcu_pin_obj_t* cts = mp_const_none; +#endif +#ifdef DEFAULT_UART_IS_RS485 + const bool rs485 = true; +#else + const bool rs485 = false; +#endif - common_hal_busio_uart_construct(self, tx, rx, 9600, 8, PARITY_NONE, 1, 1.0f, 64); + common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485, 9600, 8, PARITY_NONE, 1, 1.0f, 64); MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self); return MP_STATE_VM(shared_uart_bus); } From d388899985b24530cc08cdf10ed15e3c7ba41349 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Tue, 18 Feb 2020 00:09:35 +0000 Subject: [PATCH 509/531] Addition of RS485 support --- ports/mimxrt10xx/common-hal/busio/UART.c | 38 +++++++++++++++++-- .../supervisor/flexspi_nor_flash_ops.c | 2 +- shared-bindings/busio/UART.c | 15 ++++++-- shared-bindings/busio/UART.h | 3 +- shared-module/board/__init__.c | 11 ++++-- 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index 2842b2cd95..3609a99982 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -73,7 +73,8 @@ void LPUART_UserCallback(LPUART_Type *base, lpuart_handle_t *handle, status_t st void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, - const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, bool rs485_mode, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, + const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, uint16_t receiver_buffer_size) { @@ -114,7 +115,22 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, mp_raise_RuntimeError(translate("Invalid UART pin selection")); } - // Now check for RTS/CTS pin(s) + // Filter for sane settings for RS485 + if (rs485_dir != mp_const_none) { + if ((rts != mp_const_none) || (cts != mp_const_none)) { + mp_raise_ValueError(translate("Cannot specify RTS or CTS in RS485 mode")); + } + // For IMXRT the RTS pin is used for RS485 direction + rts = rs485_dir; + } + else + { + if (rs485_invert == true) { + mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode")); + } + } + + // Now check for RTS/CTS (or overloaded RS485 direction) pin(s) const uint32_t rts_count = sizeof(mcu_uart_rts_list) / sizeof(mcu_periph_obj_t); const uint32_t cts_count = sizeof(mcu_uart_cts_list) / sizeof(mcu_periph_obj_t); @@ -163,10 +179,24 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, config.enableTx = self->tx_pin != NULL; config.enableRx = self->rx_pin != NULL; config.enableRxRTS = self->rts_pin != NULL; - config.enableTxCTS = self->cts_pin != NULL; - + config.enableTxCTS = self->cts_pin != NULL; + if (self->rts_pin != NULL) + claim_pin(self->rts_pin->pin); + if (self->cts_pin != NULL) + claim_pin(self->cts_pin->pin); + LPUART_Init(self->uart, &config, UART_CLOCK_FREQ); + // Before we init, setup RS485 direction pin + // ..unfortunately this isn't done by the driver library + uint32_t modir = (self->uart->MODIR) & ~(LPUART_MODIR_TXRTSPOL_MASK | LPUART_MODIR_TXRTSE_MASK); + if (rs485_dir != mp_const_none) { + modir |= LPUART_MODIR_TXRTSE_MASK; + if ( rs485_invert == true ) + modir |= LPUART_MODIR_TXRTSPOL_MASK; + } + self->uart->MODIR = modir; + if (self->tx_pin != NULL) claim_pin(self->tx_pin->pin); diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c index 71252d6776..f97a54a89d 100644 --- a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -324,7 +324,7 @@ void flexspi_nor_flash_init(FLEXSPI_Type *base) config.ahbConfig.enableAHBBufferable = true; config.ahbConfig.enableReadAddressOpt = true; config.ahbConfig.enableAHBCachable = true; - config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackFromDqsPad; + config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackInternally; //kFLEXSPI_ReadSampleClkLoopbackFromDqsPad; FLEXSPI_Init(base, &config); /* Configure flash settings according to serial flash feature. */ diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 529d2d3cef..02c5afb16e 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -53,6 +53,10 @@ //| //| :param ~microcontroller.Pin tx: the pin to transmit with, or ``None`` if this ``UART`` is receive-only. //| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only. +//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use. +//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use. +//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use. +//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin. //| :param int baudrate: the transmit and receive speed. //| :param int bits: the number of bits per byte, 7, 8 or 9. //| :param Parity parity: the parity used for error checking. @@ -82,7 +86,8 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co // https://github.com/adafruit/circuitpython/issues/1056) busio_uart_obj_t *self = m_new_ll_obj(busio_uart_obj_t); self->base.type = &busio_uart_type; - enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_receiver_buffer_size, ARG_rts, ARG_cts, ARG_rs485}; + enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_receiver_buffer_size, + ARG_rts, ARG_cts, ARG_rs485_dir,ARG_rs485_invert}; static const mp_arg_t allowed_args[] = { { MP_QSTR_tx, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_rx, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -94,7 +99,8 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co { MP_QSTR_receiver_buffer_size, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, { MP_QSTR_rts, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_cts, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_rs485, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false } }, + { MP_QSTR_rs485_dir, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none } }, + { MP_QSTR_rs485_invert, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false } }, }; 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); @@ -131,9 +137,10 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co const mcu_pin_obj_t* cts = MP_OBJ_TO_PTR(args[ARG_cts].u_obj); - bool rs485 = args[ARG_rs485].u_bool; + const mcu_pin_obj_t* rs485_dir = args[ARG_rs485_dir].u_obj; + bool rs485_invert = args[ARG_rs485_invert].u_bool; - common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485, + common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, args[ARG_baudrate].u_int, bits, parity, stop, timeout, args[ARG_receiver_buffer_size].u_int); return (mp_obj_t)self; diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h index 1d748ecc70..fe71e86689 100644 --- a/shared-bindings/busio/UART.h +++ b/shared-bindings/busio/UART.h @@ -41,7 +41,8 @@ typedef enum { // Construct an underlying UART object. extern void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, - const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, bool rs485_mode, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, + const mcu_pin_obj_t * rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, uint16_t receiver_buffer_size); diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 05567d7ab2..952e1fc10c 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -111,12 +111,17 @@ mp_obj_t common_hal_board_create_uart(void) { const mcu_pin_obj_t* cts = mp_const_none; #endif #ifdef DEFAULT_UART_IS_RS485 - const bool rs485 = true; + const mcu_pin_obj_t* rs485_dir = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RS485DIR); +#ifdef DEFAULT_UART_RS485_INVERT + const bool rs485_invert = true; +#endif #else - const bool rs485 = false; + const mcu_pin_obj_t* rs485_dir = mp_const_none; + const bool rs485_invert = true; #endif - common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485, 9600, 8, PARITY_NONE, 1, 1.0f, 64); + common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, + 9600, 8, PARITY_NONE, 1, 1.0f, 64); MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self); return MP_STATE_VM(shared_uart_bus); } From f0e5341b0f6ad09a03dec4a9d38669cc2fea6343 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Tue, 18 Feb 2020 15:21:49 +0000 Subject: [PATCH 510/531] Addition of support for imxt1010, 1050 and 1060 families --- .../boards/imxrt1020_evk/flash_config.c | 6 ++- .../mimxrt10xx/MIMXRT1011/periph.c | 20 ++++++++++ .../mimxrt10xx/MIMXRT1011/periph.h | 2 + .../mimxrt10xx/MIMXRT1062/periph.c | 40 ++++++++++++++++++- .../mimxrt10xx/MIMXRT1062/periph.h | 2 + .../supervisor/flexspi_nor_flash_ops.c | 6 ++- 6 files changed, 73 insertions(+), 3 deletions(-) diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c index b74c0b1514..80a57f17be 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c @@ -42,7 +42,11 @@ const flexspi_nor_config_t qspiflash_config = { { .tag = FLEXSPI_CFG_BLK_TAG, .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, +#ifdef BOARD_USING_SECONDARY_QSPI_PINMUX + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromInternally, +#else + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, +#endif .csHoldTime = 1u, .csSetupTime = 2u, // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c index e9d735830f..2fed6dfc61 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c @@ -113,6 +113,26 @@ const mcu_periph_obj_t mcu_uart_tx_list[9] = { PERIPH_PIN(4, 3, kIOMUXC_LPUART4_TXD_SELECT_INPUT, 1, &pin_GPIO_06), }; +const mcu_periph_obj_t mcu_uart_rts_list[4] = { + PERIPH_PIN(1, 6, 0, 0, &pin_GPIO_07), + + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_07), + + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_13), + + PERIPH_PIN(4, 3, 0, 0, &pin_GPIO_AD_13) +}; + +const mcu_periph_obj_t mcu_uart_cts_list[4] = { + PERIPH_PIN(1, 6, 0, 0, &pin_GPIO_08), + + PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_08), + + PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_14), + + PERIPH_PIN(4, 3, 0, 0, &pin_GPIO_AD_14), +}; + const mcu_pwm_obj_t mcu_pwm_list[20] = { PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 2, &pin_GPIO_02), PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 2, &pin_GPIO_SD_02), diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h index c91d5808af..a791aa2942 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h @@ -36,6 +36,8 @@ extern const mcu_periph_obj_t mcu_spi_miso_list[4]; extern const mcu_periph_obj_t mcu_uart_rx_list[9]; extern const mcu_periph_obj_t mcu_uart_tx_list[9]; +const mcu_periph_obj_t mcu_uart_rts_list[4]; +const mcu_periph_obj_t mcu_uart_cts_list[4]; extern const mcu_pwm_obj_t mcu_pwm_list[20]; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c index 3f0473a886..9a1a4ab65c 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c @@ -127,8 +127,8 @@ const mcu_periph_obj_t mcu_uart_rx_list[18] = { PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 0, &pin_GPIO_EMC_26), PERIPH_PIN(6, 2, kIOMUXC_LPUART6_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B0_03), - PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_32), PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B1_09), + PERIPH_PIN(7, 2, kIOMUXC_LPUART7_RX_SELECT_INPUT, 1, &pin_GPIO_EMC_32), PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 0, &pin_GPIO_SD_B0_05), PERIPH_PIN(8, 2, kIOMUXC_LPUART8_RX_SELECT_INPUT, 1, &pin_GPIO_AD_B1_11), @@ -163,6 +163,44 @@ const mcu_periph_obj_t mcu_uart_tx_list[18] = { PERIPH_PIN(8, 2, kIOMUXC_LPUART8_TX_SELECT_INPUT, 2, &pin_GPIO_EMC_38), }; +const mcu_periph_obj_t mcu_uart_rts_list[9] = { + PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_15), + + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_AD_B1_01), + + PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_AD_B1_05), + PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_EMC_16), + + PERIPH_PIN(4, 2, 0, 0, &pin_GPIO_EMC_18), + + PERIPH_PIN(5, 2, 0, 0, &pin_GPIO_EMC_27), + + PERIPH_PIN(6, 2, 0, 0, &pin_GPIO_EMC_29), + + PERIPH_PIN(7, 2, 0, 0, &pin_GPIO_SD_B1_07), + + PERIPH_PIN(8, 2, 0, 0, &pin_GPIO_SD_B0_03), +}; + +const mcu_periph_obj_t mcu_uart_cts_list[9] = { + PERIPH_PIN(1, 2, 0, 0, &pin_GPIO_AD_B0_14), + + PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_AD_B1_00), + + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_CTS_B_SELECT_INPUT, 0, &pin_GPIO_EMC_15), + PERIPH_PIN(3, 2, kIOMUXC_LPUART3_CTS_B_SELECT_INPUT, 1, &pin_GPIO_AD_B1_04), + + PERIPH_PIN(4, 2, 0, 0, &pin_GPIO_EMC_17), + + PERIPH_PIN(5, 2, 0, 0, &pin_GPIO_EMC_28), + + PERIPH_PIN(6, 2, 0, 0, &pin_GPIO_EMC_30), + + PERIPH_PIN(7, 2, 0, 0, &pin_GPIO_SD_B1_06), + + PERIPH_PIN(8, 2, 0, 0, &pin_GPIO_SD_B0_02), +}; + const mcu_pwm_obj_t mcu_pwm_list[67] = { PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_EMC_23), PWM_PIN(PWM1, kPWM_Module_0, kPWM_PwmA, 1, &pin_GPIO_SD_B0_00), diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h index b069ca76bb..dbda2edb19 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h @@ -36,6 +36,8 @@ extern const mcu_periph_obj_t mcu_spi_miso_list[8]; extern const mcu_periph_obj_t mcu_uart_rx_list[18]; extern const mcu_periph_obj_t mcu_uart_tx_list[18]; +const mcu_periph_obj_t mcu_uart_rts_list[9]; +const mcu_periph_obj_t mcu_uart_cts_list[9]; extern const mcu_pwm_obj_t mcu_pwm_list[67]; diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c index f97a54a89d..28d5115ac7 100644 --- a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -324,7 +324,11 @@ void flexspi_nor_flash_init(FLEXSPI_Type *base) config.ahbConfig.enableAHBBufferable = true; config.ahbConfig.enableReadAddressOpt = true; config.ahbConfig.enableAHBCachable = true; - config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackInternally; //kFLEXSPI_ReadSampleClkLoopbackFromDqsPad; +#ifdef BOARD_USING_SECONDARY_QSPI_PINMUX + config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackInternally; +#else + config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackFromDqsPad; +#endif FLEXSPI_Init(base, &config); /* Configure flash settings according to serial flash feature. */ From 490a808bf668a849eca3d42bd14254cef7a48a1a Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Tue, 18 Feb 2020 16:00:25 +0000 Subject: [PATCH 511/531] Addition of stubs for rs485/CTS/RTS handling on non-implemented chips --- ports/atmel-samd/common-hal/busio/UART.c | 13 ++++++++++--- ports/cxd56/common-hal/busio/UART.c | 12 +++++++++--- ports/nrf/common-hal/busio/UART.c | 15 +++++++++++---- ports/stm32f4/common-hal/busio/UART.c | 14 ++++++++++---- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 70857de6de..c4e70787a8 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -52,9 +52,12 @@ static void usart_async_rxc_callback(const struct usart_async_descriptor *const } void common_hal_busio_uart_construct(busio_uart_obj_t *self, - const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, - uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, - uint16_t receiver_buffer_size) { + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, + const mcu_pin_obj_t * rs485_dir, bool rs485_invert, + uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, + mp_float_t timeout, uint16_t receiver_buffer_size) { + Sercom* sercom = NULL; uint8_t sercom_index = 255; // Unset index uint32_t rx_pinmux = 0; @@ -62,6 +65,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint32_t tx_pinmux = 0; uint8_t tx_pad = 255; // Unset pad + if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) { + mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); + } + if (bits > 8) { mp_raise_NotImplementedError(translate("bytes > 8 bits not supported")); } diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c index 40ae3b7614..688a355424 100644 --- a/ports/cxd56/common-hal/busio/UART.c +++ b/ports/cxd56/common-hal/busio/UART.c @@ -53,11 +53,17 @@ STATIC busio_uart_dev_t busio_uart_dev[] = { }; void common_hal_busio_uart_construct(busio_uart_obj_t *self, - const mcu_pin_obj_t *tx, const mcu_pin_obj_t *rx, uint32_t baudrate, - uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, - uint16_t receiver_buffer_size) { + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, + const mcu_pin_obj_t * rs485_dir, bool rs485_invert, + uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, + mp_float_t timeout, uint16_t receiver_buffer_size) { struct termios tio; + if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) { + mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); + } + if (bits != 8) { mp_raise_ValueError(translate("Could not initialize UART")); } diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index d79b65ff81..c422a187f6 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -128,10 +128,17 @@ void uart_reset(void) { } } -void common_hal_busio_uart_construct (busio_uart_obj_t *self, - const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, - uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, - uint16_t receiver_buffer_size) { +void common_hal_busio_uart_construct(busio_uart_obj_t *self, + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, + const mcu_pin_obj_t * rs485_dir, bool rs485_invert, + uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, + mp_float_t timeout, uint16_t receiver_buffer_size) { + + if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) { + mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); + } + // Find a free UART peripheral. self->uarte = NULL; for (size_t i = 0 ; i < MP_ARRAY_SIZE(nrfx_uartes); i++) { diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index bfa541c17d..3c19092591 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -71,10 +71,12 @@ void uart_reset(void) { uart_clock_disable(ALL_UARTS); } -void common_hal_busio_uart_construct(busio_uart_obj_t* self, - const mcu_pin_obj_t* tx, const mcu_pin_obj_t* rx, uint32_t baudrate, - uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, - uint16_t receiver_buffer_size) { +void common_hal_busio_uart_construct(busio_uart_obj_t *self, + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, + const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, + const mcu_pin_obj_t * rs485_dir, bool rs485_invert, + uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, + mp_float_t timeout, uint16_t receiver_buffer_size) { //match pins to UART objects USART_TypeDef * USARTx; @@ -84,6 +86,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self, bool uart_taken = false; uint8_t uart_index = 0; //origin 0 corrected + if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) { + mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); + } + //Can have both pins, or either if ((tx != mp_const_none) && (rx != mp_const_none)) { //normal find loop if both pins exist From 24405cabafd4c9481118cd77e1a13ee98ab48565 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Wed, 19 Feb 2020 00:07:01 +0000 Subject: [PATCH 512/531] Edits as a result of review --- ports/atmel-samd/common-hal/busio/UART.c | 2 +- ports/cxd56/common-hal/busio/UART.c | 2 +- ports/mimxrt10xx/common-hal/busio/UART.c | 37 +++++++++---------- .../mimxrt10xx/MIMXRT1011/periph.h | 4 +- .../mimxrt10xx/MIMXRT1062/periph.h | 4 +- ports/nrf/common-hal/busio/UART.c | 2 +- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index c4e70787a8..fb9968605f 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -65,7 +65,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint32_t tx_pinmux = 0; uint8_t tx_pad = 255; // Unset pad - if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) { + if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) { mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); } diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c index 688a355424..3ed9809529 100644 --- a/ports/cxd56/common-hal/busio/UART.c +++ b/ports/cxd56/common-hal/busio/UART.c @@ -60,7 +60,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, mp_float_t timeout, uint16_t receiver_buffer_size) { struct termios tio; - if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) { + if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) { mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); } diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index 3609a99982..4fd7afecbc 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -123,41 +123,38 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // For IMXRT the RTS pin is used for RS485 direction rts = rs485_dir; } - else - { - if (rs485_invert == true) { - mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode")); - } + else { + if (rs485_invert) { + mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode")); } + } // Now check for RTS/CTS (or overloaded RS485 direction) pin(s) const uint32_t rts_count = sizeof(mcu_uart_rts_list) / sizeof(mcu_periph_obj_t); const uint32_t cts_count = sizeof(mcu_uart_cts_list) / sizeof(mcu_periph_obj_t); if (rts != mp_const_none) { - for (uint32_t i=0; i < rts_count; ++i) - { - if (mcu_uart_rts_list[i].bank_idx == self->rx_pin->bank_idx) { - if (mcu_uart_rts_list[i].pin == rts) { - self->rts_pin = &mcu_uart_rts_list[i]; - break; - } + for (uint32_t i=0; i < rts_count; ++i) { + if (mcu_uart_rts_list[i].bank_idx == self->rx_pin->bank_idx) { + if (mcu_uart_rts_list[i].pin == rts) { + self->rts_pin = &mcu_uart_rts_list[i]; + break; } } + } if (self->rts_pin == NULL) mp_raise_ValueError(translate("Selected RTS pin not valid")); } if (cts != mp_const_none) { - for (uint32_t i=0; i < cts_count; ++i) - { - if (mcu_uart_cts_list[i].bank_idx == self->rx_pin->bank_idx) { - if (mcu_uart_cts_list[i].pin == cts) { - self->cts_pin = &mcu_uart_cts_list[i]; - break; - } + for (uint32_t i=0; i < cts_count; ++i) { + if (mcu_uart_cts_list[i].bank_idx == self->rx_pin->bank_idx) { + if (mcu_uart_cts_list[i].pin == cts) { + self->cts_pin = &mcu_uart_cts_list[i]; + break; } } + } if (self->cts_pin == NULL) mp_raise_ValueError(translate("Selected CTS pin not valid")); } @@ -192,7 +189,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint32_t modir = (self->uart->MODIR) & ~(LPUART_MODIR_TXRTSPOL_MASK | LPUART_MODIR_TXRTSE_MASK); if (rs485_dir != mp_const_none) { modir |= LPUART_MODIR_TXRTSE_MASK; - if ( rs485_invert == true ) + if (rs485_invert) modir |= LPUART_MODIR_TXRTSPOL_MASK; } self->uart->MODIR = modir; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h index a791aa2942..d6d4895371 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h @@ -36,8 +36,8 @@ extern const mcu_periph_obj_t mcu_spi_miso_list[4]; extern const mcu_periph_obj_t mcu_uart_rx_list[9]; extern const mcu_periph_obj_t mcu_uart_tx_list[9]; -const mcu_periph_obj_t mcu_uart_rts_list[4]; -const mcu_periph_obj_t mcu_uart_cts_list[4]; +extern const mcu_periph_obj_t mcu_uart_rts_list[4]; +extern const mcu_periph_obj_t mcu_uart_cts_list[4]; extern const mcu_pwm_obj_t mcu_pwm_list[20]; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h index dbda2edb19..45b92f2473 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h @@ -36,8 +36,8 @@ extern const mcu_periph_obj_t mcu_spi_miso_list[8]; extern const mcu_periph_obj_t mcu_uart_rx_list[18]; extern const mcu_periph_obj_t mcu_uart_tx_list[18]; -const mcu_periph_obj_t mcu_uart_rts_list[9]; -const mcu_periph_obj_t mcu_uart_cts_list[9]; +extern const mcu_periph_obj_t mcu_uart_rts_list[9]; +extern const mcu_periph_obj_t mcu_uart_cts_list[9]; extern const mcu_pwm_obj_t mcu_pwm_list[67]; diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index c422a187f6..933faf17b8 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -135,7 +135,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, uint16_t receiver_buffer_size) { - if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) { + if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) { mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device")); } From 63bcd52a5a9462c949d4f7bbb9d1ec4d6bb76af8 Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Wed, 19 Feb 2020 05:14:27 +0100 Subject: [PATCH 513/531] Add Arduino Nano 33 IoT documentation --- ports/atmel-samd/README.rst | 79 +++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst index 9afa19b837..118b174061 100644 --- a/ports/atmel-samd/README.rst +++ b/ports/atmel-samd/README.rst @@ -11,6 +11,7 @@ CircuitPython. Supported boards include: - Adafruit M0 Bluefruit LE - Arduino Zero - Arduino MKR Zero +- Arduino Nano 33 IoT Pinout @@ -22,51 +23,51 @@ different names. The table below matches the pin order in and omits the pins only available on the largest package because all supported boards use smaller version. -===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================ +===================== =================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================ `microcontroller.pin` `board` ---------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Datasheet arduino_mkrzero arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express sparkfun_samd21_mini sparkfun_samd21_dev trinket_m0 -===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================ -PA00 ``ACCELEROMETER_SDA`` ``APA102_MOSI`` ``APA102_MOSI`` -PA01 ``ACCELEROMETER_SCL`` ``APA102_SCK`` ``APA102_SCK`` -PA02 ``A0`` ``A0`` ``A0`` / ``SPEAKER`` ``A0`` ``A0`` ``A0`` ``A0`` / ``D1`` ``A0`` ``A0`` ``A0`` ``D1`` / ``A0`` +--------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +Datasheet arduino_mkrzero arduino_nano_33_iot arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express sparkfun_samd21_mini sparkfun_samd21_dev trinket_m0 +===================== =================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================ +PA00 ``ACCELEROMETER_SDA`` ``APA102_MOSI`` ``APA102_MOSI`` +PA01 ``ACCELEROMETER_SCL`` ``APA102_SCK`` ``APA102_SCK`` +PA02 ``A0`` ``A0`` ``A0`` ``A0`` / ``SPEAKER`` ``A0`` ``A0`` ``A0`` ``A0`` / ``D1`` ``A0`` ``A0`` ``A0`` ``D1`` / ``A0`` PA03 -PB08 ``L`` ``A1`` ``A7`` / ``TX`` ``A1`` ``A1`` ``A1`` ``A1`` ``A1`` ``A1`` -PB09 ``BATTERY`` ``A2`` ``A6`` / ``RX`` ``A2`` ``A2`` ``A2`` ``A2`` ``A2`` ``A2`` -PA04 ``A3`` ``A3`` ``IR_PROXIMITY`` ``A3`` ``A3`` ``A3`` ``D0`` / ``TX`` / ``SDA`` ``A3`` ``A3`` ``A3`` -PA05 ``A4`` ``A4`` ``A1`` ``A4`` ``A4`` ``A4`` ``D2`` / ``RX`` / ``SCL`` ``A4`` ``A4`` -PA06 ``A5`` ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D8`` ``D8`` ``D4`` / ``TX`` -PA07 ``A6`` ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX`` -PA08 ``D11`` / ``SDA`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D4`` ``D4`` ``D0`` / ``SDA`` -PA09 ``D12`` / ``SCL`` ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D3`` ``D3`` ``D2`` / ``SCL`` -PA10 ``D2`` ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13`` -PA11 ``D3`` ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` -PB10 ``D4`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` -PB11 ``D5`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` -PA12 ``SD_MOSI`` ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` -PA13 ``SD_SCK`` ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS`` ``D38`` -PA14 ``SD_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` ``D2`` ``D2`` -PA15 ``SD_MISO`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` -PA16 ``D8`` / ``MOSI`` ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11`` ``D11`` / ``MOSI`` ``D11`` -PA17 ``D9`` / ``SCK`` ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13`` ``D13`` / ``SCK`` / ``BLUE_LED`` ``D13`` / ``BLUE_LED`` -PA18 ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` -PA19 ``D10`` / ``MISO`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` / ``MISO`` ``D12`` -PA20 ``D6`` ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6`` -PA21 ``D7`` ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7`` ``D7`` ``D7`` -PA22 ``D0`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` -PA23 ``D1`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` ``SCL`` ``SCL`` +PB08 ``L`` ``A4`` / ``SDA`` ``A1`` ``A7`` / ``TX`` ``A1`` ``A1`` ``A1`` ``A1`` ``A1`` ``A1`` +PB09 ``BATTERY`` ``A5`` / ``SCL`` ``A2`` ``A6`` / ``RX`` ``A2`` ``A2`` ``A2`` ``A2`` ``A2`` ``A2`` +PA04 ``A3`` ``D6`` ``A3`` ``IR_PROXIMITY`` ``A3`` ``A3`` ``A3`` ``D0`` / ``TX`` / ``SDA`` ``A3`` ``A3`` ``A3`` +PA05 ``A4`` ``D5`` ``A4`` ``A1`` ``A4`` ``A4`` ``A4`` ``D2`` / ``RX`` / ``SCL`` ``A4`` ``A4`` +PA06 ``A5`` ``D7`` ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D8`` ``D8`` ``D4`` / ``TX`` +PA07 ``A6`` ``D4`` ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX`` +PA08 ``D11`` / ``SDA`` ``NINA_RESETN`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D4`` ``D4`` ``D0`` / ``SDA`` +PA09 ``D12`` / ``SCL`` ``A6`` ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D3`` ``D3`` ``D2`` / ``SCL`` +PA10 ``D2`` ``A3`` ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13`` +PA11 ``D3`` ``A2`` ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` +PB10 ``D4`` ``D2`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` +PB11 ``D5`` ``D3`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` +PA12 ``SD_MOSI`` ``NINA_MOSI`` ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` +PA13 ``SD_SCK`` ``NINA_MISO`` ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS`` ``D38`` +PA14 ``SD_CS`` ``NINA_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` ``D2`` ``D2`` +PA15 ``SD_MISO`` ``NINA_SCK`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` +PA16 ``D8`` / ``MOSI`` ``D11`` / ``MOSI`` ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11`` ``D11`` / ``MOSI`` ``D11`` +PA17 ``D9`` / ``SCK`` ``D13`` / ``SCK`` ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13`` ``D13`` / ``SCK`` / ``BLUE_LED`` ``D13`` / ``BLUE_LED`` +PA18 ``D8`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` +PA19 ``D10`` / ``MISO`` ``D12`` / ``MISO`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` / ``MISO`` ``D12`` +PA20 ``D6`` ``D9`` ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6`` +PA21 ``D7`` ``D10`` ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7`` ``D7`` ``D7`` +PA22 ``D0`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` +PA23 ``D1`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` ``SCL`` ``SCL`` PA24 PA25 -PB22 ``D14`` / ``TX`` ``FLASH_CS`` ``D30`` / ``TX1`` -PB23 ``D13`` / ``RX`` ``NEOPIXEL`` / ``D8`` ``D31`` / ``RX1`` -PA27 ``SD_CD`` ``GREEN_LED`` ``GREEN_LED`` -PA28 ``BUTTON_A`` / ``D4`` +PB22 ``D14`` / ``TX`` ``D1`` / ``TX`` ``FLASH_CS`` ``D30`` / ``TX1`` +PB23 ``D13`` / ``RX`` ``D0`` / ``RX`` ``NEOPIXEL`` / ``D8`` ``D31`` / ``RX1`` +PA27 ``SD_CD`` ``NINA_GPIO0`` ``GREEN_LED`` ``GREEN_LED`` +PA28 ``NINA_ACK`` ``BUTTON_A`` / ``D4`` PA29 -PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL`` +PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL`` PA31 -PB02 ``A1`` ``A5`` ``A5`` / ``SDA`` ``A5`` ``A5`` ``A5`` ``A5`` ``A5`` -PB03 ``A2`` ``A4`` / ``SCL`` ``YELLOW_LED`` ``YELLOW_LED`` -===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================ +PB02 ``A1`` ``A1`` ``A5`` ``A5`` / ``SDA`` ``A5`` ``A5`` ``A5`` ``A5`` ``A5`` +PB03 ``A2`` ``A7`` ``A4`` / ``SCL`` ``YELLOW_LED`` ``YELLOW_LED`` +===================== =================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================ Here is a table about which pins can do what in CircuitPython terms. However, just because something is listed, doesn't mean it will always work. Existing use From fba0b302ff5ed469ea2ebf3703d6ba4b8a9786b1 Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Wed, 19 Feb 2020 08:56:06 +0100 Subject: [PATCH 514/531] Add Arduino Nano 33 IoT support --- .../boards/arduino_nano_33_iot/board.c | 40 +++++++++++++++++++ .../arduino_nano_33_iot/mpconfigboard.h | 22 ++++++++++ .../arduino_nano_33_iot/mpconfigboard.mk | 13 ++++++ .../boards/arduino_nano_33_iot/pins.c | 37 +++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 ports/atmel-samd/boards/arduino_nano_33_iot/board.c create mode 100644 ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/arduino_nano_33_iot/pins.c diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/board.c b/ports/atmel-samd/boards/arduino_nano_33_iot/board.c new file mode 100644 index 0000000000..770bc82593 --- /dev/null +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) +{ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.h b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.h new file mode 100644 index 0000000000..847e1a6792 --- /dev/null +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.h @@ -0,0 +1,22 @@ +#define MICROPY_HW_BOARD_NAME "Arduino Nano 33 IoT" +#define MICROPY_HW_MCU_NAME "samd21g18" + +#define MICROPY_HW_LED_STATUS (&pin_PA17) + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define DEFAULT_I2C_BUS_SCL (&pin_PB09) +#define DEFAULT_I2C_BUS_SDA (&pin_PB08) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA17) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA16) +#define DEFAULT_SPI_BUS_MISO (&pin_PA19) + +#define DEFAULT_UART_BUS_RX (&pin_PB23) +#define DEFAULT_UART_BUS_TX (&pin_PB22) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk new file mode 100644 index 0000000000..8a29b0ace0 --- /dev/null +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk @@ -0,0 +1,13 @@ +USB_VID = 0x2341 +USB_PID = 0x8057 +USB_PRODUCT = "Arduino Nano 33 IoT" +USB_MANUFACTURER = "Arduino" + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 + +SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c b/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c new file mode 100644 index 0000000000..3478db9dff --- /dev/null +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c @@ -0,0 +1,37 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA21) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 4615d172c7dc9fc8b205d7d744af70940d704ee2 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Wed, 19 Feb 2020 08:45:07 +0000 Subject: [PATCH 515/531] Addition of translation files --- locale/ID.po | 23 ++++++++++++++++++++++- locale/circuitpython.pot | 23 ++++++++++++++++++++++- locale/de_DE.po | 23 ++++++++++++++++++++++- locale/en_US.po | 23 ++++++++++++++++++++++- locale/en_x_pirate.po | 23 ++++++++++++++++++++++- locale/es.po | 23 ++++++++++++++++++++++- locale/fil.po | 23 ++++++++++++++++++++++- locale/fr.po | 23 ++++++++++++++++++++++- locale/it_IT.po | 23 ++++++++++++++++++++++- locale/ko.po | 23 ++++++++++++++++++++++- locale/pl.po | 23 ++++++++++++++++++++++- locale/pt_BR.po | 23 ++++++++++++++++++++++- locale/zh_Latn_pinyin.po | 23 ++++++++++++++++++++++- 13 files changed, 286 insertions(+), 13 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 182dd2679d..01f461392f 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -462,6 +462,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "" @@ -1183,6 +1187,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1192,6 +1200,11 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1255,6 +1268,14 @@ msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index e067213560..354dbc4ba4 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-12 11:31-0800\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -452,6 +452,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "" @@ -1169,6 +1173,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1178,6 +1186,11 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1239,6 +1252,14 @@ msgstr "" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/de_DE.po b/locale/de_DE.po index a5bb053abd..056f56d749 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -456,6 +456,10 @@ msgstr "Reset zum bootloader nicht möglich da bootloader nicht vorhanden" msgid "Cannot set value when direction is input." msgstr "Der Wert kann nicht gesetzt werden, wenn die Richtung input ist." +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "" @@ -1186,6 +1190,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1195,6 +1203,11 @@ msgstr "Die RTC-Kalibrierung wird auf diesem Board nicht unterstützt" msgid "RTC is not supported on this board" msgstr "Eine RTC wird auf diesem Board nicht unterstützt" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1256,6 +1269,14 @@ msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/en_US.po b/locale/en_US.po index 5485810a31..58c798ce4b 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -452,6 +452,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "" @@ -1169,6 +1173,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1178,6 +1186,11 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1239,6 +1252,14 @@ msgstr "" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 517d067dad..e2ee9c887d 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -456,6 +456,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "" @@ -1173,6 +1177,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1182,6 +1190,11 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1243,6 +1256,14 @@ msgstr "" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/es.po b/locale/es.po index 76f0799249..8d445a469a 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -458,6 +458,10 @@ msgstr "No se puede reiniciar a bootloader porque no hay bootloader presente." msgid "Cannot set value when direction is input." msgstr "No se puede asignar un valor cuando la dirección es input." +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "Cannot subclass slice" @@ -1185,6 +1189,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1194,6 +1202,11 @@ msgstr "Calibración de RTC no es soportada en esta placa" msgid "RTC is not supported on this board" msgstr "RTC no soportado en esta placa" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1256,6 +1269,14 @@ msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/fil.po b/locale/fil.po index 187c31b538..b8b61d723b 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -460,6 +460,10 @@ msgstr "Hindi ma-reset sa bootloader dahil walang bootloader." msgid "Cannot set value when direction is input." msgstr "Hindi ma i-set ang value kapag ang direksyon ay input." +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "Hindi magawa ang sublcass slice" @@ -1191,6 +1195,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1200,6 +1208,11 @@ msgstr "RTC calibration ay hindi supportado ng board na ito" msgid "RTC is not supported on this board" msgstr "Hindi supportado ang RTC sa board na ito" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1262,6 +1275,14 @@ msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/fr.po b/locale/fr.po index 8b66e5c0d6..625b4e91aa 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -465,6 +465,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "Impossible d'affecter une valeur quand la direction est 'input'." +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "On ne peut faire de sous-classes de tranches" @@ -1204,6 +1208,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1213,6 +1221,11 @@ msgstr "étalonnage de la RTC non supportée sur cette carte" msgid "RTC is not supported on this board" msgstr "RTC non supportée sur cette carte" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1276,6 +1289,14 @@ msgstr "Taux d'échantillonage trop élevé. Doit être inf. à %d" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/it_IT.po b/locale/it_IT.po index 3671a6ec23..93af9bdb86 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -461,6 +461,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "non si può impostare un valore quando direzione è input" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "Impossibile subclasare slice" @@ -1200,6 +1204,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1209,6 +1217,11 @@ msgstr "calibrazione RTC non supportata su questa scheda" msgid "RTC is not supported on this board" msgstr "RTC non supportato su questa scheda" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1273,6 +1286,14 @@ msgstr "" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/ko.po b/locale/ko.po index f1f550775d..04ab849d43 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -456,6 +456,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "" @@ -1173,6 +1177,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1182,6 +1190,11 @@ msgstr "" msgid "RTC is not supported on this board" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1243,6 +1256,14 @@ msgstr "" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/pl.po b/locale/pl.po index ee95b2e7d1..d766191822 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -455,6 +455,10 @@ msgstr "Nie można zrestartować -- nie ma bootloadera." msgid "Cannot set value when direction is input." msgstr "Nie można ustawić wartości w trybie wejścia" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "Nie można dziedziczyć ze slice" @@ -1174,6 +1178,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1183,6 +1191,11 @@ msgstr "Brak obsługi kalibracji RTC" msgid "RTC is not supported on this board" msgstr "Brak obsługi RTC" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1244,6 +1257,14 @@ msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index b94b14fcd5..b948003a18 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-10 11:46-0500\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -457,6 +457,10 @@ msgstr "" msgid "Cannot set value when direction is input." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "" @@ -1185,6 +1189,10 @@ msgstr "" msgid "RNG Init Error" msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1194,6 +1202,11 @@ msgstr "A calibração RTC não é suportada nesta placa" msgid "RTC is not supported on this board" msgstr "O RTC não é suportado nesta placa" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "" @@ -1256,6 +1269,14 @@ msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" msgid "Scan already in progess. Stop with stop_scan." msgstr "" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index dcb78828c6..9a9473436f 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-12 11:31-0800\n" +"POT-Creation-Date: 2020-02-19 08:44+0000\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -461,6 +461,10 @@ msgstr "Wúfǎ chóng zhì wèi bootloader, yīnwèi méiyǒu bootloader cúnzà msgid "Cannot set value when direction is input." msgstr "Dāng fāngxiàng xiàng nèi shí, bùnéng shèzhì gāi zhí." +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + #: py/objslice.c msgid "Cannot subclass slice" msgstr "Wúfǎ zi fēnlèi" @@ -1188,6 +1192,10 @@ msgstr "RNG qǔxiāo chūshǐhuà cuòwù" msgid "RNG Init Error" msgstr "RNG chūshǐhuà cuòwù" +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + #: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c #: ports/nrf/common-hal/rtc/RTC.c msgid "RTC calibration is not supported on this board" @@ -1197,6 +1205,11 @@ msgstr "Cǐ bǎn bù zhīchí RTC jiàozhǔn" msgid "RTC is not supported on this board" msgstr "Cǐ bǎn bù zhīchí RTC" +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/nrf/common-hal/busio/UART.c ports/stm32f4/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + #: ports/stm32f4/common-hal/os/__init__.c msgid "Random number generation error" msgstr "Suíjī shù shēngchéng cuòwù" @@ -1258,6 +1271,14 @@ msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" 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ǐ." +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected CTS pin not valid" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Selected RTS pin not valid" +msgstr "" + #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "Serializer in use" From 1ed5afeaec9a3c76930aa32e3a8bc0a63b61b6d9 Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Wed, 19 Feb 2020 10:22:57 +0100 Subject: [PATCH 516/531] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d389845a2d..f88630cdd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,6 +126,7 @@ jobs: - "arduino_mkr1300" - "arduino_mkrzero" - "arduino_nano_33_ble" + - "arduino_nano_33_iot" - "arduino_zero" - "bast_pro_mini_m0" - "capablerobot_usbhub" From aa0cf38084035c9b6080a4a97385dbcd6ae475c8 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Wed, 19 Feb 2020 21:58:10 +0100 Subject: [PATCH 517/531] mimxrt10xx: Add Feather M7 1011 board config --- .github/workflows/build.yml | 1 + .../mimxrt10xx/boards/feather_m7_1011/board.c | 39 ++++++ .../boards/feather_m7_1011/flash_config.c | 122 ++++++++++++++++++ .../boards/feather_m7_1011/mpconfigboard.h | 20 +++ .../boards/feather_m7_1011/mpconfigboard.mk | 8 ++ .../mimxrt10xx/boards/feather_m7_1011/pins.c | 43 ++++++ ports/mimxrt10xx/linking/flash/W25Q32JV.ld | 1 + 7 files changed, 234 insertions(+) create mode 100644 ports/mimxrt10xx/boards/feather_m7_1011/board.c create mode 100644 ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c create mode 100644 ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.h create mode 100644 ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.mk create mode 100644 ports/mimxrt10xx/boards/feather_m7_1011/pins.c create mode 100644 ports/mimxrt10xx/linking/flash/W25Q32JV.ld diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ebe4753ea..ea99de249b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -157,6 +157,7 @@ jobs: - "feather_m0_rfm9x" - "feather_m0_supersized" - "feather_m4_express" + - "feather_m7_1011" - "feather_mimxrt1011" - "feather_mimxrt1062" - "feather_nrf52840_express" diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/board.c b/ports/mimxrt10xx/boards/feather_m7_1011/board.c new file mode 100644 index 0000000000..52dd498b3f --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_m7_1011/board.c @@ -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 + * 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 "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c new file mode 100644 index 0000000000..b74c0b1514 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c @@ -0,0 +1,122 @@ +/* + * Copyright 2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fsl_flexspi_nor_boot.h" +#include "fsl_flexspi_nor_config.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 */ +}; + +__attribute__((section(".boot_hdr.conf"))) +// Values copied from https://github.com/PaulStoffregen/cores/blob/ddb23fa5d97dac763bc06e11b9b41f026bd51f0a/teensy4/bootdata.c#L39 +const flexspi_nor_config_t qspiflash_config = { + .memConfig = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad, + .csHoldTime = 1u, + .csSetupTime = 2u, + // Enable DDR mode, Wordaddressable, Safe configuration, Differential clock + .deviceType = kFlexSpiDeviceType_SerialNOR, + .sflashPadType = kSerialFlash_4Pads, + .serialClkFreq = kFlexSpiSerialClk_60MHz, // 03 + .sflashA1Size = FLASH_SIZE, + .lookupTable = + { + // FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) + // (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | + // FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + // Read LUTs + FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18), + FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04), + 0, + 0, + + 0x24040405, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000406, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x08180420, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x081804D8, + 0, + 0, + 0, + + 0x08180402, + 0x00002004, + 0, + 0, + + 0, + 0, + 0, + 0, + + 0x00000460, + }, + }, + .pageSize = 256u, + .sectorSize = 4u * 1024u, + .ipcmdSerialClkFreq = kFlexSpiSerialClk_30MHz, + .blockSize = 0x00010000, + .isUniformBlockSize = false, +}; diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.h b/ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.h new file mode 100644 index 0000000000..e96ec13dd9 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.h @@ -0,0 +1,20 @@ +#define MICROPY_HW_BOARD_NAME "Feather MIMXRT1011" +#define MICROPY_HW_MCU_NAME "IMXRT1011DAE5A" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO_00) + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (4 * 1024 * 1024) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO_12) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO_11) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO_AD_06) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO_AD_04) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO_AD_03) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_01) +#define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_02) diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.mk b/ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.mk new file mode 100644 index 0000000000..670b48b602 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_m7_1011/mpconfigboard.mk @@ -0,0 +1,8 @@ +USB_VID = 0x239A +USB_PID = 0x8092 +USB_PRODUCT = "Feather M7 1011" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = MIMXRT1011DAE5A +CHIP_FAMILY = MIMXRT1011 +FLASH = W25Q32JV diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c new file mode 100644 index 0000000000..09e3217614 --- /dev/null +++ b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c @@ -0,0 +1,43 @@ +#include "shared-bindings/board/__init__.h" + +#include "boards/board.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // Analog + { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO_AD_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO_AD_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO_AD_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO_AD_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO_AD_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO_AD_05) }, + + // Digital + { MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO_10) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO_09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO_08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO_07) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO_05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO_04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO_AD_00) }, + + // SPI + { MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO_AD_06) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO_AD_03) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO_AD_04) }, + + // UART + { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO_AD_02) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO_AD_01) }, + + // I2C + { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO_11) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO_12) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO_00) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/mimxrt10xx/linking/flash/W25Q32JV.ld b/ports/mimxrt10xx/linking/flash/W25Q32JV.ld new file mode 100644 index 0000000000..3fa395c665 --- /dev/null +++ b/ports/mimxrt10xx/linking/flash/W25Q32JV.ld @@ -0,0 +1 @@ +_ld_flash_size = 4M; From feac87901ab738bae94b1bd5a1265a2084acc37a Mon Sep 17 00:00:00 2001 From: arturo182 Date: Wed, 19 Feb 2020 22:23:32 +0100 Subject: [PATCH 518/531] mimxrt10xx: Enable displayio Closes #2466 --- ports/mimxrt10xx/background.c | 3 +- .../common-hal/displayio/ParallelBus.c | 68 +++++++++++++++++++ .../common-hal/displayio/ParallelBus.h | 36 ++++++++++ .../common-hal/microcontroller/Pin.c | 4 ++ ports/mimxrt10xx/mpconfigport.mk | 1 - 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 ports/mimxrt10xx/common-hal/displayio/ParallelBus.c create mode 100644 ports/mimxrt10xx/common-hal/displayio/ParallelBus.h diff --git a/ports/mimxrt10xx/background.c b/ports/mimxrt10xx/background.c index c0b2176853..71dd795216 100644 --- a/ports/mimxrt10xx/background.c +++ b/ports/mimxrt10xx/background.c @@ -37,9 +37,8 @@ #include "supervisor/linker.h" #include "supervisor/shared/stack.h" -// TODO #ifdef CIRCUITPY_DISPLAYIO -//#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/__init__.h" #endif volatile uint64_t last_finished_tick = 0; diff --git a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c b/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c new file mode 100644 index 0000000000..87fc511af1 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c @@ -0,0 +1,68 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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 "shared-bindings/displayio/ParallelBus.h" + +#include + +#include "common-hal/microcontroller/Pin.h" +#include "py/runtime.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/microcontroller/__init__.h" + +#include "tick.h" + +void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self, + const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select, + const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) { + + mp_raise_NotImplementedError(translate("ParallelBus not yet supported")); +} + +void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self) { + +} + +bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { + return false; +} + +bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { + return false; +} + +bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { + + return false; +} + +void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) { + +} + +void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { + +} diff --git a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.h b/ports/mimxrt10xx/common-hal/displayio/ParallelBus.h new file mode 100644 index 0000000000..845e44df06 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/displayio/ParallelBus.h @@ -0,0 +1,36 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H + +#include "common-hal/digitalio/DigitalInOut.h" + +typedef struct { + mp_obj_base_t base; +} displayio_parallelbus_obj_t; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index 04dd997393..21e61d29d4 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -224,3 +224,7 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin) { void common_hal_reset_pin(const mcu_pin_obj_t* pin) { // reset_pin_number(pin->number); } + +void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) { +// never_reset_pin_number(pin->port, pin->number); +} diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index b928ce3bb4..5881ac3020 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -20,7 +20,6 @@ USB_MSC_MAX_PACKET_SIZE = 512 INTERNAL_FLASH_FILESYSTEM = 1 -CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_FREQUENCYIO = 0 From e8f71415644846ca0f4195afcad4a9e8b2469ded Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 20 Feb 2020 12:15:56 -0800 Subject: [PATCH 519/531] Disable BLE file service for now Fixes #2633 --- py/circuitpy_mpconfig.mk | 5 +++++ supervisor/shared/bluetooth.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 93e5982d5c..d6e033daf3 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -328,6 +328,11 @@ CIRCUITPY_SERIAL_BLE = 0 endif CFLAGS += -DCIRCUITPY_SERIAL_BLE=$(CIRCUITPY_SERIAL_BLE) +ifndef CIRCUITPY_BLE_FILE_SERVICE +CIRCUITPY_BLE_FILE_SERVICE = 0 +endif +CFLAGS += -DCIRCUITPY_BLE_FILE_SERVICE=$(CIRCUITPY_BLE_FILE_SERVICE) + # REPL over UART ifndef CIRCUITPY_SERIAL_UART CIRCUITPY_SERIAL_UART = 0 diff --git a/supervisor/shared/bluetooth.c b/supervisor/shared/bluetooth.c index 18caa2eb4a..b463160cf5 100644 --- a/supervisor/shared/bluetooth.c +++ b/supervisor/shared/bluetooth.c @@ -64,6 +64,9 @@ mp_obj_list_t characteristic_list; mp_obj_t characteristic_list_items[4]; void supervisor_bluetooth_start_advertising(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return; + #endif bool is_connected = common_hal_bleio_adapter_get_connected(&common_hal_bleio_adapter_obj); if (is_connected) { return; @@ -79,6 +82,10 @@ void supervisor_bluetooth_start_advertising(void) { } void supervisor_start_bluetooth(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return; + #endif + common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, true); supervisor_ble_service_uuid.base.type = &bleio_uuid_type; @@ -203,6 +210,9 @@ uint32_t current_command[1024 / sizeof(uint32_t)]; volatile size_t current_offset; void supervisor_bluetooth_background(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return; + #endif if (!run_ble_background) { return; } @@ -296,6 +306,9 @@ void supervisor_bluetooth_background(void) { // This happens in an interrupt so we need to be quick. bool supervisor_bluetooth_hook(ble_evt_t *ble_evt) { + #if !CIRCUITPY_BLE_FILE_SERVICE + return false; + #endif // Catch writes to filename or contents. Length is read-only. bool done = false; From 634d24691093950d08efc029eefb65fa15ef6865 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 20 Feb 2020 16:00:21 -0500 Subject: [PATCH 520/531] relicense nrf SPI.c to MIT --- ports/nrf/common-hal/busio/SPI.c | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index 43aced1a5f..b4ebddde1d 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -1,25 +1,28 @@ /* - * SPI Master library for nRF5x. + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) * * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec - * Copyright (c) 2017 hathach - * Copyright (c) 2016 Sandeep Mistry All right reserved. - * Copyright (c) 2015 Arduino LLC * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * 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: * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * 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 From 39ec5d0e51a26b3a8a3287e9e8222efadd30cfee Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Fri, 21 Feb 2020 01:34:52 +0100 Subject: [PATCH 521/531] Add NINA pins --- ports/atmel-samd/README.rst | 14 +++++++------- .../boards/arduino_nano_33_iot/pins.c | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst index 118b174061..31442e1d1c 100644 --- a/ports/atmel-samd/README.rst +++ b/ports/atmel-samd/README.rst @@ -38,16 +38,16 @@ PA04 ``A3`` ``D6`` ``A3`` PA05 ``A4`` ``D5`` ``A4`` ``A1`` ``A4`` ``A4`` ``A4`` ``D2`` / ``RX`` / ``SCL`` ``A4`` ``A4`` PA06 ``A5`` ``D7`` ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D8`` ``D8`` ``D4`` / ``TX`` PA07 ``A6`` ``D4`` ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX`` -PA08 ``D11`` / ``SDA`` ``NINA_RESETN`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D4`` ``D4`` ``D0`` / ``SDA`` +PA08 ``D11`` / ``SDA`` ``ESP_RESET`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D4`` ``D4`` ``D0`` / ``SDA`` PA09 ``D12`` / ``SCL`` ``A6`` ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D3`` ``D3`` ``D2`` / ``SCL`` PA10 ``D2`` ``A3`` ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13`` PA11 ``D3`` ``A2`` ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` PB10 ``D4`` ``D2`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` PB11 ``D5`` ``D3`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` -PA12 ``SD_MOSI`` ``NINA_MOSI`` ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` -PA13 ``SD_SCK`` ``NINA_MISO`` ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS`` ``D38`` -PA14 ``SD_CS`` ``NINA_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` ``D2`` ``D2`` -PA15 ``SD_MISO`` ``NINA_SCK`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` +PA12 ``SD_MOSI`` ``ESP_MOSI`` ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` +PA13 ``SD_SCK`` ``ESP_MISO`` ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS`` ``D38`` +PA14 ``SD_CS`` ``ESP_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` ``D2`` ``D2`` +PA15 ``SD_MISO`` ``ESP_SCK`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` PA16 ``D8`` / ``MOSI`` ``D11`` / ``MOSI`` ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11`` ``D11`` / ``MOSI`` ``D11`` PA17 ``D9`` / ``SCK`` ``D13`` / ``SCK`` ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13`` ``D13`` / ``SCK`` / ``BLUE_LED`` ``D13`` / ``BLUE_LED`` PA18 ``D8`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` @@ -60,8 +60,8 @@ PA24 PA25 PB22 ``D14`` / ``TX`` ``D1`` / ``TX`` ``FLASH_CS`` ``D30`` / ``TX1`` PB23 ``D13`` / ``RX`` ``D0`` / ``RX`` ``NEOPIXEL`` / ``D8`` ``D31`` / ``RX1`` -PA27 ``SD_CD`` ``NINA_GPIO0`` ``GREEN_LED`` ``GREEN_LED`` -PA28 ``NINA_ACK`` ``BUTTON_A`` / ``D4`` +PA27 ``SD_CD`` ``ESP_GPIO0`` ``GREEN_LED`` ``GREEN_LED`` +PA28 ``ESP_ACK`` ``BUTTON_A`` / ``D4`` PA29 PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL`` PA31 diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c b/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c index 3478db9dff..653af1df39 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c @@ -6,7 +6,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA11) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA10) }, { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB09) }, { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA09) }, { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB23) }, @@ -23,15 +25,21 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA21) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB08) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB09) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + // NINA-W102 + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PA08) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_MOSI), MP_ROM_PTR(&pin_PA12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_MISO), MP_ROM_PTR(&pin_PA13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_CS), MP_ROM_PTR(&pin_PA14) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_SCK), MP_ROM_PTR(&pin_PA15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_GPIO0), MP_ROM_PTR(&pin_PA27) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_ACK), MP_ROM_PTR(&pin_PA28) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From e31ac710be0e1983ec791dc4db169505afdd8d63 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 20 Feb 2020 21:55:04 -0500 Subject: [PATCH 522/531] Enable _bleio adapter when _bleio is imported --- py/circuitpy_mpconfig.h | 1 + shared-bindings/_bleio/Adapter.c | 2 +- shared-bindings/_bleio/__init__.c | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index c1ac2cddb6..53cd7b0bb6 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -72,6 +72,7 @@ #define MICROPY_HELPER_REPL (1) #define MICROPY_KBD_EXCEPTION (1) #define MICROPY_MEM_STATS (0) +#define MICROPY_MODULE_BUILTIN_INIT (1) #define MICROPY_NONSTANDARD_TYPECODES (0) #define MICROPY_OPT_COMPUTED_GOTO (1) #define MICROPY_PERSISTENT_CODE_LOAD (1) diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 500055cf31..921667f0fb 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -117,7 +117,7 @@ const mp_obj_property_t bleio_adapter_address_obj = { //| .. attribute:: name //| -//| name of the BLE adapter used once connected. Not used in advertisements. +//| name of the BLE adapter used once connected. //| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``, //| to make it easy to distinguish multiple CircuitPython boards. //| diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index 5d26862a64..dd401398c5 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -132,6 +132,14 @@ NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t* fmt, ...) nlr_raise(exception); } +// Called when _bleio is imported. +STATIC mp_obj_t bleio___init__(void) { + common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, true); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(bleio___init___obj, bleio___init__); + + STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { // Name must be the first entry so that the exception printing below is correct. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__bleio) }, @@ -156,6 +164,10 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ConnectionError), MP_ROM_PTR(&mp_type_bleio_ConnectionError) }, { MP_ROM_QSTR(MP_QSTR_RoleError), MP_ROM_PTR(&mp_type_bleio_RoleError) }, { MP_ROM_QSTR(MP_QSTR_SecurityError), MP_ROM_PTR(&mp_type_bleio_SecurityError) }, + + // Initialization + { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&bleio___init___obj) }, + }; STATIC MP_DEFINE_CONST_DICT(bleio_module_globals, bleio_module_globals_table); From 9cf46ec9470c479a342d02ac18d0162298657c75 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 21 Feb 2020 08:44:25 -0500 Subject: [PATCH 523/531] put neopixel_write buffer in root pointers --- .../nrf/common-hal/neopixel_write/__init__.c | 26 +++++++++---------- ports/nrf/mpconfigport.h | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index cd1b4fe590..ec313d044e 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -25,6 +25,7 @@ */ #include "py/mphal.h" +#include "py/mpstate.h" #include "shared-bindings/neopixel_write/__init__.h" #include "nrf_pwm.h" @@ -97,14 +98,11 @@ static NRF_PWM_Type* find_free_pwm (void) { return NULL; } -static uint16_t* pixels_pattern_heap = NULL; static size_t pixels_pattern_heap_size = 0; -static bool pattern_on_heap = false; // Called during reset_port() to free the pattern buffer void neopixel_write_reset(void) { - pixels_pattern_heap = NULL; + MP_STATE_VM(pixels_pattern_heap) = NULL; pixels_pattern_heap_size = 0; - pattern_on_heap = false; } uint64_t next_start_tick_ms = 0; @@ -148,10 +146,11 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout (void) sd_softdevice_is_enabled(&sd_en); if (pixels_pattern_heap_size < pattern_size) { - if (pattern_on_heap) { - m_free(pixels_pattern_heap); + // Current heap buffer is too small. + if (MP_STATE_VM(pixels_pattern_heap)) { + // Old pixels_pattern_heap will be gc'd; don't free it. pixels_pattern = NULL; - pixels_pattern_heap = NULL; + MP_STATE_VM(pixels_pattern_heap) = NULL; pixels_pattern_heap_size = 0; } @@ -159,16 +158,17 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // If the soft device is enabled then we must use PWM to // transmit. This takes a bunch of memory to do so raise an // exception if we can't. - pixels_pattern_heap = (uint16_t *) m_malloc(pattern_size, false); + MP_STATE_VM(pixels_pattern_heap) = (uint16_t *) m_malloc(pattern_size, false); } else { - pixels_pattern_heap = (uint16_t *) m_malloc_maybe(pattern_size, false); + // Might return NULL. + MP_STATE_VM(pixels_pattern_heap) = (uint16_t *) m_malloc_maybe(pattern_size, false); } - if (pixels_pattern_heap) { - pattern_on_heap = true; + if (MP_STATE_VM(pixels_pattern_heap)) { pixels_pattern_heap_size = pattern_size; } } - pixels_pattern = pixels_pattern_heap; + // Might be NULL, which means we failed to allocate. + pixels_pattern = MP_STATE_VM(pixels_pattern_heap); } } @@ -176,7 +176,7 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout wait_until(next_start_tick_ms, next_start_tick_us); // Use the identified device to choose the implementation - // If a PWM device is available use DMA + // If a PWM device is available and we have a buffer, use DMA. if ( (pixels_pattern != NULL) && (pwm != NULL) ) { uint16_t pos = 0; // bit position diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 473169e946..44e51fc5f3 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -164,6 +164,7 @@ #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS \ + uint16_t* pixels_pattern_heap; \ ble_drv_evt_handler_entry_t* ble_drv_evt_handler_entries; \ From f63b2c0d0c364788f7951859733e6a5ca6150e0d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 21 Feb 2020 17:36:15 -0500 Subject: [PATCH 524/531] use realloc instead --- ports/nrf/common-hal/neopixel_write/__init__.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index ec313d044e..0a4036aae3 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -150,18 +150,21 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout if (MP_STATE_VM(pixels_pattern_heap)) { // Old pixels_pattern_heap will be gc'd; don't free it. pixels_pattern = NULL; - MP_STATE_VM(pixels_pattern_heap) = NULL; pixels_pattern_heap_size = 0; } + // realloc routines fall back to a plain malloc if the incoming ptr is NULL. if (sd_en) { // If the soft device is enabled then we must use PWM to // transmit. This takes a bunch of memory to do so raise an // exception if we can't. - MP_STATE_VM(pixels_pattern_heap) = (uint16_t *) m_malloc(pattern_size, false); + MP_STATE_VM(pixels_pattern_heap) = + (uint16_t *) m_realloc(MP_STATE_VM(pixels_pattern_heap), pattern_size); } else { // Might return NULL. - MP_STATE_VM(pixels_pattern_heap) = (uint16_t *) m_malloc_maybe(pattern_size, false); + MP_STATE_VM(pixels_pattern_heap) = + // true means move if necessary. + (uint16_t *) m_realloc_maybe(MP_STATE_VM(pixels_pattern_heap), pattern_size, true); } if (MP_STATE_VM(pixels_pattern_heap)) { pixels_pattern_heap_size = pattern_size; From 96db16a7a2c0ade89438391391c53efa1768f74e Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Sat, 22 Feb 2020 04:30:18 +0100 Subject: [PATCH 525/531] Last NINA pins --- ports/atmel-samd/README.rst | 6 +++--- ports/atmel-samd/boards/arduino_nano_33_iot/pins.c | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst index 31442e1d1c..b4d2085777 100644 --- a/ports/atmel-samd/README.rst +++ b/ports/atmel-samd/README.rst @@ -54,14 +54,14 @@ PA18 ``D8`` ``D10`` PA19 ``D10`` / ``MISO`` ``D12`` / ``MISO`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` / ``MISO`` ``D12`` PA20 ``D6`` ``D9`` ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6`` PA21 ``D7`` ``D10`` ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7`` ``D7`` ``D7`` -PA22 ``D0`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` -PA23 ``D1`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` ``SCL`` ``SCL`` +PA22 ``D0`` ``ESP_TX`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` +PA23 ``D1`` ``ESP_RX`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` ``SCL`` ``SCL`` PA24 PA25 PB22 ``D14`` / ``TX`` ``D1`` / ``TX`` ``FLASH_CS`` ``D30`` / ``TX1`` PB23 ``D13`` / ``RX`` ``D0`` / ``RX`` ``NEOPIXEL`` / ``D8`` ``D31`` / ``RX1`` PA27 ``SD_CD`` ``ESP_GPIO0`` ``GREEN_LED`` ``GREEN_LED`` -PA28 ``ESP_ACK`` ``BUTTON_A`` / ``D4`` +PA28 ``ESP_BUSY`` ``BUTTON_A`` / ``D4`` PA29 PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL`` PA31 diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c b/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c index 653af1df39..6b23cbf091 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/pins.c @@ -30,16 +30,20 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) }, { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + // NINA-W102 { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PA08) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_MOSI), MP_ROM_PTR(&pin_PA12) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_MISO), MP_ROM_PTR(&pin_PA13) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_CS), MP_ROM_PTR(&pin_PA14) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_SCK), MP_ROM_PTR(&pin_PA15) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PA22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PA23) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_GPIO0), MP_ROM_PTR(&pin_PA27) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_ACK), MP_ROM_PTR(&pin_PA28) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_PA28) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From d41cf2e9265e3250d8e98c06ce0ea8dfc523edb1 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Sun, 23 Feb 2020 11:16:24 +0000 Subject: [PATCH 526/531] Fix incorrect initialisation of default UART --- shared-module/board/__init__.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 952e1fc10c..bbf177384b 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -114,10 +114,12 @@ mp_obj_t common_hal_board_create_uart(void) { const mcu_pin_obj_t* rs485_dir = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RS485DIR); #ifdef DEFAULT_UART_RS485_INVERT const bool rs485_invert = true; +#else + const bool rs485_invert = false; #endif #else const mcu_pin_obj_t* rs485_dir = mp_const_none; - const bool rs485_invert = true; + const bool rs485_invert = false; #endif common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, From 876c646d097b79fdf45b94f5d4b1024585fd5cc3 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 24 Feb 2020 15:40:52 -0800 Subject: [PATCH 527/531] Fix Mac crash when waking up with an ejected CIRCUITPY We now correctly set the reason for the unit not being ready and always start the unit. Fixes #2567 --- supervisor/shared/usb/usb_msc_flash.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index c0279f9e5f..7532b6aead 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -208,6 +208,8 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) { return false; } if (ejected[lun]) { + // Set 0x3a for media not present. + tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x3A, 0x00); return false; } @@ -243,10 +245,8 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) { return false; } - } else { - // Start the unit, but only if not ejected. - return !ejected[lun]; } + // Always start the unit, even if ejected. Whether media is present is a separate check. } return true; From 28c7a1e9c3193f386197d6cb629f6843a6302d89 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 24 Feb 2020 16:11:17 -0800 Subject: [PATCH 528/531] Fix crash after empty REPL session We were trying to reset bluetooth when it was off and then trying to raise an exception without the heap. --- ports/nrf/common-hal/_bleio/Adapter.c | 5 ++++- ports/nrf/common-hal/_bleio/__init__.c | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index 09b7c95b9f..53015364a6 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -723,7 +723,10 @@ void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter) { void bleio_adapter_reset(bleio_adapter_obj_t* adapter) { common_hal_bleio_adapter_stop_scan(adapter); - common_hal_bleio_adapter_stop_advertising(adapter); + if (adapter->current_advertising_data != NULL) { + common_hal_bleio_adapter_stop_advertising(adapter); + } + adapter->connection_objs = NULL; for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { bleio_connection_internal_t *connection = &bleio_connections[i]; diff --git a/ports/nrf/common-hal/_bleio/__init__.c b/ports/nrf/common-hal/_bleio/__init__.c index 58e28c8c10..62a3a9299c 100644 --- a/ports/nrf/common-hal/_bleio/__init__.c +++ b/ports/nrf/common-hal/_bleio/__init__.c @@ -89,14 +89,15 @@ void check_sec_status(uint8_t sec_status) { // Turn off BLE on a reset or reload. void bleio_reset() { + if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) { + return; + } bleio_adapter_reset(&common_hal_bleio_adapter_obj); if (!vm_used_ble) { // No user-code BLE operations were done, so we can maintain the supervisor state. return; } - if (common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) { - common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false); - } + common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false); bonding_reset(); supervisor_start_bluetooth(); } From f20255813f56a17b8a83663173577a17fade5e45 Mon Sep 17 00:00:00 2001 From: jepler Date: Fri, 13 Sep 2019 12:28:30 -0500 Subject: [PATCH 529/531] samd51 thing plus: new port testing performed: * successfully store and retrieve a 500kB file on the flash * square wave output on each pin appears on o'scope * board.SPI(), board.SERIAL(), board.I2C() all construct --- .github/workflows/build.yml | 1 + .../boards/sparkfun_samd51_thing_plus/board.c | 38 +++++++++++++++++++ .../mpconfigboard.h | 33 ++++++++++++++++ .../mpconfigboard.mk | 17 +++++++++ .../boards/sparkfun_samd51_thing_plus/pins.c | 37 ++++++++++++++++++ supervisor/shared/external_flash/devices.h | 19 ++++++++++ 6 files changed, 145 insertions(+) create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e30311b8bf..118135850e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -219,6 +219,7 @@ jobs: - "sparkfun_redboard_turbo" - "sparkfun_samd21_dev" - "sparkfun_samd21_mini" + - "sparkfun_samd51_thing_plus" - "spresense" - "stm32f411ce_blackpill" - "stm32f411ve_discovery" diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c new file mode 100644 index 0000000000..8096b9b8ea --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.h new file mode 100644 index 0000000000..a5dee295bf --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.h @@ -0,0 +1,33 @@ +#define MICROPY_HW_BOARD_NAME "SparkFun Thing Plus - SAMD51" +#define MICROPY_HW_MCU_NAME "samd51j20" + +#define CIRCUITPY_MCU_FAMILY samd51 + +// On-board flash +#define SPI_FLASH_MOSI_PIN &pin_PA08 +#define SPI_FLASH_MISO_PIN &pin_PA11 +#define SPI_FLASH_SCK_PIN &pin_PA09 +#define SPI_FLASH_CS_PIN &pin_PA10 + +// These are pins not to reset. +// SPI Data pins +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PA22) +#define DEFAULT_I2C_BUS_SDA (&pin_PA23) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB12) +#define DEFAULT_SPI_BUS_MISO (&pin_PB11) + +#define DEFAULT_UART_BUS_RX (&pin_PA13) +#define DEFAULT_UART_BUS_TX (&pin_PA12) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk new file mode 100644 index 0000000000..13863e565f --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk @@ -0,0 +1,17 @@ +LD_FILE = boards/samd51x20-bootloader-external-flash.ld +USB_VID = 0x1b4f +USB_PID = 0x0016 # Used by uf2 bootloader +USB_PRODUCT = "SparkFun SAMD51 Thing+" +USB_MANUFACTURER = "SparkFun Electronics" + +CHIP_VARIANT = SAMD51J20A +CHIP_FAMILY = samd51 + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = AT25SF041A +LONGINT_IMPL = MPZ + +CIRCUITPY_NETWORK = 1 +MICROPY_PY_WIZNET5K = 5500 +CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c new file mode 100644 index 0000000000..a9ac6d98a9 --- /dev/null +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c @@ -0,0 +1,37 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA13) }, // D0 == RX + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA12) }, // D1 == TX + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/supervisor/shared/external_flash/devices.h b/supervisor/shared/external_flash/devices.h index 55a52b40d3..50263e5d6f 100644 --- a/supervisor/shared/external_flash/devices.h +++ b/supervisor/shared/external_flash/devices.h @@ -105,6 +105,25 @@ typedef struct { .single_status_byte = false, \ } +// Settings for the Adesto Tech AT25SF041 1MiB SPI flash. It's on the SparkFun +// SAMD51 Thing Plus board +// Datasheet: https://www.adestotech.com/wp-content/uploads/DS-AT25SF041_044.pdf +#define AT25SF041A {\ + .total_size = (1 << 19), /* 512 KiB */ \ + .start_up_time_us = 10000, \ + .manufacturer_id = 0x1f, \ + .memory_type = 0x84, \ + .capacity = 0x01, \ + .max_clock_speed_mhz = 85, \ + .quad_enable_bit_mask = 0x00, \ + .has_sector_protection = false, \ + .supports_fast_read = true, \ + .supports_qspi = false, \ + .supports_qspi_writes = false, \ + .write_status_register_split = false, \ + .single_status_byte = false, \ +} + // Settings for the Gigadevice GD25Q16C 2MiB SPI flash. // Datasheet: http://www.gigadevice.com/datasheet/gd25q16c/ #define GD25Q16C {\ From 86e9fd170ac345203cf2b873526d636481b8d792 Mon Sep 17 00:00:00 2001 From: ladyada Date: Tue, 25 Feb 2020 18:00:23 -0500 Subject: [PATCH 530/531] move red LED to D13 and make D3 lsm6ds IRQ --- ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h | 2 +- ports/nrf/boards/feather_bluefruit_sense/pins.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h index 4b2b69e7e8..65d8a642e8 100644 --- a/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h +++ b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h @@ -32,7 +32,7 @@ #define MICROPY_HW_NEOPIXEL (&pin_P0_16) -#define MICROPY_HW_LED_STATUS (&pin_P1_11) +#define MICROPY_HW_LED_STATUS (&pin_P1_09) // Board does not have a 32kHz crystal. It does have a 32MHz crystal. #define BOARD_HAS_32KHZ_XTAL (0) diff --git a/ports/nrf/boards/feather_bluefruit_sense/pins.c b/ports/nrf/boards/feather_bluefruit_sense/pins.c index 55eb764632..c4863e17fb 100644 --- a/ports/nrf/boards/feather_bluefruit_sense/pins.c +++ b/ports/nrf/boards/feather_bluefruit_sense/pins.c @@ -19,6 +19,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) }, { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P1_11) }, { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_08) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_07) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_26) }, @@ -39,9 +40,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_12) }, - { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_11) }, - { MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_P1_11) }, - { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P1_11) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_09) }, + { MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_P1_09) }, { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_P1_10) }, @@ -50,6 +50,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_PROXIMITY_LIGHT_INTERRUPT), MP_ROM_PTR(&pin_P1_00) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_GYRO_INTERRUPT), MP_ROM_PTR(&pin_P1_11) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, From aadb0bfc1e22223dad82cfe0ad121501f1089f23 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Wed, 26 Feb 2020 14:28:54 +0000 Subject: [PATCH 531/531] Fix SPI clock speed on mimxrt10xx family & mimxrt1020 pinmux fixup --- ports/mimxrt10xx/common-hal/busio/SPI.c | 3 +- .../mimxrt10xx/MIMXRT1021/periph.c | 52 +++++++++---------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c index 5ff94bcf89..b262d1a461 100644 --- a/ports/mimxrt10xx/common-hal/busio/SPI.c +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -95,8 +95,7 @@ static void config_periph_pin(const mcu_periph_obj_t *periph) { | IOMUXC_SW_PAD_CTL_PAD_SRE(0)); } -#define LPSPI_CLOCK_SOURCE_DIVIDER (7U) -#define LPSPI_MASTER_CLK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk) / (LPSPI_CLOCK_SOURCE_DIVIDER + 1U)) +#define LPSPI_MASTER_CLK_FREQ (CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk) / (CLOCK_GetDiv(kCLOCK_LpspiDiv))) void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c index 0417f29cc2..60f301668a 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c @@ -33,28 +33,28 @@ LPI2C_Type *mcu_i2c_banks[] = { LPI2C1, LPI2C2, LPI2C3, LPI2C4 }; const mcu_periph_obj_t mcu_i2c_sda_list[8] = { - PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_B1_15), - PERIPH_PIN(1, 6, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 1, &pin_GPIO_EMC_03), + PERIPH_PIN(1, 6, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 0, &pin_GPIO_EMC_03), + PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SDA_SELECT_INPUT, 1, &pin_GPIO_AD_B1_15), PERIPH_PIN(2, 0, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_B1_09), PERIPH_PIN(2, 2, kIOMUXC_LPI2C2_SDA_SELECT_INPUT, 1, &pin_GPIO_EMC_18), - PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 0, &pin_GPIO_AD_B0_09), - PERIPH_PIN(3, 4, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 1, &pin_GPIO_SD_B0_01), + PERIPH_PIN(3, 4, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 0, &pin_GPIO_SD_B0_01), + PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SDA_SELECT_INPUT, 1, &pin_GPIO_AD_B0_09), PERIPH_PIN(4, 2, kIOMUXC_LPI2C4_SDA_SELECT_INPUT, 0, &pin_GPIO_EMC_10), PERIPH_PIN(4, 3, kIOMUXC_LPI2C4_SDA_SELECT_INPUT, 1, &pin_GPIO_SD_B1_03), }; const mcu_periph_obj_t mcu_i2c_scl_list[8] = { - PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_B1_14), - PERIPH_PIN(1, 6, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 1, &pin_GPIO_EMC_02), + PERIPH_PIN(1, 6, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 0, &pin_GPIO_EMC_02), + PERIPH_PIN(1, 0, kIOMUXC_LPI2C1_SCL_SELECT_INPUT, 1, &pin_GPIO_AD_B1_14), PERIPH_PIN(2, 0, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_B1_08), PERIPH_PIN(2, 2, kIOMUXC_LPI2C2_SCL_SELECT_INPUT, 1, &pin_GPIO_EMC_19), - PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 0, &pin_GPIO_AD_B0_08), - PERIPH_PIN(3, 4, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 1, &pin_GPIO_SD_B0_00), + PERIPH_PIN(3, 4, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 0, &pin_GPIO_SD_B0_00), + PERIPH_PIN(3, 1, kIOMUXC_LPI2C3_SCL_SELECT_INPUT, 1, &pin_GPIO_AD_B0_08), PERIPH_PIN(4, 2, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 0, &pin_GPIO_EMC_11), PERIPH_PIN(4, 3, kIOMUXC_LPI2C4_SCL_SELECT_INPUT, 1, &pin_GPIO_SD_B1_02), @@ -63,8 +63,8 @@ const mcu_periph_obj_t mcu_i2c_scl_list[8] = { LPSPI_Type *mcu_spi_banks[] = { LPSPI1, LPSPI2, LPSPI3, LPSPI4 }; const mcu_periph_obj_t mcu_spi_sck_list[8] = { - PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 0, &pin_GPIO_AD_B0_10), - PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 1, &pin_GPIO_SD_B0_02), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 0, &pin_GPIO_SD_B0_02), + PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SCK_SELECT_INPUT, 1, &pin_GPIO_AD_B0_10), PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 0, &pin_GPIO_EMC_00), PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SCK_SELECT_INPUT, 1, &pin_GPIO_EMC_10), @@ -77,31 +77,31 @@ const mcu_periph_obj_t mcu_spi_sck_list[8] = { }; const mcu_periph_obj_t mcu_spi_mosi_list[8] = { - PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B0_13), - PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 1, &pin_GPIO_SD_B0_05), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 0, &pin_GPIO_SD_B0_04), + PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SDO_SELECT_INPUT, 1, &pin_GPIO_AD_B0_12), - PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_EMC_03), - PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_EMC_13), - PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 2, &pin_GPIO_SD_B1_09), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_EMC_02), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_EMC_12), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 2, &pin_GPIO_SD_B1_08), - PERIPH_PIN(3, 2, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B1_15), + PERIPH_PIN(3, 2, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B1_14), - PERIPH_PIN(4, 2, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B1_05), - PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_EMC_35), + PERIPH_PIN(4, 2, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 0, &pin_GPIO_AD_B1_04), + PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SDO_SELECT_INPUT, 1, &pin_GPIO_EMC_34), }; const mcu_periph_obj_t mcu_spi_miso_list[8] = { - PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B0_12), - PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 1, &pin_GPIO_SD_B0_04), + PERIPH_PIN(1, 4, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 0, &pin_GPIO_SD_B0_05), + PERIPH_PIN(1, 1, kIOMUXC_LPSPI1_SDI_SELECT_INPUT, 1, &pin_GPIO_AD_B0_13), - PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_EMC_02), - PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_12), - PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 2, &pin_GPIO_SD_B1_08), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_EMC_03), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_13), + PERIPH_PIN(2, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 2, &pin_GPIO_SD_B1_09), - PERIPH_PIN(3, 2, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B1_14), + PERIPH_PIN(3, 2, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B1_15), - PERIPH_PIN(4, 2, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B1_04), - PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_34), + PERIPH_PIN(4, 2, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 0, &pin_GPIO_AD_B1_05), + PERIPH_PIN(4, 4, kIOMUXC_LPSPI2_SDI_SELECT_INPUT, 1, &pin_GPIO_EMC_35), }; LPUART_Type *mcu_uart_banks[] = { LPUART1, LPUART2, LPUART3, LPUART4, LPUART5, LPUART6, LPUART7, LPUART8 };